stm32g4xx_ll_tim.h 302 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724
  1. /**
  2. ******************************************************************************
  3. * @file stm32g4xx_ll_tim.h
  4. * @author MCD Application Team
  5. * @brief Header file of TIM LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2019 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 __STM32G4xx_LL_TIM_H
  20. #define __STM32G4xx_LL_TIM_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32g4xx.h"
  26. /** @addtogroup STM32G4xx_LL_Driver
  27. * @{
  28. */
  29. #if defined (TIM1) || defined (TIM2) || defined (TIM3) || defined (TIM4) || defined (TIM5) || defined (TIM6) || defined (TIM7) || defined (TIM8) || defined (TIM15) || defined (TIM16) || defined (TIM17) || defined (TIM20)
  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. 0x04U, /* 7: TIMx_CH4N */
  48. 0x38U, /* 8: TIMx_CH5 */
  49. 0x38U /* 9: TIMx_CH6 */
  50. };
  51. static const uint8_t SHIFT_TAB_OCxx[] =
  52. {
  53. 0U, /* 0: OC1M, OC1FE, OC1PE */
  54. 0U, /* 1: - NA */
  55. 8U, /* 2: OC2M, OC2FE, OC2PE */
  56. 0U, /* 3: - NA */
  57. 0U, /* 4: OC3M, OC3FE, OC3PE */
  58. 0U, /* 5: - NA */
  59. 8U, /* 6: OC4M, OC4FE, OC4PE */
  60. 0U, /* 7: - NA */
  61. 0U, /* 8: OC5M, OC5FE, OC5PE */
  62. 8U /* 9: OC6M, OC6FE, OC6PE */
  63. };
  64. static const uint8_t SHIFT_TAB_ICxx[] =
  65. {
  66. 0U, /* 0: CC1S, IC1PSC, IC1F */
  67. 0U, /* 1: - NA */
  68. 8U, /* 2: CC2S, IC2PSC, IC2F */
  69. 0U, /* 3: - NA */
  70. 0U, /* 4: CC3S, IC3PSC, IC3F */
  71. 0U, /* 5: - NA */
  72. 8U, /* 6: CC4S, IC4PSC, IC4F */
  73. 0U, /* 7: - NA */
  74. 0U, /* 8: - NA */
  75. 0U /* 9: - NA */
  76. };
  77. static const uint8_t SHIFT_TAB_CCxP[] =
  78. {
  79. 0U, /* 0: CC1P */
  80. 2U, /* 1: CC1NP */
  81. 4U, /* 2: CC2P */
  82. 6U, /* 3: CC2NP */
  83. 8U, /* 4: CC3P */
  84. 10U, /* 5: CC3NP */
  85. 12U, /* 6: CC4P */
  86. 14U, /* 7: CC4NP */
  87. 16U, /* 8: CC5P */
  88. 20U /* 9: CC6P */
  89. };
  90. static const uint8_t SHIFT_TAB_OISx[] =
  91. {
  92. 0U, /* 0: OIS1 */
  93. 1U, /* 1: OIS1N */
  94. 2U, /* 2: OIS2 */
  95. 3U, /* 3: OIS2N */
  96. 4U, /* 4: OIS3 */
  97. 5U, /* 5: OIS3N */
  98. 6U, /* 6: OIS4 */
  99. 7U, /* 7: OIS4N */
  100. 8U, /* 8: OIS5 */
  101. 10U /* 9: OIS6 */
  102. };
  103. /**
  104. * @}
  105. */
  106. /* Private constants ---------------------------------------------------------*/
  107. /** @defgroup TIM_LL_Private_Constants TIM Private Constants
  108. * @{
  109. */
  110. /* Defines used for the bit position in the register and perform offsets */
  111. #define TIM_POSITION_BRK_SOURCE (POSITION_VAL(Source) & 0x1FUL)
  112. /* Generic bit definitions for TIMx_AF1 register */
  113. #define TIMx_AF1_BKINP TIM1_AF1_BKINP /*!< BRK BKIN input polarity */
  114. #define TIMx_AF1_ETRSEL TIM1_AF1_ETRSEL /*!< TIMx ETR source selection */
  115. /* Mask used to set the TDG[x:0] of the DTG bits of the TIMx_BDTR register */
  116. #define DT_DELAY_1 ((uint8_t)0x7F)
  117. #define DT_DELAY_2 ((uint8_t)0x3F)
  118. #define DT_DELAY_3 ((uint8_t)0x1F)
  119. #define DT_DELAY_4 ((uint8_t)0x1F)
  120. /* Mask used to set the DTG[7:5] bits of the DTG bits of the TIMx_BDTR register */
  121. #define DT_RANGE_1 ((uint8_t)0x00)
  122. #define DT_RANGE_2 ((uint8_t)0x80)
  123. #define DT_RANGE_3 ((uint8_t)0xC0)
  124. #define DT_RANGE_4 ((uint8_t)0xE0)
  125. /** Legacy definitions for compatibility purpose
  126. @cond 0
  127. */
  128. /**
  129. @endcond
  130. */
  131. #define OCREF_CLEAR_SELECT_Pos (28U)
  132. #define OCREF_CLEAR_SELECT_Msk (0x1U << OCREF_CLEAR_SELECT_Pos) /*!< 0x10000000 */
  133. /**
  134. * @}
  135. */
  136. /* Private macros ------------------------------------------------------------*/
  137. /** @defgroup TIM_LL_Private_Macros TIM Private Macros
  138. * @{
  139. */
  140. /** @brief Convert channel id into channel index.
  141. * @param __CHANNEL__ This parameter can be one of the following values:
  142. * @arg @ref LL_TIM_CHANNEL_CH1
  143. * @arg @ref LL_TIM_CHANNEL_CH1N
  144. * @arg @ref LL_TIM_CHANNEL_CH2
  145. * @arg @ref LL_TIM_CHANNEL_CH2N
  146. * @arg @ref LL_TIM_CHANNEL_CH3
  147. * @arg @ref LL_TIM_CHANNEL_CH3N
  148. * @arg @ref LL_TIM_CHANNEL_CH4
  149. * @arg @ref LL_TIM_CHANNEL_CH4N
  150. * @arg @ref LL_TIM_CHANNEL_CH5
  151. * @arg @ref LL_TIM_CHANNEL_CH6
  152. * @retval none
  153. */
  154. #define TIM_GET_CHANNEL_INDEX( __CHANNEL__) \
  155. (((__CHANNEL__) == LL_TIM_CHANNEL_CH1) ? 0U :\
  156. ((__CHANNEL__) == LL_TIM_CHANNEL_CH1N) ? 1U :\
  157. ((__CHANNEL__) == LL_TIM_CHANNEL_CH2) ? 2U :\
  158. ((__CHANNEL__) == LL_TIM_CHANNEL_CH2N) ? 3U :\
  159. ((__CHANNEL__) == LL_TIM_CHANNEL_CH3) ? 4U :\
  160. ((__CHANNEL__) == LL_TIM_CHANNEL_CH3N) ? 5U :\
  161. ((__CHANNEL__) == LL_TIM_CHANNEL_CH4) ? 6U :\
  162. ((__CHANNEL__) == LL_TIM_CHANNEL_CH4N) ? 7U :\
  163. ((__CHANNEL__) == LL_TIM_CHANNEL_CH5) ? 8U : 9U)
  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. #define LL_TIM_SR_IDXF TIM_SR_IDXF /*!< Index interrupt flag */
  464. #define LL_TIM_SR_DIRF TIM_SR_DIRF /*!< Direction Change interrupt flag */
  465. #define LL_TIM_SR_IERRF TIM_SR_IERRF /*!< Index Error flag */
  466. #define LL_TIM_SR_TERRF TIM_SR_TERRF /*!< Transition Error flag */
  467. /**
  468. * @}
  469. */
  470. #if defined(USE_FULL_LL_DRIVER)
  471. /** @defgroup TIM_LL_EC_BREAK_ENABLE Break Enable
  472. * @{
  473. */
  474. #define LL_TIM_BREAK_DISABLE 0x00000000U /*!< Break function disabled */
  475. #define LL_TIM_BREAK_ENABLE TIM_BDTR_BKE /*!< Break function enabled */
  476. /**
  477. * @}
  478. */
  479. /** @defgroup TIM_LL_EC_BREAK2_ENABLE Break2 Enable
  480. * @{
  481. */
  482. #define LL_TIM_BREAK2_DISABLE 0x00000000U /*!< Break2 function disabled */
  483. #define LL_TIM_BREAK2_ENABLE TIM_BDTR_BK2E /*!< Break2 function enabled */
  484. /**
  485. * @}
  486. */
  487. /** @defgroup TIM_LL_EC_AUTOMATICOUTPUT_ENABLE Automatic output enable
  488. * @{
  489. */
  490. #define LL_TIM_AUTOMATICOUTPUT_DISABLE 0x00000000U /*!< MOE can be set only by software */
  491. #define LL_TIM_AUTOMATICOUTPUT_ENABLE TIM_BDTR_AOE /*!< MOE can be set by software or automatically at the next update event */
  492. /**
  493. * @}
  494. */
  495. #endif /* USE_FULL_LL_DRIVER */
  496. /** @defgroup TIM_LL_EC_IT IT Defines
  497. * @brief IT defines which can be used with LL_TIM_ReadReg and LL_TIM_WriteReg functions.
  498. * @{
  499. */
  500. #define LL_TIM_DIER_UIE TIM_DIER_UIE /*!< Update interrupt enable */
  501. #define LL_TIM_DIER_CC1IE TIM_DIER_CC1IE /*!< Capture/compare 1 interrupt enable */
  502. #define LL_TIM_DIER_CC2IE TIM_DIER_CC2IE /*!< Capture/compare 2 interrupt enable */
  503. #define LL_TIM_DIER_CC3IE TIM_DIER_CC3IE /*!< Capture/compare 3 interrupt enable */
  504. #define LL_TIM_DIER_CC4IE TIM_DIER_CC4IE /*!< Capture/compare 4 interrupt enable */
  505. #define LL_TIM_DIER_COMIE TIM_DIER_COMIE /*!< COM interrupt enable */
  506. #define LL_TIM_DIER_TIE TIM_DIER_TIE /*!< Trigger interrupt enable */
  507. #define LL_TIM_DIER_BIE TIM_DIER_BIE /*!< Break interrupt enable */
  508. #define LL_TIM_DIER_IDXIE TIM_DIER_IDXIE /*!< Index interrupt enable */
  509. #define LL_TIM_DIER_DIRIE TIM_DIER_DIRIE /*!< Direction Change interrupt enable */
  510. #define LL_TIM_DIER_IERRIE TIM_DIER_IERRIE /*!< Index Error interrupt enable */
  511. #define LL_TIM_DIER_TERRIE TIM_DIER_TERRIE /*!< Transition Error interrupt enable */
  512. /**
  513. * @}
  514. */
  515. /** @defgroup TIM_LL_EC_UPDATESOURCE Update Source
  516. * @{
  517. */
  518. #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 */
  519. #define LL_TIM_UPDATESOURCE_COUNTER TIM_CR1_URS /*!< Only counter overflow/underflow generates an update request */
  520. /**
  521. * @}
  522. */
  523. /** @defgroup TIM_LL_EC_ONEPULSEMODE One Pulse Mode
  524. * @{
  525. */
  526. #define LL_TIM_ONEPULSEMODE_SINGLE TIM_CR1_OPM /*!< Counter stops counting at the next update event */
  527. #define LL_TIM_ONEPULSEMODE_REPETITIVE 0x00000000U /*!< Counter is not stopped at update event */
  528. /**
  529. * @}
  530. */
  531. /** @defgroup TIM_LL_EC_COUNTERMODE Counter Mode
  532. * @{
  533. */
  534. #define LL_TIM_COUNTERMODE_UP 0x00000000U /*!< Counter used as upcounter */
  535. #define LL_TIM_COUNTERMODE_DOWN TIM_CR1_DIR /*!< Counter used as downcounter */
  536. #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. */
  537. #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 */
  538. #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. */
  539. /**
  540. * @}
  541. */
  542. /** @defgroup TIM_LL_EC_CLOCKDIVISION Clock Division
  543. * @{
  544. */
  545. #define LL_TIM_CLOCKDIVISION_DIV1 0x00000000U /*!< tDTS=tCK_INT */
  546. #define LL_TIM_CLOCKDIVISION_DIV2 TIM_CR1_CKD_0 /*!< tDTS=2*tCK_INT */
  547. #define LL_TIM_CLOCKDIVISION_DIV4 TIM_CR1_CKD_1 /*!< tDTS=4*tCK_INT */
  548. /**
  549. * @}
  550. */
  551. /** @defgroup TIM_LL_EC_COUNTERDIRECTION Counter Direction
  552. * @{
  553. */
  554. #define LL_TIM_COUNTERDIRECTION_UP 0x00000000U /*!< Timer counter counts up */
  555. #define LL_TIM_COUNTERDIRECTION_DOWN TIM_CR1_DIR /*!< Timer counter counts down */
  556. /**
  557. * @}
  558. */
  559. /** @defgroup TIM_LL_EC_CCUPDATESOURCE Capture Compare Update Source
  560. * @{
  561. */
  562. #define LL_TIM_CCUPDATESOURCE_COMG_ONLY 0x00000000U /*!< Capture/compare control bits are updated by setting the COMG bit only */
  563. #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) */
  564. /**
  565. * @}
  566. */
  567. /** @defgroup TIM_LL_EC_CCDMAREQUEST Capture Compare DMA Request
  568. * @{
  569. */
  570. #define LL_TIM_CCDMAREQUEST_CC 0x00000000U /*!< CCx DMA request sent when CCx event occurs */
  571. #define LL_TIM_CCDMAREQUEST_UPDATE TIM_CR2_CCDS /*!< CCx DMA requests sent when update event occurs */
  572. /**
  573. * @}
  574. */
  575. /** @defgroup TIM_LL_EC_LOCKLEVEL Lock Level
  576. * @{
  577. */
  578. #define LL_TIM_LOCKLEVEL_OFF 0x00000000U /*!< LOCK OFF - No bit is write protected */
  579. #define LL_TIM_LOCKLEVEL_1 TIM_BDTR_LOCK_0 /*!< LOCK Level 1 */
  580. #define LL_TIM_LOCKLEVEL_2 TIM_BDTR_LOCK_1 /*!< LOCK Level 2 */
  581. #define LL_TIM_LOCKLEVEL_3 TIM_BDTR_LOCK /*!< LOCK Level 3 */
  582. /**
  583. * @}
  584. */
  585. /** @defgroup TIM_LL_EC_CHANNEL Channel
  586. * @{
  587. */
  588. #define LL_TIM_CHANNEL_CH1 TIM_CCER_CC1E /*!< Timer input/output channel 1 */
  589. #define LL_TIM_CHANNEL_CH1N TIM_CCER_CC1NE /*!< Timer complementary output channel 1 */
  590. #define LL_TIM_CHANNEL_CH2 TIM_CCER_CC2E /*!< Timer input/output channel 2 */
  591. #define LL_TIM_CHANNEL_CH2N TIM_CCER_CC2NE /*!< Timer complementary output channel 2 */
  592. #define LL_TIM_CHANNEL_CH3 TIM_CCER_CC3E /*!< Timer input/output channel 3 */
  593. #define LL_TIM_CHANNEL_CH3N TIM_CCER_CC3NE /*!< Timer complementary output channel 3 */
  594. #define LL_TIM_CHANNEL_CH4 TIM_CCER_CC4E /*!< Timer input/output channel 4 */
  595. #define LL_TIM_CHANNEL_CH4N TIM_CCER_CC4NE /*!< Timer complementary output channel 4 */
  596. #define LL_TIM_CHANNEL_CH5 TIM_CCER_CC5E /*!< Timer output channel 5 */
  597. #define LL_TIM_CHANNEL_CH6 TIM_CCER_CC6E /*!< Timer output channel 6 */
  598. /**
  599. * @}
  600. */
  601. #if defined(USE_FULL_LL_DRIVER)
  602. /** @defgroup TIM_LL_EC_OCSTATE Output Configuration State
  603. * @{
  604. */
  605. #define LL_TIM_OCSTATE_DISABLE 0x00000000U /*!< OCx is not active */
  606. #define LL_TIM_OCSTATE_ENABLE TIM_CCER_CC1E /*!< OCx signal is output on the corresponding output pin */
  607. /**
  608. * @}
  609. */
  610. #endif /* USE_FULL_LL_DRIVER */
  611. /** Legacy definitions for compatibility purpose
  612. @cond 0
  613. */
  614. #define LL_TIM_OCMODE_ASSYMETRIC_PWM1 LL_TIM_OCMODE_ASYMMETRIC_PWM1
  615. #define LL_TIM_OCMODE_ASSYMETRIC_PWM2 LL_TIM_OCMODE_ASYMMETRIC_PWM2
  616. /**
  617. @endcond
  618. */
  619. /** @defgroup TIM_LL_EC_OCMODE Output Configuration Mode
  620. * @{
  621. */
  622. #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 */
  623. #define LL_TIM_OCMODE_ACTIVE TIM_CCMR1_OC1M_0 /*!<OCyREF is forced high on compare match*/
  624. #define LL_TIM_OCMODE_INACTIVE TIM_CCMR1_OC1M_1 /*!<OCyREF is forced low on compare match*/
  625. #define LL_TIM_OCMODE_TOGGLE (TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0) /*!<OCyREF toggles on compare match*/
  626. #define LL_TIM_OCMODE_FORCED_INACTIVE TIM_CCMR1_OC1M_2 /*!<OCyREF is forced low*/
  627. #define LL_TIM_OCMODE_FORCED_ACTIVE (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_0) /*!<OCyREF is forced high*/
  628. #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.*/
  629. #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*/
  630. #define LL_TIM_OCMODE_RETRIG_OPM1 TIM_CCMR1_OC1M_3 /*!<Retrigerrable OPM mode 1*/
  631. #define LL_TIM_OCMODE_RETRIG_OPM2 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_0) /*!<Retrigerrable OPM mode 2*/
  632. #define LL_TIM_OCMODE_COMBINED_PWM1 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_2) /*!<Combined PWM mode 1*/
  633. #define LL_TIM_OCMODE_COMBINED_PWM2 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_0 | TIM_CCMR1_OC1M_2) /*!<Combined PWM mode 2*/
  634. #define LL_TIM_OCMODE_ASYMMETRIC_PWM1 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2) /*!<Asymmetric PWM mode 1*/
  635. #define LL_TIM_OCMODE_ASYMMETRIC_PWM2 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M) /*!<Asymmetric PWM mode 2*/
  636. #define LL_TIM_OCMODE_PULSE_ON_COMPARE (TIM_CCMR2_OC3M_3 | TIM_CCMR2_OC3M_1) /*!<Pulse on Compare mode */
  637. #define LL_TIM_OCMODE_DIRECTION_OUTPUT (TIM_CCMR2_OC3M_3 | TIM_CCMR2_OC3M_1 | TIM_CCMR2_OC3M_0) /*!<Direction output mode */
  638. /**
  639. * @}
  640. */
  641. /** @defgroup TIM_LL_EC_OCPOLARITY Output Configuration Polarity
  642. * @{
  643. */
  644. #define LL_TIM_OCPOLARITY_HIGH 0x00000000U /*!< OCxactive high*/
  645. #define LL_TIM_OCPOLARITY_LOW TIM_CCER_CC1P /*!< OCxactive low*/
  646. /**
  647. * @}
  648. */
  649. /** @defgroup TIM_LL_EC_OCIDLESTATE Output Configuration Idle State
  650. * @{
  651. */
  652. #define LL_TIM_OCIDLESTATE_LOW 0x00000000U /*!<OCx=0 (after a dead-time if OC is implemented) when MOE=0*/
  653. #define LL_TIM_OCIDLESTATE_HIGH TIM_CR2_OIS1 /*!<OCx=1 (after a dead-time if OC is implemented) when MOE=0*/
  654. /**
  655. * @}
  656. */
  657. /** @defgroup TIM_LL_EC_GROUPCH5 GROUPCH5
  658. * @{
  659. */
  660. #define LL_TIM_GROUPCH5_NONE 0x00000000U /*!< No effect of OC5REF on OC1REFC, OC2REFC and OC3REFC */
  661. #define LL_TIM_GROUPCH5_OC1REFC TIM_CCR5_GC5C1 /*!< OC1REFC is the logical AND of OC1REFC and OC5REF */
  662. #define LL_TIM_GROUPCH5_OC2REFC TIM_CCR5_GC5C2 /*!< OC2REFC is the logical AND of OC2REFC and OC5REF */
  663. #define LL_TIM_GROUPCH5_OC3REFC TIM_CCR5_GC5C3 /*!< OC3REFC is the logical AND of OC3REFC and OC5REF */
  664. /**
  665. * @}
  666. */
  667. /** @defgroup TIM_LL_EC_ACTIVEINPUT Active Input Selection
  668. * @{
  669. */
  670. #define LL_TIM_ACTIVEINPUT_DIRECTTI (TIM_CCMR1_CC1S_0 << 16U) /*!< ICx is mapped on TIx */
  671. #define LL_TIM_ACTIVEINPUT_INDIRECTTI (TIM_CCMR1_CC1S_1 << 16U) /*!< ICx is mapped on TIy */
  672. #define LL_TIM_ACTIVEINPUT_TRC (TIM_CCMR1_CC1S << 16U) /*!< ICx is mapped on TRC */
  673. /**
  674. * @}
  675. */
  676. /** @defgroup TIM_LL_EC_ICPSC Input Configuration Prescaler
  677. * @{
  678. */
  679. #define LL_TIM_ICPSC_DIV1 0x00000000U /*!< No prescaler, capture is done each time an edge is detected on the capture input */
  680. #define LL_TIM_ICPSC_DIV2 (TIM_CCMR1_IC1PSC_0 << 16U) /*!< Capture is done once every 2 events */
  681. #define LL_TIM_ICPSC_DIV4 (TIM_CCMR1_IC1PSC_1 << 16U) /*!< Capture is done once every 4 events */
  682. #define LL_TIM_ICPSC_DIV8 (TIM_CCMR1_IC1PSC << 16U) /*!< Capture is done once every 8 events */
  683. /**
  684. * @}
  685. */
  686. /** @defgroup TIM_LL_EC_IC_FILTER Input Configuration Filter
  687. * @{
  688. */
  689. #define LL_TIM_IC_FILTER_FDIV1 0x00000000U /*!< No filter, sampling is done at fDTS */
  690. #define LL_TIM_IC_FILTER_FDIV1_N2 (TIM_CCMR1_IC1F_0 << 16U) /*!< fSAMPLING=fCK_INT, N=2 */
  691. #define LL_TIM_IC_FILTER_FDIV1_N4 (TIM_CCMR1_IC1F_1 << 16U) /*!< fSAMPLING=fCK_INT, N=4 */
  692. #define LL_TIM_IC_FILTER_FDIV1_N8 ((TIM_CCMR1_IC1F_1 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fCK_INT, N=8 */
  693. #define LL_TIM_IC_FILTER_FDIV2_N6 (TIM_CCMR1_IC1F_2 << 16U) /*!< fSAMPLING=fDTS/2, N=6 */
  694. #define LL_TIM_IC_FILTER_FDIV2_N8 ((TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/2, N=8 */
  695. #define LL_TIM_IC_FILTER_FDIV4_N6 ((TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_1) << 16U) /*!< fSAMPLING=fDTS/4, N=6 */
  696. #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 */
  697. #define LL_TIM_IC_FILTER_FDIV8_N6 (TIM_CCMR1_IC1F_3 << 16U) /*!< fSAMPLING=fDTS/8, N=6 */
  698. #define LL_TIM_IC_FILTER_FDIV8_N8 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/8, N=8 */
  699. #define LL_TIM_IC_FILTER_FDIV16_N5 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_1) << 16U) /*!< fSAMPLING=fDTS/16, N=5 */
  700. #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 */
  701. #define LL_TIM_IC_FILTER_FDIV16_N8 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_2) << 16U) /*!< fSAMPLING=fDTS/16, N=8 */
  702. #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 */
  703. #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 */
  704. #define LL_TIM_IC_FILTER_FDIV32_N8 (TIM_CCMR1_IC1F << 16U) /*!< fSAMPLING=fDTS/32, N=8 */
  705. /**
  706. * @}
  707. */
  708. /** @defgroup TIM_LL_EC_IC_POLARITY Input Configuration Polarity
  709. * @{
  710. */
  711. #define LL_TIM_IC_POLARITY_RISING 0x00000000U /*!< The circuit is sensitive to TIxFP1 rising edge, TIxFP1 is not inverted */
  712. #define LL_TIM_IC_POLARITY_FALLING TIM_CCER_CC1P /*!< The circuit is sensitive to TIxFP1 falling edge, TIxFP1 is inverted */
  713. #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 */
  714. /**
  715. * @}
  716. */
  717. /** @defgroup TIM_LL_EC_CLOCKSOURCE Clock Source
  718. * @{
  719. */
  720. #define LL_TIM_CLOCKSOURCE_INTERNAL 0x00000000U /*!< The timer is clocked by the internal clock provided from the RCC */
  721. #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*/
  722. #define LL_TIM_CLOCKSOURCE_EXT_MODE2 TIM_SMCR_ECE /*!< Counter counts at each rising or falling edge on the external trigger input ETR */
  723. /**
  724. * @}
  725. */
  726. /** @defgroup TIM_LL_EC_ENCODERMODE Encoder Mode
  727. * @{
  728. */
  729. #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 */
  730. #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 */
  731. #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 */
  732. #define LL_TIM_ENCODERMODE_CLOCKPLUSDIRECTION_X2 (TIM_SMCR_SMS_3 | TIM_SMCR_SMS_1) /*!< Encoder mode: Clock plus direction - x2 mode */
  733. #define LL_TIM_ENCODERMODE_CLOCKPLUSDIRECTION_X1 (TIM_SMCR_SMS_3 | TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0) /*!< Encoder mode: Clock plus direction, x1 mode, TI2FP2 edge sensitivity is set by CC2P */
  734. #define LL_TIM_ENCODERMODE_DIRECTIONALCLOCK_X2 (TIM_SMCR_SMS_3 | TIM_SMCR_SMS_2) /*!< Encoder mode: Directional Clock, x2 mode */
  735. #define LL_TIM_ENCODERMODE_DIRECTIONALCLOCK_X1_TI12 (TIM_SMCR_SMS_3 | TIM_SMCR_SMS_2 | TIM_SMCR_SMS_0) /*!< Encoder mode: Directional Clock, x1 mode, TI1FP1 and TI2FP2 edge sensitivity is set by CC1P and CC2P */
  736. #define LL_TIM_ENCODERMODE_X1_TI1 (TIM_SMCR_SMS_3 | TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1) /*!< Quadrature encoder mode: x1 mode, counting on TI1FP1 edges only, edge sensitivity is set by CC1P */
  737. #define LL_TIM_ENCODERMODE_X1_TI2 (TIM_SMCR_SMS_3 | TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0) /*!< Quadrature encoder mode: x1 mode, counting on TI2FP2 edges only, edge sensitivity is set by CC1P */
  738. /**
  739. * @}
  740. */
  741. /** @defgroup TIM_LL_EC_TRGO Trigger Output
  742. * @{
  743. */
  744. #define LL_TIM_TRGO_RESET 0x00000000U /*!< UG bit from the TIMx_EGR register is used as trigger output */
  745. #define LL_TIM_TRGO_ENABLE TIM_CR2_MMS_0 /*!< Counter Enable signal (CNT_EN) is used as trigger output */
  746. #define LL_TIM_TRGO_UPDATE TIM_CR2_MMS_1 /*!< Update event is used as trigger output */
  747. #define LL_TIM_TRGO_CC1IF (TIM_CR2_MMS_1 | TIM_CR2_MMS_0) /*!< CC1 capture or a compare match is used as trigger output */
  748. #define LL_TIM_TRGO_OC1REF TIM_CR2_MMS_2 /*!< OC1REF signal is used as trigger output */
  749. #define LL_TIM_TRGO_OC2REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_0) /*!< OC2REF signal is used as trigger output */
  750. #define LL_TIM_TRGO_OC3REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_1) /*!< OC3REF signal is used as trigger output */
  751. #define LL_TIM_TRGO_OC4REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_1 | TIM_CR2_MMS_0) /*!< OC4REF signal is used as trigger output */
  752. #define LL_TIM_TRGO_ENCODERCLK TIM_CR2_MMS_3 /*!< Encoder clock signal is used as trigger output */
  753. /**
  754. * @}
  755. */
  756. /** @defgroup TIM_LL_EC_TRGO2 Trigger Output 2
  757. * @{
  758. */
  759. #define LL_TIM_TRGO2_RESET 0x00000000U /*!< UG bit from the TIMx_EGR register is used as trigger output 2 */
  760. #define LL_TIM_TRGO2_ENABLE TIM_CR2_MMS2_0 /*!< Counter Enable signal (CNT_EN) is used as trigger output 2 */
  761. #define LL_TIM_TRGO2_UPDATE TIM_CR2_MMS2_1 /*!< Update event is used as trigger output 2 */
  762. #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 */
  763. #define LL_TIM_TRGO2_OC1 TIM_CR2_MMS2_2 /*!< OC1REF signal is used as trigger output 2 */
  764. #define LL_TIM_TRGO2_OC2 (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_0) /*!< OC2REF signal is used as trigger output 2 */
  765. #define LL_TIM_TRGO2_OC3 (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1) /*!< OC3REF signal is used as trigger output 2 */
  766. #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 */
  767. #define LL_TIM_TRGO2_OC5 TIM_CR2_MMS2_3 /*!< OC5REF signal is used as trigger output 2 */
  768. #define LL_TIM_TRGO2_OC6 (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_0) /*!< OC6REF signal is used as trigger output 2 */
  769. #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 */
  770. #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 */
  771. #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 */
  772. #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 */
  773. #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 */
  774. #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 */
  775. /**
  776. * @}
  777. */
  778. /** @defgroup TIM_LL_EC_SLAVEMODE Slave Mode
  779. * @{
  780. */
  781. #define LL_TIM_SLAVEMODE_DISABLED 0x00000000U /*!< Slave mode disabled */
  782. #define LL_TIM_SLAVEMODE_RESET TIM_SMCR_SMS_2 /*!< Reset Mode - Rising edge of the selected trigger input (TRGI) reinitializes the counter */
  783. #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 */
  784. #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 */
  785. #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 */
  786. #define LL_TIM_SLAVEMODE_COMBINED_GATEDRESET (TIM_SMCR_SMS_3 | TIM_SMCR_SMS_0) /*!< Combined gated + reset mode - The counter clock is enabled when the trigger input (TRGI) is high. The counter stops and is reset) as soon as the trigger becomes low.Both startand stop of
  787. the counter are controlled. */
  788. /**
  789. * @}
  790. */
  791. /** @defgroup TIM_LL_EC_SMS_PRELOAD_SOURCE SMS Preload Source
  792. * @{
  793. */
  794. #define LL_TIM_SMSPS_TIMUPDATE 0x00000000U /*!< The SMS preload transfer is triggered by the Timer's Update event */
  795. #define LL_TIM_SMSPS_INDEX TIM_SMCR_SMSPS /*!< The SMS preload transfer is triggered by the Index event */
  796. /**
  797. * @}
  798. */
  799. /** @defgroup TIM_LL_EC_TS Trigger Selection
  800. * @{
  801. */
  802. #define LL_TIM_TS_ITR0 0x00000000U /*!< Internal Trigger 0 (ITR0) is used as trigger input */
  803. #define LL_TIM_TS_ITR1 TIM_SMCR_TS_0 /*!< Internal Trigger 1 (ITR1) is used as trigger input */
  804. #define LL_TIM_TS_ITR2 TIM_SMCR_TS_1 /*!< Internal Trigger 2 (ITR2) is used as trigger input */
  805. #define LL_TIM_TS_ITR3 (TIM_SMCR_TS_0 | TIM_SMCR_TS_1) /*!< Internal Trigger 3 (ITR3) is used as trigger input */
  806. #define LL_TIM_TS_ITR4 TIM_SMCR_TS_3 /*!< Internal Trigger 4 (ITR4) is used as trigger input */
  807. #define LL_TIM_TS_ITR5 (TIM_SMCR_TS_3 | TIM_SMCR_TS_0) /*!< Internal Trigger 5 (ITR5) is used as trigger input */
  808. #define LL_TIM_TS_ITR6 (TIM_SMCR_TS_3 | TIM_SMCR_TS_1) /*!< Internal Trigger 6 (ITR6) is used as trigger input */
  809. #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 */
  810. #define LL_TIM_TS_ITR8 (TIM_SMCR_TS_3 | TIM_SMCR_TS_2) /*!< Internal Trigger 8 (ITR8) is used as trigger input */
  811. #define LL_TIM_TS_ITR9 (TIM_SMCR_TS_3 | TIM_SMCR_TS_2 | TIM_SMCR_TS_0) /*!< Internal Trigger 9 (ITR9) is used as trigger input */
  812. #define LL_TIM_TS_ITR10 (TIM_SMCR_TS_3 | TIM_SMCR_TS_2 | TIM_SMCR_TS_1) /*!< Internal Trigger 10 (ITR10) is used as trigger input */
  813. #define LL_TIM_TS_ITR11 (TIM_SMCR_TS_3 | TIM_SMCR_TS_2 | TIM_SMCR_TS_1 | TIM_SMCR_TS_0) /*!< Internal Trigger 11 (ITR11) is used as trigger input */
  814. #define LL_TIM_TS_TI1F_ED TIM_SMCR_TS_2 /*!< TI1 Edge Detector (TI1F_ED) is used as trigger input */
  815. #define LL_TIM_TS_TI1FP1 (TIM_SMCR_TS_2 | TIM_SMCR_TS_0) /*!< Filtered Timer Input 1 (TI1FP1) is used as trigger input */
  816. #define LL_TIM_TS_TI2FP2 (TIM_SMCR_TS_2 | TIM_SMCR_TS_1) /*!< Filtered Timer Input 2 (TI12P2) is used as trigger input */
  817. #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 */
  818. /**
  819. * @}
  820. */
  821. /** @defgroup TIM_LL_EC_ETR_POLARITY External Trigger Polarity
  822. * @{
  823. */
  824. #define LL_TIM_ETR_POLARITY_NONINVERTED 0x00000000U /*!< ETR is non-inverted, active at high level or rising edge */
  825. #define LL_TIM_ETR_POLARITY_INVERTED TIM_SMCR_ETP /*!< ETR is inverted, active at low level or falling edge */
  826. /**
  827. * @}
  828. */
  829. /** @defgroup TIM_LL_EC_ETR_PRESCALER External Trigger Prescaler
  830. * @{
  831. */
  832. #define LL_TIM_ETR_PRESCALER_DIV1 0x00000000U /*!< ETR prescaler OFF */
  833. #define LL_TIM_ETR_PRESCALER_DIV2 TIM_SMCR_ETPS_0 /*!< ETR frequency is divided by 2 */
  834. #define LL_TIM_ETR_PRESCALER_DIV4 TIM_SMCR_ETPS_1 /*!< ETR frequency is divided by 4 */
  835. #define LL_TIM_ETR_PRESCALER_DIV8 TIM_SMCR_ETPS /*!< ETR frequency is divided by 8 */
  836. /**
  837. * @}
  838. */
  839. /** @defgroup TIM_LL_EC_ETR_FILTER External Trigger Filter
  840. * @{
  841. */
  842. #define LL_TIM_ETR_FILTER_FDIV1 0x00000000U /*!< No filter, sampling is done at fDTS */
  843. #define LL_TIM_ETR_FILTER_FDIV1_N2 TIM_SMCR_ETF_0 /*!< fSAMPLING=fCK_INT, N=2 */
  844. #define LL_TIM_ETR_FILTER_FDIV1_N4 TIM_SMCR_ETF_1 /*!< fSAMPLING=fCK_INT, N=4 */
  845. #define LL_TIM_ETR_FILTER_FDIV1_N8 (TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fCK_INT, N=8 */
  846. #define LL_TIM_ETR_FILTER_FDIV2_N6 TIM_SMCR_ETF_2 /*!< fSAMPLING=fDTS/2, N=6 */
  847. #define LL_TIM_ETR_FILTER_FDIV2_N8 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/2, N=8 */
  848. #define LL_TIM_ETR_FILTER_FDIV4_N6 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/4, N=6 */
  849. #define LL_TIM_ETR_FILTER_FDIV4_N8 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/4, N=8 */
  850. #define LL_TIM_ETR_FILTER_FDIV8_N6 TIM_SMCR_ETF_3 /*!< fSAMPLING=fDTS/8, N=6 */
  851. #define LL_TIM_ETR_FILTER_FDIV8_N8 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/16, N=8 */
  852. #define LL_TIM_ETR_FILTER_FDIV16_N5 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/16, N=5 */
  853. #define LL_TIM_ETR_FILTER_FDIV16_N6 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/16, N=6 */
  854. #define LL_TIM_ETR_FILTER_FDIV16_N8 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2) /*!< fSAMPLING=fDTS/16, N=8 */
  855. #define LL_TIM_ETR_FILTER_FDIV32_N5 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/32, N=5 */
  856. #define LL_TIM_ETR_FILTER_FDIV32_N6 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/32, N=6 */
  857. #define LL_TIM_ETR_FILTER_FDIV32_N8 TIM_SMCR_ETF /*!< fSAMPLING=fDTS/32, N=8 */
  858. /**
  859. * @}
  860. */
  861. /** @defgroup TIM_LL_EC_TIM1_ETRSOURCE External Trigger Source TIM1
  862. * @{
  863. */
  864. #define LL_TIM_TIM1_ETRSOURCE_GPIO 0x00000000U /*!< ETR input is connected to GPIO */
  865. #define LL_TIM_TIM1_ETRSOURCE_COMP1 TIM1_AF1_ETRSEL_0 /*!< ETR input is connected to COMP1_OUT */
  866. #define LL_TIM_TIM1_ETRSOURCE_COMP2 TIM1_AF1_ETRSEL_1 /*!< ETR input is connected to COMP2_OUT */
  867. #define LL_TIM_TIM1_ETRSOURCE_COMP3 (TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP3_OUT */
  868. #define LL_TIM_TIM1_ETRSOURCE_COMP4 TIM1_AF1_ETRSEL_2 /*!< ETR input is connected to COMP4_OUT */
  869. #if defined(COMP5)
  870. #define LL_TIM_TIM1_ETRSOURCE_COMP5 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP5_OUT */
  871. #endif /* COMP5 */
  872. #if defined(COMP6)
  873. #define LL_TIM_TIM1_ETRSOURCE_COMP6 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1) /*!< ETR input is connected to COMP6_OUT */
  874. #endif /* COMP6 */
  875. #if defined(COMP7)
  876. #define LL_TIM_TIM1_ETRSOURCE_COMP7 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP7_OUT */
  877. #endif /* COMP7 */
  878. #define LL_TIM_TIM1_ETRSOURCE_ADC1_AWD1 TIM1_AF1_ETRSEL_3 /*!< ADC1 analog watchdog 1 */
  879. #define LL_TIM_TIM1_ETRSOURCE_ADC1_AWD2 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_0) /*!< ADC1 analog watchdog 2 */
  880. #define LL_TIM_TIM1_ETRSOURCE_ADC1_AWD3 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_1) /*!< ADC1 analog watchdog 3 */
  881. #if defined(ADC4)
  882. #define LL_TIM_TIM1_ETRSOURCE_ADC4_AWD1 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ADC4 analog watchdog 1 */
  883. #define LL_TIM_TIM1_ETRSOURCE_ADC4_AWD2 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_2) /*!< ADC4 analog watchdog 2 */
  884. #define LL_TIM_TIM1_ETRSOURCE_ADC4_AWD3 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< ADC4 analog watchdog 3 */
  885. #endif /* ADC4 */
  886. /**
  887. * @}
  888. */
  889. /** @defgroup TIM_LL_EC_TIM2_ETRSOURCE External Trigger Source TIM2
  890. * @{
  891. */
  892. #define LL_TIM_TIM2_ETRSOURCE_GPIO 0x00000000U /*!< ETR input is connected to GPIO */
  893. #define LL_TIM_TIM2_ETRSOURCE_COMP1 TIM1_AF1_ETRSEL_0 /*!< ETR input is connected to COMP1_OUT */
  894. #define LL_TIM_TIM2_ETRSOURCE_COMP2 TIM1_AF1_ETRSEL_1 /*!< ETR input is connected to COMP2_OUT */
  895. #define LL_TIM_TIM2_ETRSOURCE_COMP3 (TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP3_OUT */
  896. #define LL_TIM_TIM2_ETRSOURCE_COMP4 TIM1_AF1_ETRSEL_2 /*!< ETR input is connected to COMP4_OUT */
  897. #if defined(COMP5)
  898. #define LL_TIM_TIM2_ETRSOURCE_COMP5 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP5_OUT */
  899. #endif /* COMP5 */
  900. #if defined(COMP6)
  901. #define LL_TIM_TIM2_ETRSOURCE_COMP6 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1) /*!< ETR input is connected to COMP6_OUT */
  902. #endif /* COMP6 */
  903. #if defined(COMP7)
  904. #define LL_TIM_TIM2_ETRSOURCE_COMP7 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP7_OUT */
  905. #endif /* COMP7 */
  906. #define LL_TIM_TIM2_ETRSOURCE_TIM3_ETR TIM1_AF1_ETRSEL_3 /*!< ETR input is connected to TIM3 ETR */
  907. #define LL_TIM_TIM2_ETRSOURCE_TIM4_ETR (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to TIM4 ETR */
  908. #if defined(TIM5)
  909. #define LL_TIM_TIM2_ETRSOURCE_TIM5_ETR (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_1) /*!< ETR input is connected to TIM5 ETR */
  910. #endif /* TIM5 */
  911. #define LL_TIM_TIM2_ETRSOURCE_LSE (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to LSE */
  912. /**
  913. * @}
  914. */
  915. /** @defgroup TIM_LL_EC_TIM3_ETRSOURCE External Trigger Source TIM3
  916. * @{
  917. */
  918. #define LL_TIM_TIM3_ETRSOURCE_GPIO 0x00000000U /*!< ETR input is connected to GPIO */
  919. #define LL_TIM_TIM3_ETRSOURCE_COMP1 TIM1_AF1_ETRSEL_0 /*!< ETR input is connected to COMP1_OUT */
  920. #define LL_TIM_TIM3_ETRSOURCE_COMP2 TIM1_AF1_ETRSEL_1 /*!< ETR input is connected to COMP2_OUT */
  921. #define LL_TIM_TIM3_ETRSOURCE_COMP3 (TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP3_OUT */
  922. #define LL_TIM_TIM3_ETRSOURCE_COMP4 TIM1_AF1_ETRSEL_2 /*!< ETR input is connected to COMP4_OUT */
  923. #if defined(COMP5)
  924. #define LL_TIM_TIM3_ETRSOURCE_COMP5 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP5_OUT */
  925. #endif /* COMP5 */
  926. #if defined(COMP6)
  927. #define LL_TIM_TIM3_ETRSOURCE_COMP6 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1) /*!< ETR input is connected to COMP6_OUT */
  928. #endif /* COMP6 */
  929. #if defined(COMP7)
  930. #define LL_TIM_TIM3_ETRSOURCE_COMP7 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP7_OUT */
  931. #endif /* COMP7 */
  932. #define LL_TIM_TIM3_ETRSOURCE_TIM2_ETR TIM1_AF1_ETRSEL_3 /*!< ETR input is connected to TIM2 ETR */
  933. #define LL_TIM_TIM3_ETRSOURCE_TIM4_ETR (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to TIM4 ETR */
  934. #define LL_TIM_TIM3_ETRSOURCE_ADC2_AWD1 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ADC2 analog watchdog 1 */
  935. #define LL_TIM_TIM3_ETRSOURCE_ADC2_AWD2 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_2) /*!< ADC2 analog watchdog 2 */
  936. #define LL_TIM_TIM3_ETRSOURCE_ADC2_AWD3 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< ADC2 analog watchdog 3 */
  937. /**
  938. * @}
  939. */
  940. /** @defgroup TIM_LL_EC_TIM4_ETRSOURCE External Trigger Source TIM4
  941. * @{
  942. */
  943. #define LL_TIM_TIM4_ETRSOURCE_GPIO 0x00000000U /*!< ETR input is connected to GPIO */
  944. #define LL_TIM_TIM4_ETRSOURCE_COMP1 TIM1_AF1_ETRSEL_0 /*!< ETR input is connected to COMP1_OUT */
  945. #define LL_TIM_TIM4_ETRSOURCE_COMP2 TIM1_AF1_ETRSEL_1 /*!< ETR input is connected to COMP2_OUT */
  946. #define LL_TIM_TIM4_ETRSOURCE_COMP3 (TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP3_OUT */
  947. #define LL_TIM_TIM4_ETRSOURCE_COMP4 TIM1_AF1_ETRSEL_2 /*!< ETR input is connected to COMP4_OUT */
  948. #if defined(COMP5)
  949. #define LL_TIM_TIM4_ETRSOURCE_COMP5 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP5_OUT */
  950. #endif /* COMP5 */
  951. #if defined(COMP6)
  952. #define LL_TIM_TIM4_ETRSOURCE_COMP6 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1) /*!< ETR input is connected to COMP6_OUT */
  953. #endif /* COMP6 */
  954. #if defined(COMP7)
  955. #define LL_TIM_TIM4_ETRSOURCE_COMP7 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP7_OUT */
  956. #endif /* COMP7 */
  957. #define LL_TIM_TIM4_ETRSOURCE_TIM3_ETR TIM1_AF1_ETRSEL_3 /*!< ETR input is connected to TIM3 ETR */
  958. #if defined(TIM5)
  959. #define LL_TIM_TIM4_ETRSOURCE_TIM5_ETR (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to TIM5 ETR */
  960. #endif /* TIM5 */
  961. /**
  962. * @}
  963. */
  964. #if defined(TIM5)
  965. /** @defgroup TIM_LL_EC_TIM5_ETRSOURCE External Trigger Source TIM5
  966. * @{
  967. */
  968. #define LL_TIM_TIM5_ETRSOURCE_GPIO 0x00000000U /*!< ETR input is connected to GPIO */
  969. #define LL_TIM_TIM5_ETRSOURCE_COMP1 TIM1_AF1_ETRSEL_0 /*!< ETR input is connected to COMP1_OUT */
  970. #define LL_TIM_TIM5_ETRSOURCE_COMP2 TIM1_AF1_ETRSEL_1 /*!< ETR input is connected to COMP2_OUT */
  971. #define LL_TIM_TIM5_ETRSOURCE_COMP3 (TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP3_OUT */
  972. #define LL_TIM_TIM5_ETRSOURCE_COMP4 TIM1_AF1_ETRSEL_2 /*!< ETR input is connected to COMP4_OUT */
  973. #if defined(COMP5)
  974. #define LL_TIM_TIM5_ETRSOURCE_COMP5 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP5_OUT */
  975. #endif /* COMP5 */
  976. #if defined(COMP6)
  977. #define LL_TIM_TIM5_ETRSOURCE_COMP6 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1) /*!< ETR input is connected to COMP6_OUT */
  978. #endif /* COMP6 */
  979. #if defined(COMP7)
  980. #define LL_TIM_TIM5_ETRSOURCE_COMP7 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP7_OUT */
  981. #endif /* COMP7 */
  982. #define LL_TIM_TIM5_ETRSOURCE_TIM2_ETR TIM1_AF1_ETRSEL_3 /*!< ETR input is connected to TIM2 ETR */
  983. #define LL_TIM_TIM5_ETRSOURCE_TIM3_ETR (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to TIM3 ETR */
  984. /**
  985. * @}
  986. */
  987. #endif /* TIM5 */
  988. /** @defgroup TIM_LL_EC_TIM8_ETRSOURCE External Trigger Source TIM8
  989. * @{
  990. */
  991. #define LL_TIM_TIM8_ETRSOURCE_GPIO 0x00000000U /*!< ETR input is connected to GPIO */
  992. #define LL_TIM_TIM8_ETRSOURCE_COMP1 TIM1_AF1_ETRSEL_0 /*!< ETR input is connected to COMP1_OUT */
  993. #define LL_TIM_TIM8_ETRSOURCE_COMP2 TIM1_AF1_ETRSEL_1 /*!< ETR input is connected to COMP2_OUT */
  994. #define LL_TIM_TIM8_ETRSOURCE_COMP3 (TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP3_OUT */
  995. #define LL_TIM_TIM8_ETRSOURCE_COMP4 TIM1_AF1_ETRSEL_2 /*!< ETR input is connected to COMP4_OUT */
  996. #if defined(COMP5)
  997. #define LL_TIM_TIM8_ETRSOURCE_COMP5 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP5_OUT */
  998. #endif /* COMP5 */
  999. #if defined(COMP6)
  1000. #define LL_TIM_TIM8_ETRSOURCE_COMP6 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1) /*!< ETR input is connected to COMP6_OUT */
  1001. #endif /* COMP6 */
  1002. #if defined(COMP7)
  1003. #define LL_TIM_TIM8_ETRSOURCE_COMP7 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP7_OUT */
  1004. #endif /* COMP7 */
  1005. #define LL_TIM_TIM8_ETRSOURCE_ADC2_AWD1 TIM1_AF1_ETRSEL_3 /*!< ADC2 analog watchdog 1 */
  1006. #define LL_TIM_TIM8_ETRSOURCE_ADC2_AWD2 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_0) /*!< ADC2 analog watchdog 2 */
  1007. #define LL_TIM_TIM8_ETRSOURCE_ADC2_AWD3 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_1) /*!< ADC2 analog watchdog 3 */
  1008. #if defined(ADC3)
  1009. #define LL_TIM_TIM8_ETRSOURCE_ADC3_AWD1 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ADC3 analog watchdog 1 */
  1010. #define LL_TIM_TIM8_ETRSOURCE_ADC3_AWD2 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_2) /*!< ADC3 analog watchdog 2 */
  1011. #define LL_TIM_TIM8_ETRSOURCE_ADC3_AWD3 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< ADC3 analog watchdog 3 */
  1012. #endif /* ADC3 */
  1013. /**
  1014. * @}
  1015. */
  1016. #if defined(TIM20)
  1017. /** @defgroup TIM_LL_EC_TIM20_ETRSOURCE External Trigger Source TIM20
  1018. * @{
  1019. */
  1020. #define LL_TIM_TIM20_ETRSOURCE_GPIO 0x00000000U /*!< ETR input is connected to GPIO */
  1021. #define LL_TIM_TIM20_ETRSOURCE_COMP1 TIM1_AF1_ETRSEL_0 /*!< ETR input is connected to COMP1_OUT */
  1022. #define LL_TIM_TIM20_ETRSOURCE_COMP2 TIM1_AF1_ETRSEL_1 /*!< ETR input is connected to COMP2_OUT */
  1023. #define LL_TIM_TIM20_ETRSOURCE_COMP3 (TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP3_OUT */
  1024. #define LL_TIM_TIM20_ETRSOURCE_COMP4 TIM1_AF1_ETRSEL_2 /*!< ETR input is connected to COMP4_OUT */
  1025. #if defined(COMP5)
  1026. #define LL_TIM_TIM20_ETRSOURCE_COMP5 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP5_OUT */
  1027. #endif /* COMP5 */
  1028. #if defined(COMP6)
  1029. #define LL_TIM_TIM20_ETRSOURCE_COMP6 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1) /*!< ETR input is connected to COMP6_OUT */
  1030. #endif /* COMP6 */
  1031. #if defined(COMP7)
  1032. #define LL_TIM_TIM20_ETRSOURCE_COMP7 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ETR input is connected to COMP7_OUT */
  1033. #endif /* COMP7 */
  1034. #if defined(ADC3)
  1035. #define LL_TIM_TIM20_ETRSOURCE_ADC3_AWD1 TIM1_AF1_ETRSEL_3 /*!< ADC3 analog watchdog 1 */
  1036. #define LL_TIM_TIM20_ETRSOURCE_ADC3_AWD2 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_0) /*!< ADC3 analog watchdog 2 */
  1037. #define LL_TIM_TIM20_ETRSOURCE_ADC3_AWD3 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_1) /*!< ADC3 analog watchdog 3 */
  1038. #endif /* ADC3 */
  1039. #if defined(ADC5)
  1040. #define LL_TIM_TIM20_ETRSOURCE_ADC5_AWD1 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< ADC5 analog watchdog 1 */
  1041. #define LL_TIM_TIM20_ETRSOURCE_ADC5_AWD2 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_2) /*!< ADC5 analog watchdog 2 */
  1042. #define LL_TIM_TIM20_ETRSOURCE_ADC5_AWD3 (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< ADC5 analog watchdog 3 */
  1043. #endif /* ADC5 */
  1044. /**
  1045. * @}
  1046. */
  1047. #endif /* TIM20 */
  1048. /** @defgroup TIM_LL_EC_BREAK_POLARITY break polarity
  1049. * @{
  1050. */
  1051. #define LL_TIM_BREAK_POLARITY_LOW 0x00000000U /*!< Break input BRK is active low */
  1052. #define LL_TIM_BREAK_POLARITY_HIGH TIM_BDTR_BKP /*!< Break input BRK is active high */
  1053. /**
  1054. * @}
  1055. */
  1056. /** @defgroup TIM_LL_EC_BREAK_FILTER break filter
  1057. * @{
  1058. */
  1059. #define LL_TIM_BREAK_FILTER_FDIV1 0x00000000U /*!< No filter, BRK acts asynchronously */
  1060. #define LL_TIM_BREAK_FILTER_FDIV1_N2 0x00010000U /*!< fSAMPLING=fCK_INT, N=2 */
  1061. #define LL_TIM_BREAK_FILTER_FDIV1_N4 0x00020000U /*!< fSAMPLING=fCK_INT, N=4 */
  1062. #define LL_TIM_BREAK_FILTER_FDIV1_N8 0x00030000U /*!< fSAMPLING=fCK_INT, N=8 */
  1063. #define LL_TIM_BREAK_FILTER_FDIV2_N6 0x00040000U /*!< fSAMPLING=fDTS/2, N=6 */
  1064. #define LL_TIM_BREAK_FILTER_FDIV2_N8 0x00050000U /*!< fSAMPLING=fDTS/2, N=8 */
  1065. #define LL_TIM_BREAK_FILTER_FDIV4_N6 0x00060000U /*!< fSAMPLING=fDTS/4, N=6 */
  1066. #define LL_TIM_BREAK_FILTER_FDIV4_N8 0x00070000U /*!< fSAMPLING=fDTS/4, N=8 */
  1067. #define LL_TIM_BREAK_FILTER_FDIV8_N6 0x00080000U /*!< fSAMPLING=fDTS/8, N=6 */
  1068. #define LL_TIM_BREAK_FILTER_FDIV8_N8 0x00090000U /*!< fSAMPLING=fDTS/8, N=8 */
  1069. #define LL_TIM_BREAK_FILTER_FDIV16_N5 0x000A0000U /*!< fSAMPLING=fDTS/16, N=5 */
  1070. #define LL_TIM_BREAK_FILTER_FDIV16_N6 0x000B0000U /*!< fSAMPLING=fDTS/16, N=6 */
  1071. #define LL_TIM_BREAK_FILTER_FDIV16_N8 0x000C0000U /*!< fSAMPLING=fDTS/16, N=8 */
  1072. #define LL_TIM_BREAK_FILTER_FDIV32_N5 0x000D0000U /*!< fSAMPLING=fDTS/32, N=5 */
  1073. #define LL_TIM_BREAK_FILTER_FDIV32_N6 0x000E0000U /*!< fSAMPLING=fDTS/32, N=6 */
  1074. #define LL_TIM_BREAK_FILTER_FDIV32_N8 0x000F0000U /*!< fSAMPLING=fDTS/32, N=8 */
  1075. /**
  1076. * @}
  1077. */
  1078. /** @defgroup TIM_LL_EC_BREAK2_POLARITY BREAK2 POLARITY
  1079. * @{
  1080. */
  1081. #define LL_TIM_BREAK2_POLARITY_LOW 0x00000000U /*!< Break input BRK2 is active low */
  1082. #define LL_TIM_BREAK2_POLARITY_HIGH TIM_BDTR_BK2P /*!< Break input BRK2 is active high */
  1083. /**
  1084. * @}
  1085. */
  1086. /** @defgroup TIM_LL_EC_BREAK2_FILTER BREAK2 FILTER
  1087. * @{
  1088. */
  1089. #define LL_TIM_BREAK2_FILTER_FDIV1 0x00000000U /*!< No filter, BRK acts asynchronously */
  1090. #define LL_TIM_BREAK2_FILTER_FDIV1_N2 0x00100000U /*!< fSAMPLING=fCK_INT, N=2 */
  1091. #define LL_TIM_BREAK2_FILTER_FDIV1_N4 0x00200000U /*!< fSAMPLING=fCK_INT, N=4 */
  1092. #define LL_TIM_BREAK2_FILTER_FDIV1_N8 0x00300000U /*!< fSAMPLING=fCK_INT, N=8 */
  1093. #define LL_TIM_BREAK2_FILTER_FDIV2_N6 0x00400000U /*!< fSAMPLING=fDTS/2, N=6 */
  1094. #define LL_TIM_BREAK2_FILTER_FDIV2_N8 0x00500000U /*!< fSAMPLING=fDTS/2, N=8 */
  1095. #define LL_TIM_BREAK2_FILTER_FDIV4_N6 0x00600000U /*!< fSAMPLING=fDTS/4, N=6 */
  1096. #define LL_TIM_BREAK2_FILTER_FDIV4_N8 0x00700000U /*!< fSAMPLING=fDTS/4, N=8 */
  1097. #define LL_TIM_BREAK2_FILTER_FDIV8_N6 0x00800000U /*!< fSAMPLING=fDTS/8, N=6 */
  1098. #define LL_TIM_BREAK2_FILTER_FDIV8_N8 0x00900000U /*!< fSAMPLING=fDTS/8, N=8 */
  1099. #define LL_TIM_BREAK2_FILTER_FDIV16_N5 0x00A00000U /*!< fSAMPLING=fDTS/16, N=5 */
  1100. #define LL_TIM_BREAK2_FILTER_FDIV16_N6 0x00B00000U /*!< fSAMPLING=fDTS/16, N=6 */
  1101. #define LL_TIM_BREAK2_FILTER_FDIV16_N8 0x00C00000U /*!< fSAMPLING=fDTS/16, N=8 */
  1102. #define LL_TIM_BREAK2_FILTER_FDIV32_N5 0x00D00000U /*!< fSAMPLING=fDTS/32, N=5 */
  1103. #define LL_TIM_BREAK2_FILTER_FDIV32_N6 0x00E00000U /*!< fSAMPLING=fDTS/32, N=6 */
  1104. #define LL_TIM_BREAK2_FILTER_FDIV32_N8 0x00F00000U /*!< fSAMPLING=fDTS/32, N=8 */
  1105. /**
  1106. * @}
  1107. */
  1108. /** @defgroup TIM_LL_EC_OSSI OSSI
  1109. * @{
  1110. */
  1111. #define LL_TIM_OSSI_DISABLE 0x00000000U /*!< When inactive, OCx/OCxN outputs are disabled */
  1112. #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 */
  1113. /**
  1114. * @}
  1115. */
  1116. /** @defgroup TIM_LL_EC_OSSR OSSR
  1117. * @{
  1118. */
  1119. #define LL_TIM_OSSR_DISABLE 0x00000000U /*!< When inactive, OCx/OCxN outputs are disabled */
  1120. #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 */
  1121. /**
  1122. * @}
  1123. */
  1124. /** @defgroup TIM_LL_EC_BREAK_INPUT BREAK INPUT
  1125. * @{
  1126. */
  1127. #define LL_TIM_BREAK_INPUT_BKIN 0x00000000U /*!< TIMx_BKIN input */
  1128. #define LL_TIM_BREAK_INPUT_BKIN2 0x00000004U /*!< TIMx_BKIN2 input */
  1129. /**
  1130. * @}
  1131. */
  1132. /** @defgroup TIM_LL_EC_BKIN_SOURCE BKIN SOURCE
  1133. * @{
  1134. */
  1135. #define LL_TIM_BKIN_SOURCE_BKIN TIM1_AF1_BKINE /*!< BKIN input from AF controller */
  1136. #define LL_TIM_BKIN_SOURCE_BKCOMP1 TIM1_AF1_BKCMP1E /*!< internal signal: COMP1 output */
  1137. #define LL_TIM_BKIN_SOURCE_BKCOMP2 TIM1_AF1_BKCMP2E /*!< internal signal: COMP2 output */
  1138. #define LL_TIM_BKIN_SOURCE_BKCOMP3 TIM1_AF1_BKCMP3E /*!< internal signal: COMP3 output */
  1139. #define LL_TIM_BKIN_SOURCE_BKCOMP4 TIM1_AF1_BKCMP4E /*!< internal signal: COMP4 output */
  1140. #if defined(COMP5)
  1141. #define LL_TIM_BKIN_SOURCE_BKCOMP5 TIM1_AF1_BKCMP5E /*!< internal signal: COMP5 output */
  1142. #endif /* COMP5 */
  1143. #if defined(COMP6)
  1144. #define LL_TIM_BKIN_SOURCE_BKCOMP6 TIM1_AF1_BKCMP6E /*!< internal signal: COMP6 output */
  1145. #endif /* COMP6 */
  1146. #if defined(COMP7)
  1147. #define LL_TIM_BKIN_SOURCE_BKCOMP7 TIM1_AF1_BKCMP7E /*!< internal signal: COMP7 output */
  1148. #endif /* COMP7 */
  1149. /**
  1150. * @}
  1151. */
  1152. /** @defgroup TIM_LL_EC_BKIN_POLARITY BKIN POLARITY
  1153. * @{
  1154. */
  1155. #define LL_TIM_BKIN_POLARITY_LOW TIM1_AF1_BKINP /*!< BRK BKIN input is active low */
  1156. #define LL_TIM_BKIN_POLARITY_HIGH 0x00000000U /*!< BRK BKIN input is active high */
  1157. /**
  1158. * @}
  1159. */
  1160. /** @defgroup TIM_LL_EC_BREAK_AFMODE BREAK AF MODE
  1161. * @{
  1162. */
  1163. #define LL_TIM_BREAK_AFMODE_INPUT 0x00000000U /*!< Break input BRK in input mode */
  1164. #define LL_TIM_BREAK_AFMODE_BIDIRECTIONAL TIM_BDTR_BKBID /*!< Break input BRK in bidirectional mode */
  1165. /**
  1166. * @}
  1167. */
  1168. /** @defgroup TIM_LL_EC_BREAK2_AFMODE BREAK2 AF MODE
  1169. * @{
  1170. */
  1171. #define LL_TIM_BREAK2_AFMODE_INPUT 0x00000000U /*!< Break2 input BRK2 in input mode */
  1172. #define LL_TIM_BREAK2_AFMODE_BIDIRECTIONAL TIM_BDTR_BK2BID /*!< Break2 input BRK2 in bidirectional mode */
  1173. /**
  1174. * @}
  1175. */
  1176. /** Legacy definitions for compatibility purpose
  1177. @cond 0
  1178. */
  1179. #define LL_TIM_ReArmBRK(_PARAM_)
  1180. #define LL_TIM_ReArmBRK2(_PARAM_)
  1181. /**
  1182. @endcond
  1183. */
  1184. /** @defgroup TIM_LL_EC_DMABURST_BASEADDR DMA Burst Base Address
  1185. * @{
  1186. */
  1187. #define LL_TIM_DMABURST_BASEADDR_CR1 0x00000000U /*!< TIMx_CR1 register is the DMA base address for DMA burst */
  1188. #define LL_TIM_DMABURST_BASEADDR_CR2 TIM_DCR_DBA_0 /*!< TIMx_CR2 register is the DMA base address for DMA burst */
  1189. #define LL_TIM_DMABURST_BASEADDR_SMCR TIM_DCR_DBA_1 /*!< TIMx_SMCR register is the DMA base address for DMA burst */
  1190. #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 */
  1191. #define LL_TIM_DMABURST_BASEADDR_SR TIM_DCR_DBA_2 /*!< TIMx_SR register is the DMA base address for DMA burst */
  1192. #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 */
  1193. #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 */
  1194. #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 */
  1195. #define LL_TIM_DMABURST_BASEADDR_CCER TIM_DCR_DBA_3 /*!< TIMx_CCER register is the DMA base address for DMA burst */
  1196. #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 */
  1197. #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 */
  1198. #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 */
  1199. #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 */
  1200. #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 */
  1201. #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 */
  1202. #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 */
  1203. #define LL_TIM_DMABURST_BASEADDR_CCR4 TIM_DCR_DBA_4 /*!< TIMx_CCR4 register is the DMA base address for DMA burst */
  1204. #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 */
  1205. #define LL_TIM_DMABURST_BASEADDR_CCR5 (TIM_DCR_DBA_4 | TIM_DCR_DBA_1) /*!< TIMx_CCR5 register is the DMA base address for DMA burst */
  1206. #define LL_TIM_DMABURST_BASEADDR_CCR6 (TIM_DCR_DBA_4 | TIM_DCR_DBA_1 | TIM_DCR_DBA_0) /*!< TIMx_CCR6 register is the DMA base address for DMA burst */
  1207. #define LL_TIM_DMABURST_BASEADDR_CCMR3 (TIM_DCR_DBA_4 | TIM_DCR_DBA_2) /*!< TIMx_CCMR3 register is the DMA base address for DMA burst */
  1208. #define LL_TIM_DMABURST_BASEADDR_DTR2 (TIM_DCR_DBA_4 | TIM_DCR_DBA_2 | TIM_DCR_DBA_0) /*!< TIMx_DTR2 register is the DMA base address for DMA burst */
  1209. #define LL_TIM_DMABURST_BASEADDR_ECR (TIM_DCR_DBA_4 | TIM_DCR_DBA_2 | TIM_DCR_DBA_1) /*!< TIMx_ECR register is the DMA base address for DMA burst */
  1210. #define LL_TIM_DMABURST_BASEADDR_TISEL (TIM_DCR_DBA_4 | TIM_DCR_DBA_2 | TIM_DCR_DBA_1 | TIM_DCR_DBA_0) /*!< TIMx_TISEL register is the DMA base address for DMA burst */
  1211. #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 */
  1212. #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 */
  1213. #define LL_TIM_DMABURST_BASEADDR_OR (TIM_DCR_DBA_4 | TIM_DCR_DBA_3 | TIM_DCR_DBA_1) /*!< TIMx_OR register is the DMA base address for DMA burst */
  1214. /**
  1215. * @}
  1216. */
  1217. /** @defgroup TIM_LL_EC_DMABURST_LENGTH DMA Burst Length
  1218. * @{
  1219. */
  1220. #define LL_TIM_DMABURST_LENGTH_1TRANSFER 0x00000000U /*!< Transfer is done to 1 register starting from the DMA burst base address */
  1221. #define LL_TIM_DMABURST_LENGTH_2TRANSFERS TIM_DCR_DBL_0 /*!< Transfer is done to 2 registers starting from the DMA burst base address */
  1222. #define LL_TIM_DMABURST_LENGTH_3TRANSFERS TIM_DCR_DBL_1 /*!< Transfer is done to 3 registers starting from the DMA burst base address */
  1223. #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 */
  1224. #define LL_TIM_DMABURST_LENGTH_5TRANSFERS TIM_DCR_DBL_2 /*!< Transfer is done to 5 registers starting from the DMA burst base address */
  1225. #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 */
  1226. #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 */
  1227. #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 */
  1228. #define LL_TIM_DMABURST_LENGTH_9TRANSFERS TIM_DCR_DBL_3 /*!< Transfer is done to 9 registers starting from the DMA burst base address */
  1229. #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 */
  1230. #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 */
  1231. #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 */
  1232. #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 */
  1233. #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 */
  1234. #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 */
  1235. #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 */
  1236. #define LL_TIM_DMABURST_LENGTH_17TRANSFERS TIM_DCR_DBL_4 /*!< Transfer is done to 17 registers starting from the DMA burst base address */
  1237. #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 */
  1238. #define LL_TIM_DMABURST_LENGTH_19TRANSFERS (TIM_DCR_DBL_4 | TIM_DCR_DBL_1) /*!< Transfer is done to 19 registers starting from the DMA burst base address */
  1239. #define LL_TIM_DMABURST_LENGTH_20TRANSFERS (TIM_DCR_DBL_4 | TIM_DCR_DBL_1 | TIM_DCR_DBL_0) /*!< Transfer is done to 20 registers starting from the DMA burst base address */
  1240. #define LL_TIM_DMABURST_LENGTH_21TRANSFERS (TIM_DCR_DBL_4 | TIM_DCR_DBL_2) /*!< Transfer is done to 21 registers starting from the DMA burst base address */
  1241. #define LL_TIM_DMABURST_LENGTH_22TRANSFERS (TIM_DCR_DBL_4 | TIM_DCR_DBL_2 | TIM_DCR_DBL_0) /*!< Transfer is done to 22 registers starting from the DMA burst base address */
  1242. #define LL_TIM_DMABURST_LENGTH_23TRANSFERS (TIM_DCR_DBL_4 | TIM_DCR_DBL_2 | TIM_DCR_DBL_1) /*!< Transfer is done to 23 registers starting from the DMA burst base address */
  1243. #define LL_TIM_DMABURST_LENGTH_24TRANSFERS (TIM_DCR_DBL_4 | TIM_DCR_DBL_2 | TIM_DCR_DBL_1 | TIM_DCR_DBL_0) /*!< Transfer is done to 24 registers starting from the DMA burst base address */
  1244. #define LL_TIM_DMABURST_LENGTH_25TRANSFERS (TIM_DCR_DBL_4 | TIM_DCR_DBL_3) /*!< Transfer is done to 25 registers starting from the DMA burst base address */
  1245. #define LL_TIM_DMABURST_LENGTH_26TRANSFERS (TIM_DCR_DBL_4 | TIM_DCR_DBL_3 | TIM_DCR_DBL_0) /*!< Transfer is done to 26 registers starting from the DMA burst base address */
  1246. /**
  1247. * @}
  1248. */
  1249. /** @defgroup TIM_LL_EC_TIM1_TI1_RMP TIM1 Timer Input Ch1 Remap
  1250. * @{
  1251. */
  1252. #define LL_TIM_TIM1_TI1_RMP_GPIO 0x00000000U /*!< TIM1 input 1 is connected to GPIO */
  1253. #define LL_TIM_TIM1_TI1_RMP_COMP1 TIM_TISEL_TI1SEL_0 /*!< TIM1 input 1 is connected to COMP1_OUT */
  1254. #define LL_TIM_TIM1_TI1_RMP_COMP2 TIM_TISEL_TI1SEL_1 /*!< TIM1 input 1 is connected to COMP2_OUT */
  1255. #define LL_TIM_TIM1_TI1_RMP_COMP3 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM1 input 1 is connected to COMP3_OUT */
  1256. #define LL_TIM_TIM1_TI1_RMP_COMP4 TIM_TISEL_TI1SEL_2 /*!< TIM1 input 1 is connected to COMP4_OUT */
  1257. /**
  1258. * @}
  1259. */
  1260. /** @defgroup TIM_LL_EC_TIM2_TI1_RMP TIM2 Timer Input Ch1 Remap
  1261. * @{
  1262. */
  1263. #define LL_TIM_TIM2_TI1_RMP_GPIO 0x00000000U /*!< TIM2 input 1 is connected to GPIO */
  1264. #define LL_TIM_TIM2_TI1_RMP_COMP1 TIM_TISEL_TI1SEL_0 /*!< TIM2 input 1 is connected to COMP1_OUT */
  1265. #define LL_TIM_TIM2_TI1_RMP_COMP2 TIM_TISEL_TI1SEL_1 /*!< TIM2 input 1 is connected to COMP2_OUT */
  1266. #define LL_TIM_TIM2_TI1_RMP_COMP3 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM2 input 1 is connected to COMP3_OUT */
  1267. #define LL_TIM_TIM2_TI1_RMP_COMP4 TIM_TISEL_TI1SEL_2 /*!< TIM2 input 1 is connected to COMP4_OUT */
  1268. #if defined(COMP5)
  1269. #define LL_TIM_TIM2_TI1_RMP_COMP5 (TIM_TISEL_TI1SEL_2 | TIM_TISEL_TI1SEL_0) /*!< TIM2 input 1 is connected to COMP5_OUT */
  1270. #endif /* COMP5 */
  1271. /**
  1272. * @}
  1273. */
  1274. /** @defgroup TIM_LL_EC_TIM2_TI2_RMP TIM2 Timer Input Ch2 Remap
  1275. * @{
  1276. */
  1277. #define LL_TIM_TIM2_TI2_RMP_GPIO 0x00000000U /*!< TIM2 input 2 is connected to GPIO */
  1278. #define LL_TIM_TIM2_TI2_RMP_COMP1 TIM_TISEL_TI2SEL_0 /*!< TIM2 input 2 is connected to COMP1_OUT */
  1279. #define LL_TIM_TIM2_TI2_RMP_COMP2 TIM_TISEL_TI2SEL_1 /*!< TIM2 input 2 is connected to COMP2_OUT */
  1280. #define LL_TIM_TIM2_TI2_RMP_COMP3 (TIM_TISEL_TI2SEL_1 | TIM_TISEL_TI2SEL_0) /*!< TIM2 input 2 is connected to COMP3_OUT */
  1281. #define LL_TIM_TIM2_TI2_RMP_COMP4 TIM_TISEL_TI2SEL_2 /*!< TIM2 input 2 is connected to COMP4_OUT */
  1282. #if defined(COMP6)
  1283. #define LL_TIM_TIM2_TI2_RMP_COMP6 (TIM_TISEL_TI2SEL_2 | TIM_TISEL_TI2SEL_0) /*!< TIM2 input 2 is connected to COMP6_OUT */
  1284. #endif /* COMP6 */
  1285. /**
  1286. * @}
  1287. */
  1288. /** @defgroup TIM_LL_EC_TIM2_TI3_RMP TIM2 Timer Input Ch3 Remap
  1289. * @{
  1290. */
  1291. #define LL_TIM_TIM2_TI3_RMP_GPIO 0x00000000U /*!< TIM2 input 3 is connected to GPIO */
  1292. #define LL_TIM_TIM2_TI3_RMP_COMP4 TIM_TISEL_TI3SEL_0 /*!< TIM2 input 3 is connected to COMP4_OUT */
  1293. /**
  1294. * @}
  1295. */
  1296. /** @defgroup TIM_LL_EC_TIM2_TI4_RMP TIM2 Timer Input Ch4 Remap
  1297. * @{
  1298. */
  1299. #define LL_TIM_TIM2_TI4_RMP_GPIO 0x00000000U /*!< TIM2 input 4 is connected to GPIO */
  1300. #define LL_TIM_TIM2_TI4_RMP_COMP1 TIM_TISEL_TI4SEL_0 /*!< TIM2 input 4 is connected to COMP1_OUT */
  1301. #define LL_TIM_TIM2_TI4_RMP_COMP2 TIM_TISEL_TI4SEL_1 /*!< TIM2 input 4 is connected to COMP2_OUT */
  1302. /**
  1303. * @}
  1304. */
  1305. /** @defgroup TIM_LL_EC_TIM3_TI1_RMP TIM3 Timer Input Ch1 Remap
  1306. * @{
  1307. */
  1308. #define LL_TIM_TIM3_TI1_RMP_GPIO 0x00000000U /*!< TIM3 input 1 is connected to GPIO */
  1309. #define LL_TIM_TIM3_TI1_RMP_COMP1 TIM_TISEL_TI1SEL_0 /*!< TIM3 input 1 is connected to COMP1_OUT */
  1310. #define LL_TIM_TIM3_TI1_RMP_COMP2 TIM_TISEL_TI1SEL_1 /*!< TIM3 input 1 is connected to COMP2_OUT */
  1311. #define LL_TIM_TIM3_TI1_RMP_COMP3 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM3 input 1 is connected to COMP3_OUT */
  1312. #define LL_TIM_TIM3_TI1_RMP_COMP4 TIM_TISEL_TI1SEL_2 /*!< TIM3 input 1 is connected to COMP4_OUT */
  1313. #if defined(COMP5)
  1314. #define LL_TIM_TIM3_TI1_RMP_COMP5 (TIM_TISEL_TI1SEL_2 | TIM_TISEL_TI1SEL_0) /*!< TIM3 input 1 is connected to COMP5_OUT */
  1315. #endif /* COMP5 */
  1316. #if defined(COMP6)
  1317. #define LL_TIM_TIM3_TI1_RMP_COMP6 (TIM_TISEL_TI1SEL_2 | TIM_TISEL_TI1SEL_1) /*!< TIM3 input 1 is connected to COMP6_OUT */
  1318. #endif /* COMP6 */
  1319. #if defined(COMP7)
  1320. #define LL_TIM_TIM3_TI1_RMP_COMP7 (TIM_TISEL_TI1SEL_2 | TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM3 input 1 is connected to COMP7_OUT */
  1321. #endif /* COMP7 */
  1322. /**
  1323. * @}
  1324. */
  1325. /** @defgroup TIM_LL_EC_TIM3_TI2_RMP TIM3 Timer Input Ch2 Remap
  1326. * @{
  1327. */
  1328. #define LL_TIM_TIM3_TI2_RMP_GPIO 0x00000000U /*!< TIM3 input 2 is connected to GPIO */
  1329. #define LL_TIM_TIM3_TI2_RMP_COMP1 TIM_TISEL_TI2SEL_0 /*!< TIM3 input 2 is connected to COMP1_OUT */
  1330. #define LL_TIM_TIM3_TI2_RMP_COMP2 TIM_TISEL_TI2SEL_1 /*!< TIM3 input 2 is connected to COMP2_OUT */
  1331. #define LL_TIM_TIM3_TI2_RMP_COMP3 (TIM_TISEL_TI2SEL_1 | TIM_TISEL_TI2SEL_0) /*!< TIM3 input 2 is connected to COMP3_OUT */
  1332. #define LL_TIM_TIM3_TI2_RMP_COMP4 TIM_TISEL_TI2SEL_2 /*!< TIM3 input 2 is connected to COMP4_OUT */
  1333. #if defined(COMP5)
  1334. #define LL_TIM_TIM3_TI2_RMP_COMP5 (TIM_TISEL_TI2SEL_2 | TIM_TISEL_TI2SEL_0) /*!< TIM3 input 2 is connected to COMP5_OUT */
  1335. #endif /* COMP5 */
  1336. #if defined(COMP6)
  1337. #define LL_TIM_TIM3_TI2_RMP_COMP6 (TIM_TISEL_TI2SEL_2 | TIM_TISEL_TI2SEL_1) /*!< TIM3 input 2 is connected to COMP6_OUT */
  1338. #endif /* COMP6 */
  1339. #if defined(COMP7)
  1340. #define LL_TIM_TIM3_TI2_RMP_COMP7 (TIM_TISEL_TI2SEL_2 | TIM_TISEL_TI2SEL_1 | TIM_TISEL_TI2SEL_0) /*!< TIM3 input 2 is connected to COMP7_OUT */
  1341. #endif /* COMP7 */
  1342. /**
  1343. * @}
  1344. */
  1345. /** @defgroup TIM_LL_EC_TIM3_TI3_RMP TIM3 Timer Input Ch3 Remap
  1346. * @{
  1347. */
  1348. #define LL_TIM_TIM3_TI3_RMP_GPIO 0x00000000U /*!< TIM3 input 3 is connected to GPIO */
  1349. #define LL_TIM_TIM3_TI3_RMP_COMP3 TIM_TISEL_TI3SEL_0 /*!< TIM3 input 3 is connected to COMP3_OUT */
  1350. /**
  1351. * @}
  1352. */
  1353. /** @defgroup TIM_LL_EC_TIM4_TI1_RMP TIM4 Timer Input Ch1 Remap
  1354. * @{
  1355. */
  1356. #define LL_TIM_TIM4_TI1_RMP_GPIO 0x00000000U /*!< TIM4 input 1 is connected to GPIO */
  1357. #define LL_TIM_TIM4_TI1_RMP_COMP1 TIM_TISEL_TI1SEL_0 /*!< TIM4 input 1 is connected to COMP1_OUT */
  1358. #define LL_TIM_TIM4_TI1_RMP_COMP2 TIM_TISEL_TI1SEL_1 /*!< TIM4 input 1 is connected to COMP2_OUT */
  1359. #define LL_TIM_TIM4_TI1_RMP_COMP3 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM4 input 1 is connected to COMP3_OUT */
  1360. #define LL_TIM_TIM4_TI1_RMP_COMP4 TIM_TISEL_TI1SEL_2 /*!< TIM4 input 1 is connected to COMP4_OUT */
  1361. #if defined(COMP5)
  1362. #define LL_TIM_TIM4_TI1_RMP_COMP5 (TIM_TISEL_TI1SEL_2 | TIM_TISEL_TI1SEL_0) /*!< TIM4 input 1 is connected to COMP5_OUT */
  1363. #endif /* COMP5 */
  1364. #if defined(COMP6)
  1365. #define LL_TIM_TIM4_TI1_RMP_COMP6 (TIM_TISEL_TI1SEL_2 | TIM_TISEL_TI1SEL_1) /*!< TIM4 input 1 is connected to COMP6_OUT */
  1366. #endif /* COMP6 */
  1367. #if defined(COMP7)
  1368. #define LL_TIM_TIM4_TI1_RMP_COMP7 (TIM_TISEL_TI1SEL_2 | TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM4 input 1 is connected to COMP7_OUT */
  1369. #endif /* COMP7 */
  1370. /**
  1371. * @}
  1372. */
  1373. /** @defgroup TIM_LL_EC_TIM4_TI2_RMP TIM4 Timer Input Ch2 Remap
  1374. * @{
  1375. */
  1376. #define LL_TIM_TIM4_TI2_RMP_GPIO 0x00000000U /*!< TIM4 input 2 is connected to GPIO */
  1377. #define LL_TIM_TIM4_TI2_RMP_COMP1 TIM_TISEL_TI2SEL_0 /*!< TIM4 input 2 is connected to COMP1_OUT */
  1378. #define LL_TIM_TIM4_TI2_RMP_COMP2 TIM_TISEL_TI2SEL_1 /*!< TIM4 input 2 is connected to COMP2_OUT */
  1379. #define LL_TIM_TIM4_TI2_RMP_COMP3 (TIM_TISEL_TI2SEL_1 | TIM_TISEL_TI2SEL_0) /*!< TIM4 input 2 is connected to COMP3_OUT */
  1380. #define LL_TIM_TIM4_TI2_RMP_COMP4 TIM_TISEL_TI2SEL_2 /*!< TIM4 input 2 is connected to COMP4_OUT */
  1381. #if defined(COMP5)
  1382. #define LL_TIM_TIM4_TI2_RMP_COMP5 (TIM_TISEL_TI2SEL_2 | TIM_TISEL_TI2SEL_0) /*!< TIM4 input 2 is connected to COMP5_OUT */
  1383. #endif /* COMP5 */
  1384. #if defined(COMP6)
  1385. #define LL_TIM_TIM4_TI2_RMP_COMP6 (TIM_TISEL_TI2SEL_2 | TIM_TISEL_TI2SEL_1) /*!< TIM4 input 2 is connected to COMP6_OUT */
  1386. #endif /* COMP6 */
  1387. #if defined(COMP7)
  1388. #define LL_TIM_TIM4_TI2_RMP_COMP7 (TIM_TISEL_TI2SEL_2 | TIM_TISEL_TI2SEL_1 | TIM_TISEL_TI2SEL_0) /*!< TIM4 input 2 is connected to COMP7_OUT */
  1389. #endif /* COMP7 */
  1390. /**
  1391. * @}
  1392. */
  1393. /** @defgroup TIM_LL_EC_TIM4_TI3_RMP TIM4 Timer Input Ch3 Remap
  1394. * @{
  1395. */
  1396. #define LL_TIM_TIM4_TI3_RMP_GPIO 0x00000000U /*!< TIM4 input 3 is connected to GPIO */
  1397. #if defined(COMP5)
  1398. #define LL_TIM_TIM4_TI3_RMP_COMP5 TIM_TISEL_TI3SEL_0 /*!< TIM4 input 3 is connected to COMP5_OUT */
  1399. #endif /* COMP5 */
  1400. /**
  1401. * @}
  1402. */
  1403. /** @defgroup TIM_LL_EC_TIM4_TI4_RMP TIM4 Timer Input Ch4 Remap
  1404. * @{
  1405. */
  1406. #define LL_TIM_TIM4_TI4_RMP_GPIO 0x00000000U /*!< TIM4 input 4 is connected to GPIO */
  1407. #if defined(COMP6)
  1408. #define LL_TIM_TIM4_TI4_RMP_COMP6 TIM_TISEL_TI4SEL_0 /*!< TIM4 input 4 is connected to COMP6_OUT */
  1409. #endif /* COMP6 */
  1410. /**
  1411. * @}
  1412. */
  1413. #if defined(TIM5)
  1414. /** @defgroup TIM_LL_EC_TIM5_TI1_RMP TIM5 Timer Input Ch1 Remap
  1415. * @{
  1416. */
  1417. #define LL_TIM_TIM5_TI1_RMP_GPIO 0x00000000U /*!< TIM5 input 1 is connected to GPIO */
  1418. #define LL_TIM_TIM5_TI1_RMP_LSI TIM_TISEL_TI1SEL_0 /*!< TIM5 input 1 is connected to LSI */
  1419. #define LL_TIM_TIM5_TI1_RMP_LSE TIM_TISEL_TI1SEL_1 /*!< TIM5 input 1 is connected to LSE */
  1420. #define LL_TIM_TIM5_TI1_RMP_RTC_WK (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM5 input 1 is connected to RTC_WAKEUP */
  1421. #define LL_TIM_TIM5_TI1_RMP_COMP1 TIM_TISEL_TI1SEL_2 /*!< TIM5 input 1 is connected to COMP1_OUT */
  1422. #define LL_TIM_TIM5_TI1_RMP_COMP2 (TIM_TISEL_TI1SEL_2 | TIM_TISEL_TI1SEL_0) /*!< TIM5 input 1 is connected to COMP2_OUT */
  1423. #define LL_TIM_TIM5_TI1_RMP_COMP3 (TIM_TISEL_TI1SEL_2 | TIM_TISEL_TI1SEL_1) /*!< TIM5 input 1 is connected to COMP3_OUT */
  1424. #define LL_TIM_TIM5_TI1_RMP_COMP4 (TIM_TISEL_TI1SEL_2 | TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM5 input 1 is connected to COMP4_OUT */
  1425. #if defined(COMP5)
  1426. #define LL_TIM_TIM5_TI1_RMP_COMP5 TIM_TISEL_TI1SEL_3 /*!< TIM5 input 1 is connected to COMP5_OUT */
  1427. #endif /* COMP5 */
  1428. #if defined(COMP6)
  1429. #define LL_TIM_TIM5_TI1_RMP_COMP6 (TIM_TISEL_TI1SEL_3 | TIM_TISEL_TI1SEL_0) /*!< TIM5 input 1 is connected to COMP6_OUT */
  1430. #endif /* COMP6 */
  1431. #if defined(COMP7)
  1432. #define LL_TIM_TIM5_TI1_RMP_COMP7 (TIM_TISEL_TI1SEL_3 | TIM_TISEL_TI1SEL_1) /*!< TIM5 input 1 is connected to COMP7_OUT */
  1433. #endif /* COMP7 */
  1434. /**
  1435. * @}
  1436. */
  1437. /** @defgroup TIM_LL_EC_TIM5_TI2_RMP TIM5 Timer Input Ch2 Remap
  1438. * @{
  1439. */
  1440. #define LL_TIM_TIM5_TI2_RMP_GPIO 0x00000000U /*!< TIM5 input 2 is connected to GPIO */
  1441. #define LL_TIM_TIM5_TI2_RMP_COMP1 TIM_TISEL_TI2SEL_0 /*!< TIM5 input 2 is connected to COMP1_OUT */
  1442. #define LL_TIM_TIM5_TI2_RMP_COMP2 TIM_TISEL_TI2SEL_1 /*!< TIM5 input 2 is connected to COMP2_OUT */
  1443. #define LL_TIM_TIM5_TI2_RMP_COMP3 (TIM_TISEL_TI2SEL_1 | TIM_TISEL_TI2SEL_0) /*!< TIM5 input 2 is connected to COMP3_OUT */
  1444. #define LL_TIM_TIM5_TI2_RMP_COMP4 TIM_TISEL_TI2SEL_2 /*!< TIM5 input 2 is connected to COMP4_OUT */
  1445. #if defined(COMP5)
  1446. #define LL_TIM_TIM5_TI2_RMP_COMP5 (TIM_TISEL_TI2SEL_2 | TIM_TISEL_TI2SEL_0) /*!< TIM5 input 2 is connected to COMP5_OUT */
  1447. #endif /* COMP5 */
  1448. #if defined(COMP6)
  1449. #define LL_TIM_TIM5_TI2_RMP_COMP6 (TIM_TISEL_TI2SEL_2 | TIM_TISEL_TI2SEL_1) /*!< TIM5 input 2 is connected to COMP6_OUT */
  1450. #endif /* COMP6 */
  1451. #if defined(COMP7)
  1452. #define LL_TIM_TIM5_TI2_RMP_COMP7 (TIM_TISEL_TI2SEL_2 | TIM_TISEL_TI2SEL_1 | TIM_TISEL_TI2SEL_0) /*!< TIM5 input 2 is connected to COMP7_OUT */
  1453. #endif /* COMP7 */
  1454. /**
  1455. * @}
  1456. */
  1457. #endif /* TIM5 */
  1458. /** @defgroup TIM_LL_EC_TIM8_TI1_RMP TIM8 Timer Input Ch1 Remap
  1459. * @{
  1460. */
  1461. #define LL_TIM_TIM8_TI1_RMP_GPIO 0x00000000U /*!< TIM8 input 1 is connected to GPIO */
  1462. #define LL_TIM_TIM8_TI1_RMP_COMP1 TIM_TISEL_TI1SEL_0 /*!< TIM8 input 1 is connected to COMP1_OUT */
  1463. #define LL_TIM_TIM8_TI1_RMP_COMP2 TIM_TISEL_TI1SEL_1 /*!< TIM8 input 1 is connected to COMP2_OUT */
  1464. #define LL_TIM_TIM8_TI1_RMP_COMP3 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM8 input 1 is connected to COMP3_OUT */
  1465. #define LL_TIM_TIM8_TI1_RMP_COMP4 TIM_TISEL_TI1SEL_2 /*!< TIM8 input 1 is connected to COMP4_OUT */
  1466. /**
  1467. * @}
  1468. */
  1469. /** @defgroup TIM_LL_EC_TIM15_TI1_RMP TIM15 Timer Input Ch1 Remap
  1470. * @{
  1471. */
  1472. #define LL_TIM_TIM15_TI1_RMP_GPIO 0x00000000U /*!< TIM15 input 1 is connected to GPIO */
  1473. #define LL_TIM_TIM15_TI1_RMP_LSE TIM_TISEL_TI1SEL_0 /*!< TIM15 input 1 is connected to LSE */
  1474. #define LL_TIM_TIM15_TI1_RMP_COMP1 TIM_TISEL_TI1SEL_1 /*!< TIM15 input 1 is connected to COMP1_OUT */
  1475. #define LL_TIM_TIM15_TI1_RMP_COMP2 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM15 input 1 is connected to COMP2_OUT */
  1476. #if defined(COMP5)
  1477. #define LL_TIM_TIM15_TI1_RMP_COMP5 TIM_TISEL_TI1SEL_2 /*!< TIM15 input 1 is connected to COMP5_OUT */
  1478. #endif /* COMP5 */
  1479. #if defined(COMP7)
  1480. #define LL_TIM_TIM15_TI1_RMP_COMP7 (TIM_TISEL_TI1SEL_2 | TIM_TISEL_TI1SEL_0) /*!< TIM15 input 1 is connected to COMP7_OUT */
  1481. #endif /* COMP7 */
  1482. /**
  1483. * @}
  1484. */
  1485. /** @defgroup TIM_LL_EC_TIM15_TI2_RMP TIM15 Timer Input Ch2 Remap
  1486. * @{
  1487. */
  1488. #define LL_TIM_TIM15_TI2_RMP_GPIO 0x00000000U /*!< TIM15 input 2 is connected to GPIO */
  1489. #define LL_TIM_TIM15_TI2_RMP_COMP2 TIM_TISEL_TI2SEL_0 /*!< TIM15 input 2 is connected to COMP2_OUT */
  1490. #define LL_TIM_TIM15_TI2_RMP_COMP3 TIM_TISEL_TI2SEL_1 /*!< TIM15 input 2 is connected to COMP3_OUT */
  1491. #if defined(COMP6)
  1492. #define LL_TIM_TIM15_TI2_RMP_COMP6 (TIM_TISEL_TI2SEL_1 | TIM_TISEL_TI2SEL_0) /*!< TIM15 input 2 is connected to COMP6_OUT */
  1493. #endif /* COMP6 */
  1494. #if defined(COMP7)
  1495. #define LL_TIM_TIM15_TI2_RMP_COMP7 TIM_TISEL_TI2SEL_2 /*!< TIM15 input 2 is connected to COMP7_OUT */
  1496. #endif /* COMP7 */
  1497. /**
  1498. * @}
  1499. */
  1500. /** @defgroup TIM_LL_EC_TIM16_TI1_RMP TIM16 Timer Input Ch1 Remap
  1501. * @{
  1502. */
  1503. #define LL_TIM_TIM16_TI1_RMP_GPIO 0x00000000U /*!< TIM16 input 1 is connected to GPIO */
  1504. #if defined(COMP6)
  1505. #define LL_TIM_TIM16_TI1_RMP_COMP6 TIM_TISEL_TI1SEL_0 /*!< TIM16 input 1 is connected to COMP6_OUT */
  1506. #endif /* COMP6 */
  1507. #define LL_TIM_TIM16_TI1_RMP_MCO TIM_TISEL_TI1SEL_1 /*!< TIM16 input 1 is connected to MCO */
  1508. #define LL_TIM_TIM16_TI1_RMP_HSE_32 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM16 input 1 is connected to HSE/32 */
  1509. #define LL_TIM_TIM16_TI1_RMP_RTC_WK TIM_TISEL_TI1SEL_2 /*!< TIM16 input 1 is connected to RTC_WAKEUP */
  1510. #define LL_TIM_TIM16_TI1_RMP_LSE (TIM_TISEL_TI1SEL_2 | TIM_TISEL_TI1SEL_0) /*!< TIM16 input 1 is connected to LSE */
  1511. #define LL_TIM_TIM16_TI1_RMP_LSI (TIM_TISEL_TI1SEL_2 | TIM_TISEL_TI1SEL_1) /*!< TIM16 input 1 is connected to LSI */
  1512. /**
  1513. * @}
  1514. */
  1515. /** @defgroup TIM_LL_EC_TIM17_TI1_RMP TIM17 Timer Input Ch1 Remap
  1516. * @{
  1517. */
  1518. #define LL_TIM_TIM17_TI1_RMP_GPIO 0x00000000U /*!< TIM17 input 1 is connected to GPIO */
  1519. #if defined(COMP5)
  1520. #define LL_TIM_TIM17_TI1_RMP_COMP5 TIM_TISEL_TI1SEL_0 /*!< TIM17 input 1 is connected to COMP5_OUT */
  1521. #endif /* COMP5 */
  1522. #define LL_TIM_TIM17_TI1_RMP_MCO TIM_TISEL_TI1SEL_1 /*!< TIM17 input 1 is connected to MCO */
  1523. #define LL_TIM_TIM17_TI1_RMP_HSE_32 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM17 input 1 is connected to HSE/32 */
  1524. #define LL_TIM_TIM17_TI1_RMP_RTC_WK TIM_TISEL_TI1SEL_2 /*!< TIM17 input 1 is connected to RTC_WAKEUP */
  1525. #define LL_TIM_TIM17_TI1_RMP_LSE (TIM_TISEL_TI1SEL_2 | TIM_TISEL_TI1SEL_0) /*!< TIM17 input 1 is connected to LSE */
  1526. #define LL_TIM_TIM17_TI1_RMP_LSI (TIM_TISEL_TI1SEL_2 | TIM_TISEL_TI1SEL_1) /*!< TIM17 input 1 is connected to LSI */
  1527. /**
  1528. * @}
  1529. */
  1530. #if defined(TIM20)
  1531. /** @defgroup TIM_LL_EC_TIM20_TI1_RMP TIM20 Timer Input Ch1 Remap
  1532. * @{
  1533. */
  1534. #define LL_TIM_TIM20_TI1_RMP_GPIO 0x00000000U /*!< TIM20 input 1 is connected to GPIO */
  1535. #define LL_TIM_TIM20_TI1_RMP_COMP1 TIM_TISEL_TI1SEL_0 /*!< TIM20 input 1 is connected to COMP1_OUT */
  1536. #define LL_TIM_TIM20_TI1_RMP_COMP2 TIM_TISEL_TI1SEL_1 /*!< TIM20 input 1 is connected to COMP2_OUT */
  1537. #define LL_TIM_TIM20_TI1_RMP_COMP3 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM20 input 1 is connected to COMP3_OUT */
  1538. #define LL_TIM_TIM20_TI1_RMP_COMP4 TIM_TISEL_TI1SEL_2 /*!< TIM20 input 1 is connected to COMP4_OUT */
  1539. /**
  1540. * @}
  1541. */
  1542. #endif /* TIM20 */
  1543. /** @defgroup TIM_LL_EC_OCREF_CLR_INT OCREF clear input selection
  1544. * @{
  1545. */
  1546. #define LL_TIM_OCREF_CLR_INT_ETR OCREF_CLEAR_SELECT_Msk /*!< OCREF_CLR_INT is connected to ETRF */
  1547. #define LL_TIM_OCREF_CLR_INT_COMP1 0x00000000U /*!< OCREF clear input is connected to COMP1_OUT */
  1548. #define LL_TIM_OCREF_CLR_INT_COMP2 TIM1_AF2_OCRSEL_0 /*!< OCREF clear input is connected to COMP2_OUT */
  1549. #define LL_TIM_OCREF_CLR_INT_COMP3 TIM1_AF2_OCRSEL_1 /*!< OCREF clear input is connected to COMP3_OUT */
  1550. #define LL_TIM_OCREF_CLR_INT_COMP4 (TIM1_AF2_OCRSEL_1 | TIM1_AF2_OCRSEL_0) /*!< OCREF clear input is connected to COMP4_OUT */
  1551. #if defined(COMP5)
  1552. #define LL_TIM_OCREF_CLR_INT_COMP5 TIM1_AF2_OCRSEL_2 /*!< OCREF clear input is connected to COMP5_OUT */
  1553. #endif /* COMP5 */
  1554. #if defined(COMP6)
  1555. #define LL_TIM_OCREF_CLR_INT_COMP6 (TIM1_AF2_OCRSEL_2 | TIM1_AF2_OCRSEL_0) /*!< OCREF clear input is connected to COMP6_OUT */
  1556. #endif /* COMP6 */
  1557. #if defined(COMP7)
  1558. #define LL_TIM_OCREF_CLR_INT_COMP7 (TIM1_AF2_OCRSEL_2 | TIM1_AF2_OCRSEL_1) /*!< OCREF clear input is connected to COMP7_OUT */
  1559. #endif /* COMP7 */
  1560. /**
  1561. * @}
  1562. */
  1563. /** @defgroup TIM_LL_EC_INDEX_DIR index direction selection
  1564. * @{
  1565. */
  1566. #define LL_TIM_INDEX_UP_DOWN 0x00000000U /*!< Index resets the counter whatever the direction */
  1567. #define LL_TIM_INDEX_UP TIM_ECR_IDIR_0 /*!< Index resets the counter when up-counting only */
  1568. #define LL_TIM_INDEX_DOWN TIM_ECR_IDIR_1 /*!< Index resets the counter when down-counting only */
  1569. /**
  1570. * @}
  1571. */
  1572. /** @defgroup TIM_LL_EC_INDEX_POSITION index positioning selection
  1573. * @{
  1574. */
  1575. #define LL_TIM_INDEX_POSITION_DOWN_DOWN 0x00000000U /*!< Index resets the counter when AB = 00 */
  1576. #define LL_TIM_INDEX_POSITION_DOWN_UP TIM_ECR_IPOS_0 /*!< Index resets the counter when AB = 01 */
  1577. #define LL_TIM_INDEX_POSITION_UP_DOWN TIM_ECR_IPOS_1 /*!< Index resets the counter when AB = 10 */
  1578. #define LL_TIM_INDEX_POSITION_UP_UP (TIM_ECR_IPOS_1 | TIM_ECR_IPOS_0) /*!< Index resets the counter when AB = 11 */
  1579. #define LL_TIM_INDEX_POSITION_DOWN 0x00000000U /*!< Index resets the counter when clock is 0 */
  1580. #define LL_TIM_INDEX_POSITION_UP TIM_ECR_IPOS_0 /*!< Index resets the counter when clock is 1 */
  1581. /**
  1582. * @}
  1583. */
  1584. /** @defgroup TIM_LL_EC_FIRST_INDEX first index selection
  1585. * @{
  1586. */
  1587. #define LL_TIM_INDEX_ALL 0x00000000U /*!< Index is always active */
  1588. #define LL_TIM_INDEX_FIRST_ONLY TIM_ECR_FIDX /*!< The first Index only resets the counter */
  1589. /**
  1590. * @}
  1591. */
  1592. /** @defgroup TIM_LL_EC_PWPRSC Pulse on compare pulse width prescaler
  1593. * @{
  1594. */
  1595. #define LL_TIM_PWPRSC_X1 0x00000000U /*!< Pulse on compare pulse width prescaler 1 */
  1596. #define LL_TIM_PWPRSC_X2 TIM_ECR_PWPRSC_0 /*!< Pulse on compare pulse width prescaler 2 */
  1597. #define LL_TIM_PWPRSC_X4 TIM_ECR_PWPRSC_1 /*!< Pulse on compare pulse width prescaler 4 */
  1598. #define LL_TIM_PWPRSC_X8 (TIM_ECR_PWPRSC_1 | TIM_ECR_PWPRSC_0) /*!< Pulse on compare pulse width prescaler 8 */
  1599. #define LL_TIM_PWPRSC_X16 TIM_ECR_PWPRSC_2 /*!< Pulse on compare pulse width prescaler 16 */
  1600. #define LL_TIM_PWPRSC_X32 (TIM_ECR_PWPRSC_2 | TIM_ECR_PWPRSC_0) /*!< Pulse on compare pulse width prescaler 32 */
  1601. #define LL_TIM_PWPRSC_X64 (TIM_ECR_PWPRSC_2 | TIM_ECR_PWPRSC_1) /*!< Pulse on compare pulse width prescaler 64 */
  1602. #define LL_TIM_PWPRSC_X128 (TIM_ECR_PWPRSC_2 | TIM_ECR_PWPRSC_1 | TIM_ECR_PWPRSC_0) /*!< Pulse on compare pulse width prescaler 128 */
  1603. /**
  1604. * @}
  1605. */
  1606. /** @defgroup TIM_LL_EC_HSE_32_REQUEST Clock HSE/32 request
  1607. * @{
  1608. */
  1609. #define LL_TIM_HSE_32_NOT_REQUEST 0x00000000U /*!< Clock HSE/32 not requested */
  1610. #define LL_TIM_HSE_32_REQUEST TIM_OR_HSE32EN /*!< Clock HSE/32 requested for TIM16/17 TI1SEL remap */
  1611. /**
  1612. * @}
  1613. */
  1614. /** Legacy definitions for compatibility purpose
  1615. @cond 0
  1616. */
  1617. #define LL_TIM_BKIN_SOURCE_DFBK LL_TIM_BKIN_SOURCE_DF1BK
  1618. /**
  1619. @endcond
  1620. */
  1621. /**
  1622. * @}
  1623. */
  1624. /* Exported macro ------------------------------------------------------------*/
  1625. /** @defgroup TIM_LL_Exported_Macros TIM Exported Macros
  1626. * @{
  1627. */
  1628. /** @defgroup TIM_LL_EM_WRITE_READ Common Write and read registers Macros
  1629. * @{
  1630. */
  1631. /**
  1632. * @brief Write a value in TIM register.
  1633. * @param __INSTANCE__ TIM Instance
  1634. * @param __REG__ Register to be written
  1635. * @param __VALUE__ Value to be written in the register
  1636. * @retval None
  1637. */
  1638. #define LL_TIM_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG((__INSTANCE__)->__REG__, (__VALUE__))
  1639. /**
  1640. * @brief Read a value in TIM register.
  1641. * @param __INSTANCE__ TIM Instance
  1642. * @param __REG__ Register to be read
  1643. * @retval Register value
  1644. */
  1645. #define LL_TIM_ReadReg(__INSTANCE__, __REG__) READ_REG((__INSTANCE__)->__REG__)
  1646. /**
  1647. * @}
  1648. */
  1649. /**
  1650. * @brief HELPER macro retrieving the UIFCPY flag from the counter value.
  1651. * @note ex: @ref __LL_TIM_GETFLAG_UIFCPY (@ref LL_TIM_GetCounter ());
  1652. * @note Relevant only if UIF flag remapping has been enabled (UIF status bit is copied
  1653. * to TIMx_CNT register bit 31)
  1654. * @param __CNT__ Counter value
  1655. * @retval UIF status bit
  1656. */
  1657. #define __LL_TIM_GETFLAG_UIFCPY(__CNT__) \
  1658. (READ_BIT((__CNT__), TIM_CNT_UIFCPY) >> TIM_CNT_UIFCPY_Pos)
  1659. /**
  1660. * @brief HELPER macro calculating DTG[0:7] in the TIMx_BDTR register to achieve the requested dead time duration.
  1661. * @note ex: @ref __LL_TIM_CALC_DEADTIME (80000000, @ref LL_TIM_GetClockDivision (), 120);
  1662. * @param __TIMCLK__ timer input clock frequency (in Hz)
  1663. * @param __CKD__ This parameter can be one of the following values:
  1664. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  1665. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  1666. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  1667. * @param __DT__ deadtime duration (in ns)
  1668. * @retval DTG[0:7]
  1669. */
  1670. #define __LL_TIM_CALC_DEADTIME(__TIMCLK__, __CKD__, __DT__) \
  1671. ( (((uint64_t)((__DT__)*1000U)) < ((DT_DELAY_1+1U) * TIM_CALC_DTS((__TIMCLK__), (__CKD__)))) ? \
  1672. (uint8_t)(((uint64_t)((__DT__)*1000U) / TIM_CALC_DTS((__TIMCLK__), (__CKD__))) & DT_DELAY_1) : \
  1673. (((uint64_t)((__DT__)*1000U)) < ((64U + (DT_DELAY_2+1U)) * 2U * TIM_CALC_DTS((__TIMCLK__), (__CKD__)))) ? \
  1674. (uint8_t)(DT_RANGE_2 | ((uint8_t)((uint8_t)((((uint64_t)((__DT__)*1000U))/ TIM_CALC_DTS((__TIMCLK__), \
  1675. (__CKD__))) >> 1U) - (uint8_t) 64) & DT_DELAY_2)) :\
  1676. (((uint64_t)((__DT__)*1000U)) < ((32U + (DT_DELAY_3+1U)) * 8U * TIM_CALC_DTS((__TIMCLK__), (__CKD__)))) ? \
  1677. (uint8_t)(DT_RANGE_3 | ((uint8_t)((uint8_t)(((((uint64_t)(__DT__)*1000U))/ TIM_CALC_DTS((__TIMCLK__), \
  1678. (__CKD__))) >> 3U) - (uint8_t) 32) & DT_DELAY_3)) :\
  1679. (((uint64_t)((__DT__)*1000U)) < ((32U + (DT_DELAY_4+1U)) * 16U * TIM_CALC_DTS((__TIMCLK__), (__CKD__)))) ? \
  1680. (uint8_t)(DT_RANGE_4 | ((uint8_t)((uint8_t)(((((uint64_t)(__DT__)*1000U))/ TIM_CALC_DTS((__TIMCLK__), \
  1681. (__CKD__))) >> 4U) - (uint8_t) 32) & DT_DELAY_4)) :\
  1682. 0U)
  1683. /**
  1684. * @brief HELPER macro calculating the prescaler value to achieve the required counter clock frequency.
  1685. * @note ex: @ref __LL_TIM_CALC_PSC (80000000, 1000000);
  1686. * @param __TIMCLK__ timer input clock frequency (in Hz)
  1687. * @param __CNTCLK__ counter clock frequency (in Hz)
  1688. * @retval Prescaler value (between Min_Data=0 and Max_Data=65535)
  1689. */
  1690. #define __LL_TIM_CALC_PSC(__TIMCLK__, __CNTCLK__) \
  1691. (((__TIMCLK__) >= (__CNTCLK__)) ? (uint32_t)((((__TIMCLK__) + (__CNTCLK__)/2U)/(__CNTCLK__)) - 1U) : 0U)
  1692. /**
  1693. * @brief HELPER macro calculating the auto-reload value to achieve the required output signal frequency.
  1694. * @note ex: @ref __LL_TIM_CALC_ARR (1000000, @ref LL_TIM_GetPrescaler (), 10000);
  1695. * @param __TIMCLK__ timer input clock frequency (in Hz)
  1696. * @param __PSC__ prescaler
  1697. * @param __FREQ__ output signal frequency (in Hz)
  1698. * @retval Auto-reload value (between Min_Data=0 and Max_Data=65535)
  1699. */
  1700. #define __LL_TIM_CALC_ARR(__TIMCLK__, __PSC__, __FREQ__) \
  1701. ((((__TIMCLK__)/((__PSC__) + 1U)) >= (__FREQ__)) ? (((__TIMCLK__)/((__FREQ__) * ((__PSC__) + 1U))) - 1U) : 0U)
  1702. /**
  1703. * @brief HELPER macro calculating the auto-reload value, with dithering feature enabled, to achieve the required
  1704. * output signal frequency.
  1705. * @note ex: @ref __LL_TIM_CALC_ARR_DITHER (1000000, @ref LL_TIM_GetPrescaler (), 10000);
  1706. * @param __TIMCLK__ timer input clock frequency (in Hz)
  1707. * @param __PSC__ prescaler
  1708. * @param __FREQ__ output signal frequency (in Hz)
  1709. * @retval Auto-reload value (between Min_Data=0 and Max_Data=65535)
  1710. */
  1711. #define __LL_TIM_CALC_ARR_DITHER(__TIMCLK__, __PSC__, __FREQ__) \
  1712. ((((__TIMCLK__)/((__PSC__) + 1U)) >= (__FREQ__)) ? \
  1713. (uint32_t)((((uint64_t)(__TIMCLK__) * 16U/((__FREQ__) * ((__PSC__) + 1U))) - 16U)) : 0U)
  1714. /**
  1715. * @brief HELPER macro calculating the compare value required to achieve the required timer output compare
  1716. * active/inactive delay.
  1717. * @note ex: @ref __LL_TIM_CALC_DELAY (1000000, @ref LL_TIM_GetPrescaler (), 10);
  1718. * @param __TIMCLK__ timer input clock frequency (in Hz)
  1719. * @param __PSC__ prescaler
  1720. * @param __DELAY__ timer output compare active/inactive delay (in us)
  1721. * @retval Compare value (between Min_Data=0 and Max_Data=65535)
  1722. */
  1723. #define __LL_TIM_CALC_DELAY(__TIMCLK__, __PSC__, __DELAY__) \
  1724. ((uint32_t)(((uint64_t)(__TIMCLK__) * (uint64_t)(__DELAY__)) \
  1725. / ((uint64_t)1000000U * (uint64_t)((__PSC__) + 1U))))
  1726. /**
  1727. * @brief HELPER macro calculating the compare value, with dithering feature enabled, to achieve the required timer
  1728. * output compare active/inactive delay.
  1729. * @note ex: @ref __LL_TIM_CALC_DELAY_DITHER (1000000, @ref LL_TIM_GetPrescaler (), 10);
  1730. * @param __TIMCLK__ timer input clock frequency (in Hz)
  1731. * @param __PSC__ prescaler
  1732. * @param __DELAY__ timer output compare active/inactive delay (in us)
  1733. * @retval Compare value (between Min_Data=0 and Max_Data=65535)
  1734. */
  1735. #define __LL_TIM_CALC_DELAY_DITHER(__TIMCLK__, __PSC__, __DELAY__) \
  1736. ((uint32_t)(((uint64_t)(__TIMCLK__) * (uint64_t)(__DELAY__) * 16U) \
  1737. / ((uint64_t)1000000U * (uint64_t)((__PSC__) + 1U))))
  1738. /**
  1739. * @brief HELPER macro calculating the auto-reload value to achieve the required pulse duration
  1740. * (when the timer operates in one pulse mode).
  1741. * @note ex: @ref __LL_TIM_CALC_PULSE (1000000, @ref LL_TIM_GetPrescaler (), 10, 20);
  1742. * @param __TIMCLK__ timer input clock frequency (in Hz)
  1743. * @param __PSC__ prescaler
  1744. * @param __DELAY__ timer output compare active/inactive delay (in us)
  1745. * @param __PULSE__ pulse duration (in us)
  1746. * @retval Auto-reload value (between Min_Data=0 and Max_Data=65535)
  1747. */
  1748. #define __LL_TIM_CALC_PULSE(__TIMCLK__, __PSC__, __DELAY__, __PULSE__) \
  1749. ((uint32_t)(__LL_TIM_CALC_DELAY((__TIMCLK__), (__PSC__), (__PULSE__)) \
  1750. + __LL_TIM_CALC_DELAY((__TIMCLK__), (__PSC__), (__DELAY__))))
  1751. /**
  1752. * @brief HELPER macro calculating the auto-reload value, with dithering feature enabled, to achieve the required
  1753. * pulse duration (when the timer operates in one pulse mode).
  1754. * @note ex: @ref __LL_TIM_CALC_PULSE_DITHER (1000000, @ref LL_TIM_GetPrescaler (), 10, 20);
  1755. * @param __TIMCLK__ timer input clock frequency (in Hz)
  1756. * @param __PSC__ prescaler
  1757. * @param __DELAY__ timer output compare active/inactive delay (in us)
  1758. * @param __PULSE__ pulse duration (in us)
  1759. * @retval Auto-reload value (between Min_Data=0 and Max_Data=65535)
  1760. */
  1761. #define __LL_TIM_CALC_PULSE_DITHER(__TIMCLK__, __PSC__, __DELAY__, __PULSE__) \
  1762. ((uint32_t)(__LL_TIM_CALC_DELAY_DITHER((__TIMCLK__), (__PSC__), (__PULSE__)) \
  1763. + __LL_TIM_CALC_DELAY_DITHER((__TIMCLK__), (__PSC__), (__DELAY__))))
  1764. /**
  1765. * @brief HELPER macro retrieving the ratio of the input capture prescaler
  1766. * @note ex: @ref __LL_TIM_GET_ICPSC_RATIO (@ref LL_TIM_IC_GetPrescaler ());
  1767. * @param __ICPSC__ This parameter can be one of the following values:
  1768. * @arg @ref LL_TIM_ICPSC_DIV1
  1769. * @arg @ref LL_TIM_ICPSC_DIV2
  1770. * @arg @ref LL_TIM_ICPSC_DIV4
  1771. * @arg @ref LL_TIM_ICPSC_DIV8
  1772. * @retval Input capture prescaler ratio (1, 2, 4 or 8)
  1773. */
  1774. #define __LL_TIM_GET_ICPSC_RATIO(__ICPSC__) \
  1775. ((uint32_t)(0x01U << (((__ICPSC__) >> 16U) >> TIM_CCMR1_IC1PSC_Pos)))
  1776. /**
  1777. * @}
  1778. */
  1779. /* Exported functions --------------------------------------------------------*/
  1780. /** @defgroup TIM_LL_Exported_Functions TIM Exported Functions
  1781. * @{
  1782. */
  1783. /** @defgroup TIM_LL_EF_Time_Base Time Base configuration
  1784. * @{
  1785. */
  1786. /**
  1787. * @brief Enable timer counter.
  1788. * @rmtoll CR1 CEN LL_TIM_EnableCounter
  1789. * @param TIMx Timer instance
  1790. * @retval None
  1791. */
  1792. __STATIC_INLINE void LL_TIM_EnableCounter(TIM_TypeDef *TIMx)
  1793. {
  1794. SET_BIT(TIMx->CR1, TIM_CR1_CEN);
  1795. }
  1796. /**
  1797. * @brief Disable timer counter.
  1798. * @rmtoll CR1 CEN LL_TIM_DisableCounter
  1799. * @param TIMx Timer instance
  1800. * @retval None
  1801. */
  1802. __STATIC_INLINE void LL_TIM_DisableCounter(TIM_TypeDef *TIMx)
  1803. {
  1804. CLEAR_BIT(TIMx->CR1, TIM_CR1_CEN);
  1805. }
  1806. /**
  1807. * @brief Indicates whether the timer counter is enabled.
  1808. * @rmtoll CR1 CEN LL_TIM_IsEnabledCounter
  1809. * @param TIMx Timer instance
  1810. * @retval State of bit (1 or 0).
  1811. */
  1812. __STATIC_INLINE uint32_t LL_TIM_IsEnabledCounter(const TIM_TypeDef *TIMx)
  1813. {
  1814. return ((READ_BIT(TIMx->CR1, TIM_CR1_CEN) == (TIM_CR1_CEN)) ? 1UL : 0UL);
  1815. }
  1816. /**
  1817. * @brief Enable update event generation.
  1818. * @rmtoll CR1 UDIS LL_TIM_EnableUpdateEvent
  1819. * @param TIMx Timer instance
  1820. * @retval None
  1821. */
  1822. __STATIC_INLINE void LL_TIM_EnableUpdateEvent(TIM_TypeDef *TIMx)
  1823. {
  1824. CLEAR_BIT(TIMx->CR1, TIM_CR1_UDIS);
  1825. }
  1826. /**
  1827. * @brief Disable update event generation.
  1828. * @rmtoll CR1 UDIS LL_TIM_DisableUpdateEvent
  1829. * @param TIMx Timer instance
  1830. * @retval None
  1831. */
  1832. __STATIC_INLINE void LL_TIM_DisableUpdateEvent(TIM_TypeDef *TIMx)
  1833. {
  1834. SET_BIT(TIMx->CR1, TIM_CR1_UDIS);
  1835. }
  1836. /**
  1837. * @brief Indicates whether update event generation is enabled.
  1838. * @rmtoll CR1 UDIS LL_TIM_IsEnabledUpdateEvent
  1839. * @param TIMx Timer instance
  1840. * @retval Inverted state of bit (0 or 1).
  1841. */
  1842. __STATIC_INLINE uint32_t LL_TIM_IsEnabledUpdateEvent(const TIM_TypeDef *TIMx)
  1843. {
  1844. return ((READ_BIT(TIMx->CR1, TIM_CR1_UDIS) == (uint32_t)RESET) ? 1UL : 0UL);
  1845. }
  1846. /**
  1847. * @brief Set update event source
  1848. * @note Update event source set to LL_TIM_UPDATESOURCE_REGULAR: any of the following events
  1849. * generate an update interrupt or DMA request if enabled:
  1850. * - Counter overflow/underflow
  1851. * - Setting the UG bit
  1852. * - Update generation through the slave mode controller
  1853. * @note Update event source set to LL_TIM_UPDATESOURCE_COUNTER: only counter
  1854. * overflow/underflow generates an update interrupt or DMA request if enabled.
  1855. * @rmtoll CR1 URS LL_TIM_SetUpdateSource
  1856. * @param TIMx Timer instance
  1857. * @param UpdateSource This parameter can be one of the following values:
  1858. * @arg @ref LL_TIM_UPDATESOURCE_REGULAR
  1859. * @arg @ref LL_TIM_UPDATESOURCE_COUNTER
  1860. * @retval None
  1861. */
  1862. __STATIC_INLINE void LL_TIM_SetUpdateSource(TIM_TypeDef *TIMx, uint32_t UpdateSource)
  1863. {
  1864. MODIFY_REG(TIMx->CR1, TIM_CR1_URS, UpdateSource);
  1865. }
  1866. /**
  1867. * @brief Get actual event update source
  1868. * @rmtoll CR1 URS LL_TIM_GetUpdateSource
  1869. * @param TIMx Timer instance
  1870. * @retval Returned value can be one of the following values:
  1871. * @arg @ref LL_TIM_UPDATESOURCE_REGULAR
  1872. * @arg @ref LL_TIM_UPDATESOURCE_COUNTER
  1873. */
  1874. __STATIC_INLINE uint32_t LL_TIM_GetUpdateSource(const TIM_TypeDef *TIMx)
  1875. {
  1876. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_URS));
  1877. }
  1878. /**
  1879. * @brief Set one pulse mode (one shot v.s. repetitive).
  1880. * @rmtoll CR1 OPM LL_TIM_SetOnePulseMode
  1881. * @param TIMx Timer instance
  1882. * @param OnePulseMode This parameter can be one of the following values:
  1883. * @arg @ref LL_TIM_ONEPULSEMODE_SINGLE
  1884. * @arg @ref LL_TIM_ONEPULSEMODE_REPETITIVE
  1885. * @retval None
  1886. */
  1887. __STATIC_INLINE void LL_TIM_SetOnePulseMode(TIM_TypeDef *TIMx, uint32_t OnePulseMode)
  1888. {
  1889. MODIFY_REG(TIMx->CR1, TIM_CR1_OPM, OnePulseMode);
  1890. }
  1891. /**
  1892. * @brief Get actual one pulse mode.
  1893. * @rmtoll CR1 OPM LL_TIM_GetOnePulseMode
  1894. * @param TIMx Timer instance
  1895. * @retval Returned value can be one of the following values:
  1896. * @arg @ref LL_TIM_ONEPULSEMODE_SINGLE
  1897. * @arg @ref LL_TIM_ONEPULSEMODE_REPETITIVE
  1898. */
  1899. __STATIC_INLINE uint32_t LL_TIM_GetOnePulseMode(const TIM_TypeDef *TIMx)
  1900. {
  1901. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_OPM));
  1902. }
  1903. /**
  1904. * @brief Set the timer counter counting mode.
  1905. * @note Macro IS_TIM_COUNTER_MODE_SELECT_INSTANCE(TIMx) can be used to
  1906. * check whether or not the counter mode selection feature is supported
  1907. * by a timer instance.
  1908. * @note Switching from Center Aligned counter mode to Edge counter mode (or reverse)
  1909. * requires a timer reset to avoid unexpected direction
  1910. * due to DIR bit readonly in center aligned mode.
  1911. * @rmtoll CR1 DIR LL_TIM_SetCounterMode\n
  1912. * CR1 CMS LL_TIM_SetCounterMode
  1913. * @param TIMx Timer instance
  1914. * @param CounterMode This parameter can be one of the following values:
  1915. * @arg @ref LL_TIM_COUNTERMODE_UP
  1916. * @arg @ref LL_TIM_COUNTERMODE_DOWN
  1917. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP
  1918. * @arg @ref LL_TIM_COUNTERMODE_CENTER_DOWN
  1919. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP_DOWN
  1920. * @retval None
  1921. */
  1922. __STATIC_INLINE void LL_TIM_SetCounterMode(TIM_TypeDef *TIMx, uint32_t CounterMode)
  1923. {
  1924. MODIFY_REG(TIMx->CR1, (TIM_CR1_DIR | TIM_CR1_CMS), CounterMode);
  1925. }
  1926. /**
  1927. * @brief Get actual counter mode.
  1928. * @note Macro IS_TIM_COUNTER_MODE_SELECT_INSTANCE(TIMx) can be used to
  1929. * check whether or not the counter mode selection feature is supported
  1930. * by a timer instance.
  1931. * @rmtoll CR1 DIR LL_TIM_GetCounterMode\n
  1932. * CR1 CMS LL_TIM_GetCounterMode
  1933. * @param TIMx Timer instance
  1934. * @retval Returned value can be one of the following values:
  1935. * @arg @ref LL_TIM_COUNTERMODE_UP
  1936. * @arg @ref LL_TIM_COUNTERMODE_DOWN
  1937. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP
  1938. * @arg @ref LL_TIM_COUNTERMODE_CENTER_DOWN
  1939. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP_DOWN
  1940. */
  1941. __STATIC_INLINE uint32_t LL_TIM_GetCounterMode(const TIM_TypeDef *TIMx)
  1942. {
  1943. uint32_t counter_mode;
  1944. counter_mode = (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_CMS));
  1945. if (counter_mode == 0U)
  1946. {
  1947. counter_mode = (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_DIR));
  1948. }
  1949. return counter_mode;
  1950. }
  1951. /**
  1952. * @brief Enable auto-reload (ARR) preload.
  1953. * @rmtoll CR1 ARPE LL_TIM_EnableARRPreload
  1954. * @param TIMx Timer instance
  1955. * @retval None
  1956. */
  1957. __STATIC_INLINE void LL_TIM_EnableARRPreload(TIM_TypeDef *TIMx)
  1958. {
  1959. SET_BIT(TIMx->CR1, TIM_CR1_ARPE);
  1960. }
  1961. /**
  1962. * @brief Disable auto-reload (ARR) preload.
  1963. * @rmtoll CR1 ARPE LL_TIM_DisableARRPreload
  1964. * @param TIMx Timer instance
  1965. * @retval None
  1966. */
  1967. __STATIC_INLINE void LL_TIM_DisableARRPreload(TIM_TypeDef *TIMx)
  1968. {
  1969. CLEAR_BIT(TIMx->CR1, TIM_CR1_ARPE);
  1970. }
  1971. /**
  1972. * @brief Indicates whether auto-reload (ARR) preload is enabled.
  1973. * @rmtoll CR1 ARPE LL_TIM_IsEnabledARRPreload
  1974. * @param TIMx Timer instance
  1975. * @retval State of bit (1 or 0).
  1976. */
  1977. __STATIC_INLINE uint32_t LL_TIM_IsEnabledARRPreload(const TIM_TypeDef *TIMx)
  1978. {
  1979. return ((READ_BIT(TIMx->CR1, TIM_CR1_ARPE) == (TIM_CR1_ARPE)) ? 1UL : 0UL);
  1980. }
  1981. /**
  1982. * @brief Set the division ratio between the timer clock and the sampling clock used by the dead-time generators
  1983. * (when supported) and the digital filters.
  1984. * @note Macro IS_TIM_CLOCK_DIVISION_INSTANCE(TIMx) can be used to check
  1985. * whether or not the clock division feature is supported by the timer
  1986. * instance.
  1987. * @rmtoll CR1 CKD LL_TIM_SetClockDivision
  1988. * @param TIMx Timer instance
  1989. * @param ClockDivision This parameter can be one of the following values:
  1990. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  1991. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  1992. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  1993. * @retval None
  1994. */
  1995. __STATIC_INLINE void LL_TIM_SetClockDivision(TIM_TypeDef *TIMx, uint32_t ClockDivision)
  1996. {
  1997. MODIFY_REG(TIMx->CR1, TIM_CR1_CKD, ClockDivision);
  1998. }
  1999. /**
  2000. * @brief Get the actual division ratio between the timer clock and the sampling clock used by the dead-time
  2001. * generators (when supported) and the digital filters.
  2002. * @note Macro IS_TIM_CLOCK_DIVISION_INSTANCE(TIMx) can be used to check
  2003. * whether or not the clock division feature is supported by the timer
  2004. * instance.
  2005. * @rmtoll CR1 CKD LL_TIM_GetClockDivision
  2006. * @param TIMx Timer instance
  2007. * @retval Returned value can be one of the following values:
  2008. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  2009. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  2010. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  2011. */
  2012. __STATIC_INLINE uint32_t LL_TIM_GetClockDivision(const TIM_TypeDef *TIMx)
  2013. {
  2014. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_CKD));
  2015. }
  2016. /**
  2017. * @brief Set the counter value.
  2018. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2019. * whether or not a timer instance supports a 32 bits counter.
  2020. * @note If dithering is activated, pay attention to the Counter value interpretation
  2021. * @rmtoll CNT CNT LL_TIM_SetCounter
  2022. * @param TIMx Timer instance
  2023. * @param Counter Counter value (between Min_Data=0 and Max_Data=0xFFFF or 0xFFFFFFFF)
  2024. * @retval None
  2025. */
  2026. __STATIC_INLINE void LL_TIM_SetCounter(TIM_TypeDef *TIMx, uint32_t Counter)
  2027. {
  2028. WRITE_REG(TIMx->CNT, Counter);
  2029. }
  2030. /**
  2031. * @brief Get the counter value.
  2032. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2033. * whether or not a timer instance supports a 32 bits counter.
  2034. * @note If dithering is activated, pay attention to the Counter value interpretation
  2035. * @rmtoll CNT CNT LL_TIM_GetCounter
  2036. * @param TIMx Timer instance
  2037. * @retval Counter value (between Min_Data=0 and Max_Data=0xFFFF or 0xFFFFFFFF)
  2038. */
  2039. __STATIC_INLINE uint32_t LL_TIM_GetCounter(const TIM_TypeDef *TIMx)
  2040. {
  2041. return (uint32_t)(READ_REG(TIMx->CNT));
  2042. }
  2043. /**
  2044. * @brief Get the current direction of the counter
  2045. * @rmtoll CR1 DIR LL_TIM_GetDirection
  2046. * @param TIMx Timer instance
  2047. * @retval Returned value can be one of the following values:
  2048. * @arg @ref LL_TIM_COUNTERDIRECTION_UP
  2049. * @arg @ref LL_TIM_COUNTERDIRECTION_DOWN
  2050. */
  2051. __STATIC_INLINE uint32_t LL_TIM_GetDirection(const TIM_TypeDef *TIMx)
  2052. {
  2053. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_DIR));
  2054. }
  2055. /**
  2056. * @brief Set the prescaler value.
  2057. * @note The counter clock frequency CK_CNT is equal to fCK_PSC / (PSC[15:0] + 1).
  2058. * @note The prescaler can be changed on the fly as this control register is buffered. The new
  2059. * prescaler ratio is taken into account at the next update event.
  2060. * @note Helper macro @ref __LL_TIM_CALC_PSC can be used to calculate the Prescaler parameter
  2061. * @rmtoll PSC PSC LL_TIM_SetPrescaler
  2062. * @param TIMx Timer instance
  2063. * @param Prescaler between Min_Data=0 and Max_Data=65535
  2064. * @retval None
  2065. */
  2066. __STATIC_INLINE void LL_TIM_SetPrescaler(TIM_TypeDef *TIMx, uint32_t Prescaler)
  2067. {
  2068. WRITE_REG(TIMx->PSC, Prescaler);
  2069. }
  2070. /**
  2071. * @brief Get the prescaler value.
  2072. * @rmtoll PSC PSC LL_TIM_GetPrescaler
  2073. * @param TIMx Timer instance
  2074. * @retval Prescaler value between Min_Data=0 and Max_Data=65535
  2075. */
  2076. __STATIC_INLINE uint32_t LL_TIM_GetPrescaler(const TIM_TypeDef *TIMx)
  2077. {
  2078. return (uint32_t)(READ_REG(TIMx->PSC));
  2079. }
  2080. /**
  2081. * @brief Set the auto-reload value.
  2082. * @note The counter is blocked while the auto-reload value is null.
  2083. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2084. * whether or not a timer instance supports a 32 bits counter.
  2085. * @note Helper macro @ref __LL_TIM_CALC_ARR can be used to calculate the AutoReload parameter
  2086. * In case dithering is activated,macro __LL_TIM_CALC_ARR_DITHER can be used instead, to calculate the AutoReload
  2087. * parameter.
  2088. * @rmtoll ARR ARR LL_TIM_SetAutoReload
  2089. * @param TIMx Timer instance
  2090. * @param AutoReload between Min_Data=0 and Max_Data=65535
  2091. * @retval None
  2092. */
  2093. __STATIC_INLINE void LL_TIM_SetAutoReload(TIM_TypeDef *TIMx, uint32_t AutoReload)
  2094. {
  2095. WRITE_REG(TIMx->ARR, AutoReload);
  2096. }
  2097. /**
  2098. * @brief Get the auto-reload value.
  2099. * @rmtoll ARR ARR LL_TIM_GetAutoReload
  2100. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2101. * whether or not a timer instance supports a 32 bits counter.
  2102. * @note If dithering is activated, pay attention to the returned value interpretation
  2103. * @param TIMx Timer instance
  2104. * @retval Auto-reload value
  2105. */
  2106. __STATIC_INLINE uint32_t LL_TIM_GetAutoReload(const TIM_TypeDef *TIMx)
  2107. {
  2108. return (uint32_t)(READ_REG(TIMx->ARR));
  2109. }
  2110. /**
  2111. * @brief Set the repetition counter value.
  2112. * @note For advanced timer instances RepetitionCounter can be up to 65535.
  2113. * @note Macro IS_TIM_REPETITION_COUNTER_INSTANCE(TIMx) can be used to check
  2114. * whether or not a timer instance supports a repetition counter.
  2115. * @rmtoll RCR REP LL_TIM_SetRepetitionCounter
  2116. * @param TIMx Timer instance
  2117. * @param RepetitionCounter between Min_Data=0 and Max_Data=255 or 65535 for advanced timer.
  2118. * @retval None
  2119. */
  2120. __STATIC_INLINE void LL_TIM_SetRepetitionCounter(TIM_TypeDef *TIMx, uint32_t RepetitionCounter)
  2121. {
  2122. WRITE_REG(TIMx->RCR, RepetitionCounter);
  2123. }
  2124. /**
  2125. * @brief Get the repetition counter value.
  2126. * @note Macro IS_TIM_REPETITION_COUNTER_INSTANCE(TIMx) can be used to check
  2127. * whether or not a timer instance supports a repetition counter.
  2128. * @rmtoll RCR REP LL_TIM_GetRepetitionCounter
  2129. * @param TIMx Timer instance
  2130. * @retval Repetition counter value
  2131. */
  2132. __STATIC_INLINE uint32_t LL_TIM_GetRepetitionCounter(const TIM_TypeDef *TIMx)
  2133. {
  2134. return (uint32_t)(READ_REG(TIMx->RCR));
  2135. }
  2136. /**
  2137. * @brief Force a continuous copy of the update interrupt flag (UIF) into the timer counter register (bit 31).
  2138. * @note This allows both the counter value and a potential roll-over condition signalled by the UIFCPY flag to be read
  2139. * in an atomic way.
  2140. * @rmtoll CR1 UIFREMAP LL_TIM_EnableUIFRemap
  2141. * @param TIMx Timer instance
  2142. * @retval None
  2143. */
  2144. __STATIC_INLINE void LL_TIM_EnableUIFRemap(TIM_TypeDef *TIMx)
  2145. {
  2146. SET_BIT(TIMx->CR1, TIM_CR1_UIFREMAP);
  2147. }
  2148. /**
  2149. * @brief Disable update interrupt flag (UIF) remapping.
  2150. * @rmtoll CR1 UIFREMAP LL_TIM_DisableUIFRemap
  2151. * @param TIMx Timer instance
  2152. * @retval None
  2153. */
  2154. __STATIC_INLINE void LL_TIM_DisableUIFRemap(TIM_TypeDef *TIMx)
  2155. {
  2156. CLEAR_BIT(TIMx->CR1, TIM_CR1_UIFREMAP);
  2157. }
  2158. /**
  2159. * @brief Indicate whether update interrupt flag (UIF) copy is set.
  2160. * @param Counter Counter value
  2161. * @retval State of bit (1 or 0).
  2162. */
  2163. __STATIC_INLINE uint32_t LL_TIM_IsActiveUIFCPY(const uint32_t Counter)
  2164. {
  2165. return (((Counter & TIM_CNT_UIFCPY) == (TIM_CNT_UIFCPY)) ? 1UL : 0UL);
  2166. }
  2167. /**
  2168. * @brief Enable dithering.
  2169. * @note Macro IS_TIM_DITHERING_INSTANCE(TIMx) can be used to check whether or not
  2170. * a timer instance provides dithering.
  2171. * @rmtoll CR1 DITHEN LL_TIM_EnableDithering
  2172. * @param TIMx Timer instance
  2173. * @retval None
  2174. */
  2175. __STATIC_INLINE void LL_TIM_EnableDithering(TIM_TypeDef *TIMx)
  2176. {
  2177. SET_BIT(TIMx->CR1, TIM_CR1_DITHEN);
  2178. }
  2179. /**
  2180. * @brief Disable dithering.
  2181. * @note Macro IS_TIM_DITHERING_INSTANCE(TIMx) can be used to check whether or not
  2182. * a timer instance provides dithering.
  2183. * @rmtoll CR1 DITHEN LL_TIM_DisableDithering
  2184. * @param TIMx Timer instance
  2185. * @retval None
  2186. */
  2187. __STATIC_INLINE void LL_TIM_DisableDithering(TIM_TypeDef *TIMx)
  2188. {
  2189. CLEAR_BIT(TIMx->CR1, TIM_CR1_DITHEN);
  2190. }
  2191. /**
  2192. * @brief Indicates whether dithering is activated.
  2193. * @note Macro IS_TIM_DITHERING_INSTANCE(TIMx) can be used to check whether or not
  2194. * a timer instance provides dithering.
  2195. * @rmtoll CR1 DITHEN LL_TIM_IsEnabledDithering
  2196. * @param TIMx Timer instance
  2197. * @retval State of bit (1 or 0).
  2198. */
  2199. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDithering(const TIM_TypeDef *TIMx)
  2200. {
  2201. return ((READ_BIT(TIMx->CR1, TIM_CR1_DITHEN) == (TIM_CR1_DITHEN)) ? 1UL : 0UL);
  2202. }
  2203. /**
  2204. * @}
  2205. */
  2206. /** @defgroup TIM_LL_EF_Capture_Compare Capture Compare configuration
  2207. * @{
  2208. */
  2209. /**
  2210. * @brief Enable the capture/compare control bits (CCxE, CCxNE and OCxM) preload.
  2211. * @note CCxE, CCxNE and OCxM bits are preloaded, after having been written,
  2212. * they are updated only when a commutation event (COM) occurs.
  2213. * @note Only on channels that have a complementary output.
  2214. * @note Macro IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
  2215. * whether or not a timer instance is able to generate a commutation event.
  2216. * @rmtoll CR2 CCPC LL_TIM_CC_EnablePreload
  2217. * @param TIMx Timer instance
  2218. * @retval None
  2219. */
  2220. __STATIC_INLINE void LL_TIM_CC_EnablePreload(TIM_TypeDef *TIMx)
  2221. {
  2222. SET_BIT(TIMx->CR2, TIM_CR2_CCPC);
  2223. }
  2224. /**
  2225. * @brief Disable the capture/compare control bits (CCxE, CCxNE and OCxM) preload.
  2226. * @note Macro IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
  2227. * whether or not a timer instance is able to generate a commutation event.
  2228. * @rmtoll CR2 CCPC LL_TIM_CC_DisablePreload
  2229. * @param TIMx Timer instance
  2230. * @retval None
  2231. */
  2232. __STATIC_INLINE void LL_TIM_CC_DisablePreload(TIM_TypeDef *TIMx)
  2233. {
  2234. CLEAR_BIT(TIMx->CR2, TIM_CR2_CCPC);
  2235. }
  2236. /**
  2237. * @brief Indicates whether the capture/compare control bits (CCxE, CCxNE and OCxM) preload is enabled.
  2238. * @rmtoll CR2 CCPC LL_TIM_CC_IsEnabledPreload
  2239. * @param TIMx Timer instance
  2240. * @retval State of bit (1 or 0).
  2241. */
  2242. __STATIC_INLINE uint32_t LL_TIM_CC_IsEnabledPreload(const TIM_TypeDef *TIMx)
  2243. {
  2244. return ((READ_BIT(TIMx->CR2, TIM_CR2_CCPC) == (TIM_CR2_CCPC)) ? 1UL : 0UL);
  2245. }
  2246. /**
  2247. * @brief Set the updated source of the capture/compare control bits (CCxE, CCxNE and OCxM).
  2248. * @note Macro IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
  2249. * whether or not a timer instance is able to generate a commutation event.
  2250. * @rmtoll CR2 CCUS LL_TIM_CC_SetUpdate
  2251. * @param TIMx Timer instance
  2252. * @param CCUpdateSource This parameter can be one of the following values:
  2253. * @arg @ref LL_TIM_CCUPDATESOURCE_COMG_ONLY
  2254. * @arg @ref LL_TIM_CCUPDATESOURCE_COMG_AND_TRGI
  2255. * @retval None
  2256. */
  2257. __STATIC_INLINE void LL_TIM_CC_SetUpdate(TIM_TypeDef *TIMx, uint32_t CCUpdateSource)
  2258. {
  2259. MODIFY_REG(TIMx->CR2, TIM_CR2_CCUS, CCUpdateSource);
  2260. }
  2261. /**
  2262. * @brief Set the trigger of the capture/compare DMA request.
  2263. * @rmtoll CR2 CCDS LL_TIM_CC_SetDMAReqTrigger
  2264. * @param TIMx Timer instance
  2265. * @param DMAReqTrigger This parameter can be one of the following values:
  2266. * @arg @ref LL_TIM_CCDMAREQUEST_CC
  2267. * @arg @ref LL_TIM_CCDMAREQUEST_UPDATE
  2268. * @retval None
  2269. */
  2270. __STATIC_INLINE void LL_TIM_CC_SetDMAReqTrigger(TIM_TypeDef *TIMx, uint32_t DMAReqTrigger)
  2271. {
  2272. MODIFY_REG(TIMx->CR2, TIM_CR2_CCDS, DMAReqTrigger);
  2273. }
  2274. /**
  2275. * @brief Get actual trigger of the capture/compare DMA request.
  2276. * @rmtoll CR2 CCDS LL_TIM_CC_GetDMAReqTrigger
  2277. * @param TIMx Timer instance
  2278. * @retval Returned value can be one of the following values:
  2279. * @arg @ref LL_TIM_CCDMAREQUEST_CC
  2280. * @arg @ref LL_TIM_CCDMAREQUEST_UPDATE
  2281. */
  2282. __STATIC_INLINE uint32_t LL_TIM_CC_GetDMAReqTrigger(const TIM_TypeDef *TIMx)
  2283. {
  2284. return (uint32_t)(READ_BIT(TIMx->CR2, TIM_CR2_CCDS));
  2285. }
  2286. /**
  2287. * @brief Set the lock level to freeze the
  2288. * configuration of several capture/compare parameters.
  2289. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2290. * the lock mechanism is supported by a timer instance.
  2291. * @rmtoll BDTR LOCK LL_TIM_CC_SetLockLevel
  2292. * @param TIMx Timer instance
  2293. * @param LockLevel This parameter can be one of the following values:
  2294. * @arg @ref LL_TIM_LOCKLEVEL_OFF
  2295. * @arg @ref LL_TIM_LOCKLEVEL_1
  2296. * @arg @ref LL_TIM_LOCKLEVEL_2
  2297. * @arg @ref LL_TIM_LOCKLEVEL_3
  2298. * @retval None
  2299. */
  2300. __STATIC_INLINE void LL_TIM_CC_SetLockLevel(TIM_TypeDef *TIMx, uint32_t LockLevel)
  2301. {
  2302. MODIFY_REG(TIMx->BDTR, TIM_BDTR_LOCK, LockLevel);
  2303. }
  2304. /**
  2305. * @brief Enable capture/compare channels.
  2306. * @rmtoll CCER CC1E LL_TIM_CC_EnableChannel\n
  2307. * CCER CC1NE LL_TIM_CC_EnableChannel\n
  2308. * CCER CC2E LL_TIM_CC_EnableChannel\n
  2309. * CCER CC2NE LL_TIM_CC_EnableChannel\n
  2310. * CCER CC3E LL_TIM_CC_EnableChannel\n
  2311. * CCER CC3NE LL_TIM_CC_EnableChannel\n
  2312. * CCER CC4E LL_TIM_CC_EnableChannel\n
  2313. * CCER CC4NE LL_TIM_CC_EnableChannel\n
  2314. * CCER CC5E LL_TIM_CC_EnableChannel\n
  2315. * CCER CC6E LL_TIM_CC_EnableChannel
  2316. * @param TIMx Timer instance
  2317. * @param Channels This parameter can be a combination of the following values:
  2318. * @arg @ref LL_TIM_CHANNEL_CH1
  2319. * @arg @ref LL_TIM_CHANNEL_CH1N
  2320. * @arg @ref LL_TIM_CHANNEL_CH2
  2321. * @arg @ref LL_TIM_CHANNEL_CH2N
  2322. * @arg @ref LL_TIM_CHANNEL_CH3
  2323. * @arg @ref LL_TIM_CHANNEL_CH3N
  2324. * @arg @ref LL_TIM_CHANNEL_CH4
  2325. * @arg @ref LL_TIM_CHANNEL_CH4N
  2326. * @arg @ref LL_TIM_CHANNEL_CH5
  2327. * @arg @ref LL_TIM_CHANNEL_CH6
  2328. * @retval None
  2329. */
  2330. __STATIC_INLINE void LL_TIM_CC_EnableChannel(TIM_TypeDef *TIMx, uint32_t Channels)
  2331. {
  2332. SET_BIT(TIMx->CCER, Channels);
  2333. }
  2334. /**
  2335. * @brief Disable capture/compare channels.
  2336. * @rmtoll CCER CC1E LL_TIM_CC_DisableChannel\n
  2337. * CCER CC1NE LL_TIM_CC_DisableChannel\n
  2338. * CCER CC2E LL_TIM_CC_DisableChannel\n
  2339. * CCER CC2NE LL_TIM_CC_DisableChannel\n
  2340. * CCER CC3E LL_TIM_CC_DisableChannel\n
  2341. * CCER CC3NE LL_TIM_CC_DisableChannel\n
  2342. * CCER CC4E LL_TIM_CC_DisableChannel\n
  2343. * CCER CC4NE LL_TIM_CC_DisableChannel\n
  2344. * CCER CC5E LL_TIM_CC_DisableChannel\n
  2345. * CCER CC6E LL_TIM_CC_DisableChannel
  2346. * @param TIMx Timer instance
  2347. * @param Channels This parameter can be a combination of the following values:
  2348. * @arg @ref LL_TIM_CHANNEL_CH1
  2349. * @arg @ref LL_TIM_CHANNEL_CH1N
  2350. * @arg @ref LL_TIM_CHANNEL_CH2
  2351. * @arg @ref LL_TIM_CHANNEL_CH2N
  2352. * @arg @ref LL_TIM_CHANNEL_CH3
  2353. * @arg @ref LL_TIM_CHANNEL_CH3N
  2354. * @arg @ref LL_TIM_CHANNEL_CH4
  2355. * @arg @ref LL_TIM_CHANNEL_CH4N
  2356. * @arg @ref LL_TIM_CHANNEL_CH5
  2357. * @arg @ref LL_TIM_CHANNEL_CH6
  2358. * @retval None
  2359. */
  2360. __STATIC_INLINE void LL_TIM_CC_DisableChannel(TIM_TypeDef *TIMx, uint32_t Channels)
  2361. {
  2362. CLEAR_BIT(TIMx->CCER, Channels);
  2363. }
  2364. /**
  2365. * @brief Indicate whether channel(s) is(are) enabled.
  2366. * @rmtoll CCER CC1E LL_TIM_CC_IsEnabledChannel\n
  2367. * CCER CC1NE LL_TIM_CC_IsEnabledChannel\n
  2368. * CCER CC2E LL_TIM_CC_IsEnabledChannel\n
  2369. * CCER CC2NE LL_TIM_CC_IsEnabledChannel\n
  2370. * CCER CC3E LL_TIM_CC_IsEnabledChannel\n
  2371. * CCER CC3NE LL_TIM_CC_IsEnabledChannel\n
  2372. * CCER CC4E LL_TIM_CC_IsEnabledChannel\n
  2373. * CCER CC4NE LL_TIM_CC_IsEnabledChannel\n
  2374. * CCER CC5E LL_TIM_CC_IsEnabledChannel\n
  2375. * CCER CC6E LL_TIM_CC_IsEnabledChannel
  2376. * @param TIMx Timer instance
  2377. * @param Channels This parameter can be a combination of the following values:
  2378. * @arg @ref LL_TIM_CHANNEL_CH1
  2379. * @arg @ref LL_TIM_CHANNEL_CH1N
  2380. * @arg @ref LL_TIM_CHANNEL_CH2
  2381. * @arg @ref LL_TIM_CHANNEL_CH2N
  2382. * @arg @ref LL_TIM_CHANNEL_CH3
  2383. * @arg @ref LL_TIM_CHANNEL_CH3N
  2384. * @arg @ref LL_TIM_CHANNEL_CH4
  2385. * @arg @ref LL_TIM_CHANNEL_CH4N
  2386. * @arg @ref LL_TIM_CHANNEL_CH5
  2387. * @arg @ref LL_TIM_CHANNEL_CH6
  2388. * @retval State of bit (1 or 0).
  2389. */
  2390. __STATIC_INLINE uint32_t LL_TIM_CC_IsEnabledChannel(const TIM_TypeDef *TIMx, uint32_t Channels)
  2391. {
  2392. return ((READ_BIT(TIMx->CCER, Channels) == (Channels)) ? 1UL : 0UL);
  2393. }
  2394. /**
  2395. * @}
  2396. */
  2397. /** @defgroup TIM_LL_EF_Output_Channel Output channel configuration
  2398. * @{
  2399. */
  2400. /**
  2401. * @brief Configure an output channel.
  2402. * @rmtoll CCMR1 CC1S LL_TIM_OC_ConfigOutput\n
  2403. * CCMR1 CC2S LL_TIM_OC_ConfigOutput\n
  2404. * CCMR2 CC3S LL_TIM_OC_ConfigOutput\n
  2405. * CCMR2 CC4S LL_TIM_OC_ConfigOutput\n
  2406. * CCMR3 CC5S LL_TIM_OC_ConfigOutput\n
  2407. * CCMR3 CC6S LL_TIM_OC_ConfigOutput\n
  2408. * CCER CC1P LL_TIM_OC_ConfigOutput\n
  2409. * CCER CC2P LL_TIM_OC_ConfigOutput\n
  2410. * CCER CC3P LL_TIM_OC_ConfigOutput\n
  2411. * CCER CC4P LL_TIM_OC_ConfigOutput\n
  2412. * CCER CC5P LL_TIM_OC_ConfigOutput\n
  2413. * CCER CC6P LL_TIM_OC_ConfigOutput\n
  2414. * CR2 OIS1 LL_TIM_OC_ConfigOutput\n
  2415. * CR2 OIS2 LL_TIM_OC_ConfigOutput\n
  2416. * CR2 OIS3 LL_TIM_OC_ConfigOutput\n
  2417. * CR2 OIS4 LL_TIM_OC_ConfigOutput\n
  2418. * CR2 OIS5 LL_TIM_OC_ConfigOutput\n
  2419. * CR2 OIS6 LL_TIM_OC_ConfigOutput
  2420. * @param TIMx Timer instance
  2421. * @param Channel This parameter can be one of the following values:
  2422. * @arg @ref LL_TIM_CHANNEL_CH1
  2423. * @arg @ref LL_TIM_CHANNEL_CH2
  2424. * @arg @ref LL_TIM_CHANNEL_CH3
  2425. * @arg @ref LL_TIM_CHANNEL_CH4
  2426. * @arg @ref LL_TIM_CHANNEL_CH5
  2427. * @arg @ref LL_TIM_CHANNEL_CH6
  2428. * @param Configuration This parameter must be a combination of all the following values:
  2429. * @arg @ref LL_TIM_OCPOLARITY_HIGH or @ref LL_TIM_OCPOLARITY_LOW
  2430. * @arg @ref LL_TIM_OCIDLESTATE_LOW or @ref LL_TIM_OCIDLESTATE_HIGH
  2431. * @retval None
  2432. */
  2433. __STATIC_INLINE void LL_TIM_OC_ConfigOutput(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Configuration)
  2434. {
  2435. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2436. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2437. CLEAR_BIT(*pReg, (TIM_CCMR1_CC1S << SHIFT_TAB_OCxx[iChannel]));
  2438. MODIFY_REG(TIMx->CCER, (TIM_CCER_CC1P << SHIFT_TAB_CCxP[iChannel]),
  2439. (Configuration & TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel]);
  2440. MODIFY_REG(TIMx->CR2, (TIM_CR2_OIS1 << SHIFT_TAB_OISx[iChannel]),
  2441. (Configuration & TIM_CR2_OIS1) << SHIFT_TAB_OISx[iChannel]);
  2442. }
  2443. /**
  2444. * @brief Define the behavior of the output reference signal OCxREF from which
  2445. * OCx and OCxN (when relevant) are derived.
  2446. * @rmtoll CCMR1 OC1M LL_TIM_OC_SetMode\n
  2447. * CCMR1 OC2M LL_TIM_OC_SetMode\n
  2448. * CCMR2 OC3M LL_TIM_OC_SetMode\n
  2449. * CCMR2 OC4M LL_TIM_OC_SetMode\n
  2450. * CCMR3 OC5M LL_TIM_OC_SetMode\n
  2451. * CCMR3 OC6M LL_TIM_OC_SetMode
  2452. * @param TIMx Timer instance
  2453. * @param Channel This parameter can be one of the following values:
  2454. * @arg @ref LL_TIM_CHANNEL_CH1
  2455. * @arg @ref LL_TIM_CHANNEL_CH2
  2456. * @arg @ref LL_TIM_CHANNEL_CH3
  2457. * @arg @ref LL_TIM_CHANNEL_CH4
  2458. * @arg @ref LL_TIM_CHANNEL_CH5
  2459. * @arg @ref LL_TIM_CHANNEL_CH6
  2460. * @param Mode This parameter can be one of the following values:
  2461. * @arg @ref LL_TIM_OCMODE_FROZEN
  2462. * @arg @ref LL_TIM_OCMODE_ACTIVE
  2463. * @arg @ref LL_TIM_OCMODE_INACTIVE
  2464. * @arg @ref LL_TIM_OCMODE_TOGGLE
  2465. * @arg @ref LL_TIM_OCMODE_FORCED_INACTIVE
  2466. * @arg @ref LL_TIM_OCMODE_FORCED_ACTIVE
  2467. * @arg @ref LL_TIM_OCMODE_PWM1
  2468. * @arg @ref LL_TIM_OCMODE_PWM2
  2469. * @arg @ref LL_TIM_OCMODE_RETRIG_OPM1
  2470. * @arg @ref LL_TIM_OCMODE_RETRIG_OPM2
  2471. * @arg @ref LL_TIM_OCMODE_COMBINED_PWM1
  2472. * @arg @ref LL_TIM_OCMODE_COMBINED_PWM2
  2473. * @arg @ref LL_TIM_OCMODE_ASYMMETRIC_PWM1
  2474. * @arg @ref LL_TIM_OCMODE_ASYMMETRIC_PWM2
  2475. * @arg @ref LL_TIM_OCMODE_PULSE_ON_COMPARE (for channel 3 or channel 4 only)
  2476. * @arg @ref LL_TIM_OCMODE_DIRECTION_OUTPUT (for channel 3 or channel 4 only)
  2477. * @retval None
  2478. */
  2479. __STATIC_INLINE void LL_TIM_OC_SetMode(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Mode)
  2480. {
  2481. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2482. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2483. MODIFY_REG(*pReg, ((TIM_CCMR1_OC1M | TIM_CCMR1_CC1S) << SHIFT_TAB_OCxx[iChannel]), Mode << SHIFT_TAB_OCxx[iChannel]);
  2484. }
  2485. /**
  2486. * @brief Get the output compare mode of an output channel.
  2487. * @rmtoll CCMR1 OC1M LL_TIM_OC_GetMode\n
  2488. * CCMR1 OC2M LL_TIM_OC_GetMode\n
  2489. * CCMR2 OC3M LL_TIM_OC_GetMode\n
  2490. * CCMR2 OC4M LL_TIM_OC_GetMode\n
  2491. * CCMR3 OC5M LL_TIM_OC_GetMode\n
  2492. * CCMR3 OC6M LL_TIM_OC_GetMode
  2493. * @param TIMx Timer instance
  2494. * @param Channel This parameter can be one of the following values:
  2495. * @arg @ref LL_TIM_CHANNEL_CH1
  2496. * @arg @ref LL_TIM_CHANNEL_CH2
  2497. * @arg @ref LL_TIM_CHANNEL_CH3
  2498. * @arg @ref LL_TIM_CHANNEL_CH4
  2499. * @arg @ref LL_TIM_CHANNEL_CH5
  2500. * @arg @ref LL_TIM_CHANNEL_CH6
  2501. * @retval Returned value can be one of the following values:
  2502. * @arg @ref LL_TIM_OCMODE_FROZEN
  2503. * @arg @ref LL_TIM_OCMODE_ACTIVE
  2504. * @arg @ref LL_TIM_OCMODE_INACTIVE
  2505. * @arg @ref LL_TIM_OCMODE_TOGGLE
  2506. * @arg @ref LL_TIM_OCMODE_FORCED_INACTIVE
  2507. * @arg @ref LL_TIM_OCMODE_FORCED_ACTIVE
  2508. * @arg @ref LL_TIM_OCMODE_PWM1
  2509. * @arg @ref LL_TIM_OCMODE_PWM2
  2510. * @arg @ref LL_TIM_OCMODE_RETRIG_OPM1
  2511. * @arg @ref LL_TIM_OCMODE_RETRIG_OPM2
  2512. * @arg @ref LL_TIM_OCMODE_COMBINED_PWM1
  2513. * @arg @ref LL_TIM_OCMODE_COMBINED_PWM2
  2514. * @arg @ref LL_TIM_OCMODE_ASYMMETRIC_PWM1
  2515. * @arg @ref LL_TIM_OCMODE_ASYMMETRIC_PWM2
  2516. * @arg @ref LL_TIM_OCMODE_PULSE_ON_COMPARE (for channel 3 or channel 4 only)
  2517. * @arg @ref LL_TIM_OCMODE_DIRECTION_OUTPUT (for channel 3 or channel 4 only)
  2518. */
  2519. __STATIC_INLINE uint32_t LL_TIM_OC_GetMode(const TIM_TypeDef *TIMx, uint32_t Channel)
  2520. {
  2521. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2522. const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2523. return (READ_BIT(*pReg, ((TIM_CCMR1_OC1M | TIM_CCMR1_CC1S) << SHIFT_TAB_OCxx[iChannel])) >> SHIFT_TAB_OCxx[iChannel]);
  2524. }
  2525. /**
  2526. * @brief Set the polarity of an output channel.
  2527. * @rmtoll CCER CC1P LL_TIM_OC_SetPolarity\n
  2528. * CCER CC1NP LL_TIM_OC_SetPolarity\n
  2529. * CCER CC2P LL_TIM_OC_SetPolarity\n
  2530. * CCER CC2NP LL_TIM_OC_SetPolarity\n
  2531. * CCER CC3P LL_TIM_OC_SetPolarity\n
  2532. * CCER CC3NP LL_TIM_OC_SetPolarity\n
  2533. * CCER CC4P LL_TIM_OC_SetPolarity\n
  2534. * CCER CC4NP LL_TIM_OC_SetPolarity\n
  2535. * CCER CC5P LL_TIM_OC_SetPolarity\n
  2536. * CCER CC6P LL_TIM_OC_SetPolarity
  2537. * @param TIMx Timer instance
  2538. * @param Channel This parameter can be one of the following values:
  2539. * @arg @ref LL_TIM_CHANNEL_CH1
  2540. * @arg @ref LL_TIM_CHANNEL_CH1N
  2541. * @arg @ref LL_TIM_CHANNEL_CH2
  2542. * @arg @ref LL_TIM_CHANNEL_CH2N
  2543. * @arg @ref LL_TIM_CHANNEL_CH3
  2544. * @arg @ref LL_TIM_CHANNEL_CH3N
  2545. * @arg @ref LL_TIM_CHANNEL_CH4
  2546. * @arg @ref LL_TIM_CHANNEL_CH4N
  2547. * @arg @ref LL_TIM_CHANNEL_CH5
  2548. * @arg @ref LL_TIM_CHANNEL_CH6
  2549. * @param Polarity This parameter can be one of the following values:
  2550. * @arg @ref LL_TIM_OCPOLARITY_HIGH
  2551. * @arg @ref LL_TIM_OCPOLARITY_LOW
  2552. * @retval None
  2553. */
  2554. __STATIC_INLINE void LL_TIM_OC_SetPolarity(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Polarity)
  2555. {
  2556. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2557. MODIFY_REG(TIMx->CCER, (TIM_CCER_CC1P << SHIFT_TAB_CCxP[iChannel]), Polarity << SHIFT_TAB_CCxP[iChannel]);
  2558. }
  2559. /**
  2560. * @brief Get the polarity of an output channel.
  2561. * @rmtoll CCER CC1P LL_TIM_OC_GetPolarity\n
  2562. * CCER CC1NP LL_TIM_OC_GetPolarity\n
  2563. * CCER CC2P LL_TIM_OC_GetPolarity\n
  2564. * CCER CC2NP LL_TIM_OC_GetPolarity\n
  2565. * CCER CC3P LL_TIM_OC_GetPolarity\n
  2566. * CCER CC3NP LL_TIM_OC_GetPolarity\n
  2567. * CCER CC4P LL_TIM_OC_GetPolarity\n
  2568. * CCER CC4NP LL_TIM_OC_GetPolarity\n
  2569. * CCER CC5P LL_TIM_OC_GetPolarity\n
  2570. * CCER CC6P LL_TIM_OC_GetPolarity
  2571. * @param TIMx Timer instance
  2572. * @param Channel This parameter can be one of the following values:
  2573. * @arg @ref LL_TIM_CHANNEL_CH1
  2574. * @arg @ref LL_TIM_CHANNEL_CH1N
  2575. * @arg @ref LL_TIM_CHANNEL_CH2
  2576. * @arg @ref LL_TIM_CHANNEL_CH2N
  2577. * @arg @ref LL_TIM_CHANNEL_CH3
  2578. * @arg @ref LL_TIM_CHANNEL_CH3N
  2579. * @arg @ref LL_TIM_CHANNEL_CH4
  2580. * @arg @ref LL_TIM_CHANNEL_CH4N
  2581. * @arg @ref LL_TIM_CHANNEL_CH5
  2582. * @arg @ref LL_TIM_CHANNEL_CH6
  2583. * @retval Returned value can be one of the following values:
  2584. * @arg @ref LL_TIM_OCPOLARITY_HIGH
  2585. * @arg @ref LL_TIM_OCPOLARITY_LOW
  2586. */
  2587. __STATIC_INLINE uint32_t LL_TIM_OC_GetPolarity(const TIM_TypeDef *TIMx, uint32_t Channel)
  2588. {
  2589. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2590. return (READ_BIT(TIMx->CCER, (TIM_CCER_CC1P << SHIFT_TAB_CCxP[iChannel])) >> SHIFT_TAB_CCxP[iChannel]);
  2591. }
  2592. /**
  2593. * @brief Set the IDLE state of an output channel
  2594. * @note This function is significant only for the timer instances
  2595. * supporting the break feature. Macro IS_TIM_BREAK_INSTANCE(TIMx)
  2596. * can be used to check whether or not a timer instance provides
  2597. * a break input.
  2598. * @rmtoll CR2 OIS1 LL_TIM_OC_SetIdleState\n
  2599. * CR2 OIS2N LL_TIM_OC_SetIdleState\n
  2600. * CR2 OIS2 LL_TIM_OC_SetIdleState\n
  2601. * CR2 OIS2N LL_TIM_OC_SetIdleState\n
  2602. * CR2 OIS3 LL_TIM_OC_SetIdleState\n
  2603. * CR2 OIS3N LL_TIM_OC_SetIdleState\n
  2604. * CR2 OIS4 LL_TIM_OC_SetIdleState\n
  2605. * CR2 OIS4N LL_TIM_OC_SetIdleState\n
  2606. * CR2 OIS5 LL_TIM_OC_SetIdleState\n
  2607. * CR2 OIS6 LL_TIM_OC_SetIdleState
  2608. * @param TIMx Timer instance
  2609. * @param Channel This parameter can be one of the following values:
  2610. * @arg @ref LL_TIM_CHANNEL_CH1
  2611. * @arg @ref LL_TIM_CHANNEL_CH1N
  2612. * @arg @ref LL_TIM_CHANNEL_CH2
  2613. * @arg @ref LL_TIM_CHANNEL_CH2N
  2614. * @arg @ref LL_TIM_CHANNEL_CH3
  2615. * @arg @ref LL_TIM_CHANNEL_CH3N
  2616. * @arg @ref LL_TIM_CHANNEL_CH4
  2617. * @arg @ref LL_TIM_CHANNEL_CH4N
  2618. * @arg @ref LL_TIM_CHANNEL_CH5
  2619. * @arg @ref LL_TIM_CHANNEL_CH6
  2620. * @param IdleState This parameter can be one of the following values:
  2621. * @arg @ref LL_TIM_OCIDLESTATE_LOW
  2622. * @arg @ref LL_TIM_OCIDLESTATE_HIGH
  2623. * @retval None
  2624. */
  2625. __STATIC_INLINE void LL_TIM_OC_SetIdleState(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t IdleState)
  2626. {
  2627. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2628. MODIFY_REG(TIMx->CR2, (TIM_CR2_OIS1 << SHIFT_TAB_OISx[iChannel]), IdleState << SHIFT_TAB_OISx[iChannel]);
  2629. }
  2630. /**
  2631. * @brief Get the IDLE state of an output channel
  2632. * @rmtoll CR2 OIS1 LL_TIM_OC_GetIdleState\n
  2633. * CR2 OIS2N LL_TIM_OC_GetIdleState\n
  2634. * CR2 OIS2 LL_TIM_OC_GetIdleState\n
  2635. * CR2 OIS2N LL_TIM_OC_GetIdleState\n
  2636. * CR2 OIS3 LL_TIM_OC_GetIdleState\n
  2637. * CR2 OIS3N LL_TIM_OC_GetIdleState\n
  2638. * CR2 OIS4 LL_TIM_OC_GetIdleState\n
  2639. * CR2 OIS4N LL_TIM_OC_GetIdleState\n
  2640. * CR2 OIS5 LL_TIM_OC_GetIdleState\n
  2641. * CR2 OIS6 LL_TIM_OC_GetIdleState
  2642. * @param TIMx Timer instance
  2643. * @param Channel This parameter can be one of the following values:
  2644. * @arg @ref LL_TIM_CHANNEL_CH1
  2645. * @arg @ref LL_TIM_CHANNEL_CH1N
  2646. * @arg @ref LL_TIM_CHANNEL_CH2
  2647. * @arg @ref LL_TIM_CHANNEL_CH2N
  2648. * @arg @ref LL_TIM_CHANNEL_CH3
  2649. * @arg @ref LL_TIM_CHANNEL_CH3N
  2650. * @arg @ref LL_TIM_CHANNEL_CH4
  2651. * @arg @ref LL_TIM_CHANNEL_CH4N
  2652. * @arg @ref LL_TIM_CHANNEL_CH5
  2653. * @arg @ref LL_TIM_CHANNEL_CH6
  2654. * @retval Returned value can be one of the following values:
  2655. * @arg @ref LL_TIM_OCIDLESTATE_LOW
  2656. * @arg @ref LL_TIM_OCIDLESTATE_HIGH
  2657. */
  2658. __STATIC_INLINE uint32_t LL_TIM_OC_GetIdleState(const TIM_TypeDef *TIMx, uint32_t Channel)
  2659. {
  2660. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2661. return (READ_BIT(TIMx->CR2, (TIM_CR2_OIS1 << SHIFT_TAB_OISx[iChannel])) >> SHIFT_TAB_OISx[iChannel]);
  2662. }
  2663. /**
  2664. * @brief Enable fast mode for the output channel.
  2665. * @note Acts only if the channel is configured in PWM1 or PWM2 mode.
  2666. * @rmtoll CCMR1 OC1FE LL_TIM_OC_EnableFast\n
  2667. * CCMR1 OC2FE LL_TIM_OC_EnableFast\n
  2668. * CCMR2 OC3FE LL_TIM_OC_EnableFast\n
  2669. * CCMR2 OC4FE LL_TIM_OC_EnableFast\n
  2670. * CCMR3 OC5FE LL_TIM_OC_EnableFast\n
  2671. * CCMR3 OC6FE LL_TIM_OC_EnableFast
  2672. * @param TIMx Timer instance
  2673. * @param Channel This parameter can be one of the following values:
  2674. * @arg @ref LL_TIM_CHANNEL_CH1
  2675. * @arg @ref LL_TIM_CHANNEL_CH2
  2676. * @arg @ref LL_TIM_CHANNEL_CH3
  2677. * @arg @ref LL_TIM_CHANNEL_CH4
  2678. * @arg @ref LL_TIM_CHANNEL_CH5
  2679. * @arg @ref LL_TIM_CHANNEL_CH6
  2680. * @retval None
  2681. */
  2682. __STATIC_INLINE void LL_TIM_OC_EnableFast(TIM_TypeDef *TIMx, uint32_t Channel)
  2683. {
  2684. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2685. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2686. SET_BIT(*pReg, (TIM_CCMR1_OC1FE << SHIFT_TAB_OCxx[iChannel]));
  2687. }
  2688. /**
  2689. * @brief Disable fast mode for the output channel.
  2690. * @rmtoll CCMR1 OC1FE LL_TIM_OC_DisableFast\n
  2691. * CCMR1 OC2FE LL_TIM_OC_DisableFast\n
  2692. * CCMR2 OC3FE LL_TIM_OC_DisableFast\n
  2693. * CCMR2 OC4FE LL_TIM_OC_DisableFast\n
  2694. * CCMR3 OC5FE LL_TIM_OC_DisableFast\n
  2695. * CCMR3 OC6FE LL_TIM_OC_DisableFast
  2696. * @param TIMx Timer instance
  2697. * @param Channel This parameter can be one of the following values:
  2698. * @arg @ref LL_TIM_CHANNEL_CH1
  2699. * @arg @ref LL_TIM_CHANNEL_CH2
  2700. * @arg @ref LL_TIM_CHANNEL_CH3
  2701. * @arg @ref LL_TIM_CHANNEL_CH4
  2702. * @arg @ref LL_TIM_CHANNEL_CH5
  2703. * @arg @ref LL_TIM_CHANNEL_CH6
  2704. * @retval None
  2705. */
  2706. __STATIC_INLINE void LL_TIM_OC_DisableFast(TIM_TypeDef *TIMx, uint32_t Channel)
  2707. {
  2708. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2709. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2710. CLEAR_BIT(*pReg, (TIM_CCMR1_OC1FE << SHIFT_TAB_OCxx[iChannel]));
  2711. }
  2712. /**
  2713. * @brief Indicates whether fast mode is enabled for the output channel.
  2714. * @rmtoll CCMR1 OC1FE LL_TIM_OC_IsEnabledFast\n
  2715. * CCMR1 OC2FE LL_TIM_OC_IsEnabledFast\n
  2716. * CCMR2 OC3FE LL_TIM_OC_IsEnabledFast\n
  2717. * CCMR2 OC4FE LL_TIM_OC_IsEnabledFast\n
  2718. * CCMR3 OC5FE LL_TIM_OC_IsEnabledFast\n
  2719. * CCMR3 OC6FE LL_TIM_OC_IsEnabledFast
  2720. * @param TIMx Timer instance
  2721. * @param Channel This parameter can be one of the following values:
  2722. * @arg @ref LL_TIM_CHANNEL_CH1
  2723. * @arg @ref LL_TIM_CHANNEL_CH2
  2724. * @arg @ref LL_TIM_CHANNEL_CH3
  2725. * @arg @ref LL_TIM_CHANNEL_CH4
  2726. * @arg @ref LL_TIM_CHANNEL_CH5
  2727. * @arg @ref LL_TIM_CHANNEL_CH6
  2728. * @retval State of bit (1 or 0).
  2729. */
  2730. __STATIC_INLINE uint32_t LL_TIM_OC_IsEnabledFast(const TIM_TypeDef *TIMx, uint32_t Channel)
  2731. {
  2732. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2733. const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2734. uint32_t bitfield = TIM_CCMR1_OC1FE << SHIFT_TAB_OCxx[iChannel];
  2735. return ((READ_BIT(*pReg, bitfield) == bitfield) ? 1UL : 0UL);
  2736. }
  2737. /**
  2738. * @brief Enable compare register (TIMx_CCRx) preload for the output channel.
  2739. * @rmtoll CCMR1 OC1PE LL_TIM_OC_EnablePreload\n
  2740. * CCMR1 OC2PE LL_TIM_OC_EnablePreload\n
  2741. * CCMR2 OC3PE LL_TIM_OC_EnablePreload\n
  2742. * CCMR2 OC4PE LL_TIM_OC_EnablePreload\n
  2743. * CCMR3 OC5PE LL_TIM_OC_EnablePreload\n
  2744. * CCMR3 OC6PE LL_TIM_OC_EnablePreload
  2745. * @param TIMx Timer instance
  2746. * @param Channel This parameter can be one of the following values:
  2747. * @arg @ref LL_TIM_CHANNEL_CH1
  2748. * @arg @ref LL_TIM_CHANNEL_CH2
  2749. * @arg @ref LL_TIM_CHANNEL_CH3
  2750. * @arg @ref LL_TIM_CHANNEL_CH4
  2751. * @arg @ref LL_TIM_CHANNEL_CH5
  2752. * @arg @ref LL_TIM_CHANNEL_CH6
  2753. * @retval None
  2754. */
  2755. __STATIC_INLINE void LL_TIM_OC_EnablePreload(TIM_TypeDef *TIMx, uint32_t Channel)
  2756. {
  2757. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2758. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2759. SET_BIT(*pReg, (TIM_CCMR1_OC1PE << SHIFT_TAB_OCxx[iChannel]));
  2760. }
  2761. /**
  2762. * @brief Disable compare register (TIMx_CCRx) preload for the output channel.
  2763. * @rmtoll CCMR1 OC1PE LL_TIM_OC_DisablePreload\n
  2764. * CCMR1 OC2PE LL_TIM_OC_DisablePreload\n
  2765. * CCMR2 OC3PE LL_TIM_OC_DisablePreload\n
  2766. * CCMR2 OC4PE LL_TIM_OC_DisablePreload\n
  2767. * CCMR3 OC5PE LL_TIM_OC_DisablePreload\n
  2768. * CCMR3 OC6PE LL_TIM_OC_DisablePreload
  2769. * @param TIMx Timer instance
  2770. * @param Channel This parameter can be one of the following values:
  2771. * @arg @ref LL_TIM_CHANNEL_CH1
  2772. * @arg @ref LL_TIM_CHANNEL_CH2
  2773. * @arg @ref LL_TIM_CHANNEL_CH3
  2774. * @arg @ref LL_TIM_CHANNEL_CH4
  2775. * @arg @ref LL_TIM_CHANNEL_CH5
  2776. * @arg @ref LL_TIM_CHANNEL_CH6
  2777. * @retval None
  2778. */
  2779. __STATIC_INLINE void LL_TIM_OC_DisablePreload(TIM_TypeDef *TIMx, uint32_t Channel)
  2780. {
  2781. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2782. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2783. CLEAR_BIT(*pReg, (TIM_CCMR1_OC1PE << SHIFT_TAB_OCxx[iChannel]));
  2784. }
  2785. /**
  2786. * @brief Indicates whether compare register (TIMx_CCRx) preload is enabled for the output channel.
  2787. * @rmtoll CCMR1 OC1PE LL_TIM_OC_IsEnabledPreload\n
  2788. * CCMR1 OC2PE LL_TIM_OC_IsEnabledPreload\n
  2789. * CCMR2 OC3PE LL_TIM_OC_IsEnabledPreload\n
  2790. * CCMR2 OC4PE LL_TIM_OC_IsEnabledPreload\n
  2791. * CCMR3 OC5PE LL_TIM_OC_IsEnabledPreload\n
  2792. * CCMR3 OC6PE LL_TIM_OC_IsEnabledPreload
  2793. * @param TIMx Timer instance
  2794. * @param Channel This parameter can be one of the following values:
  2795. * @arg @ref LL_TIM_CHANNEL_CH1
  2796. * @arg @ref LL_TIM_CHANNEL_CH2
  2797. * @arg @ref LL_TIM_CHANNEL_CH3
  2798. * @arg @ref LL_TIM_CHANNEL_CH4
  2799. * @arg @ref LL_TIM_CHANNEL_CH5
  2800. * @arg @ref LL_TIM_CHANNEL_CH6
  2801. * @retval State of bit (1 or 0).
  2802. */
  2803. __STATIC_INLINE uint32_t LL_TIM_OC_IsEnabledPreload(const TIM_TypeDef *TIMx, uint32_t Channel)
  2804. {
  2805. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2806. const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2807. uint32_t bitfield = TIM_CCMR1_OC1PE << SHIFT_TAB_OCxx[iChannel];
  2808. return ((READ_BIT(*pReg, bitfield) == bitfield) ? 1UL : 0UL);
  2809. }
  2810. /**
  2811. * @brief Enable clearing the output channel on an external event.
  2812. * @note This function can only be used in Output compare and PWM modes. It does not work in Forced mode.
  2813. * @note Macro IS_TIM_OCXREF_CLEAR_INSTANCE(TIMx) can be used to check whether
  2814. * or not a timer instance can clear the OCxREF signal on an external event.
  2815. * @rmtoll CCMR1 OC1CE LL_TIM_OC_EnableClear\n
  2816. * CCMR1 OC2CE LL_TIM_OC_EnableClear\n
  2817. * CCMR2 OC3CE LL_TIM_OC_EnableClear\n
  2818. * CCMR2 OC4CE LL_TIM_OC_EnableClear\n
  2819. * CCMR3 OC5CE LL_TIM_OC_EnableClear\n
  2820. * CCMR3 OC6CE LL_TIM_OC_EnableClear
  2821. * @param TIMx Timer instance
  2822. * @param Channel This parameter can be one of the following values:
  2823. * @arg @ref LL_TIM_CHANNEL_CH1
  2824. * @arg @ref LL_TIM_CHANNEL_CH2
  2825. * @arg @ref LL_TIM_CHANNEL_CH3
  2826. * @arg @ref LL_TIM_CHANNEL_CH4
  2827. * @arg @ref LL_TIM_CHANNEL_CH5
  2828. * @arg @ref LL_TIM_CHANNEL_CH6
  2829. * @retval None
  2830. */
  2831. __STATIC_INLINE void LL_TIM_OC_EnableClear(TIM_TypeDef *TIMx, uint32_t Channel)
  2832. {
  2833. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2834. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2835. SET_BIT(*pReg, (TIM_CCMR1_OC1CE << SHIFT_TAB_OCxx[iChannel]));
  2836. }
  2837. /**
  2838. * @brief Disable clearing the output channel on an external event.
  2839. * @note Macro IS_TIM_OCXREF_CLEAR_INSTANCE(TIMx) can be used to check whether
  2840. * or not a timer instance can clear the OCxREF signal on an external event.
  2841. * @rmtoll CCMR1 OC1CE LL_TIM_OC_DisableClear\n
  2842. * CCMR1 OC2CE LL_TIM_OC_DisableClear\n
  2843. * CCMR2 OC3CE LL_TIM_OC_DisableClear\n
  2844. * CCMR2 OC4CE LL_TIM_OC_DisableClear\n
  2845. * CCMR3 OC5CE LL_TIM_OC_DisableClear\n
  2846. * CCMR3 OC6CE LL_TIM_OC_DisableClear
  2847. * @param TIMx Timer instance
  2848. * @param Channel This parameter can be one of the following values:
  2849. * @arg @ref LL_TIM_CHANNEL_CH1
  2850. * @arg @ref LL_TIM_CHANNEL_CH2
  2851. * @arg @ref LL_TIM_CHANNEL_CH3
  2852. * @arg @ref LL_TIM_CHANNEL_CH4
  2853. * @arg @ref LL_TIM_CHANNEL_CH5
  2854. * @arg @ref LL_TIM_CHANNEL_CH6
  2855. * @retval None
  2856. */
  2857. __STATIC_INLINE void LL_TIM_OC_DisableClear(TIM_TypeDef *TIMx, uint32_t Channel)
  2858. {
  2859. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2860. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2861. CLEAR_BIT(*pReg, (TIM_CCMR1_OC1CE << SHIFT_TAB_OCxx[iChannel]));
  2862. }
  2863. /**
  2864. * @brief Indicates clearing the output channel on an external event is enabled for the output channel.
  2865. * @note This function enables clearing the output channel on an external event.
  2866. * @note This function can only be used in Output compare and PWM modes. It does not work in Forced mode.
  2867. * @note Macro IS_TIM_OCXREF_CLEAR_INSTANCE(TIMx) can be used to check whether
  2868. * or not a timer instance can clear the OCxREF signal on an external event.
  2869. * @rmtoll CCMR1 OC1CE LL_TIM_OC_IsEnabledClear\n
  2870. * CCMR1 OC2CE LL_TIM_OC_IsEnabledClear\n
  2871. * CCMR2 OC3CE LL_TIM_OC_IsEnabledClear\n
  2872. * CCMR2 OC4CE LL_TIM_OC_IsEnabledClear\n
  2873. * CCMR3 OC5CE LL_TIM_OC_IsEnabledClear\n
  2874. * CCMR3 OC6CE LL_TIM_OC_IsEnabledClear
  2875. * @param TIMx Timer instance
  2876. * @param Channel This parameter can be one of the following values:
  2877. * @arg @ref LL_TIM_CHANNEL_CH1
  2878. * @arg @ref LL_TIM_CHANNEL_CH2
  2879. * @arg @ref LL_TIM_CHANNEL_CH3
  2880. * @arg @ref LL_TIM_CHANNEL_CH4
  2881. * @arg @ref LL_TIM_CHANNEL_CH5
  2882. * @arg @ref LL_TIM_CHANNEL_CH6
  2883. * @retval State of bit (1 or 0).
  2884. */
  2885. __STATIC_INLINE uint32_t LL_TIM_OC_IsEnabledClear(const TIM_TypeDef *TIMx, uint32_t Channel)
  2886. {
  2887. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2888. const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2889. uint32_t bitfield = TIM_CCMR1_OC1CE << SHIFT_TAB_OCxx[iChannel];
  2890. return ((READ_BIT(*pReg, bitfield) == bitfield) ? 1UL : 0UL);
  2891. }
  2892. /**
  2893. * @brief Set the dead-time delay (delay inserted between the rising edge of the OCxREF signal and the rising edge of
  2894. * the Ocx and OCxN signals).
  2895. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2896. * dead-time insertion feature is supported by a timer instance.
  2897. * @note Helper macro @ref __LL_TIM_CALC_DEADTIME can be used to calculate the DeadTime parameter
  2898. * @rmtoll BDTR DTG LL_TIM_OC_SetDeadTime
  2899. * @param TIMx Timer instance
  2900. * @param DeadTime between Min_Data=0 and Max_Data=255
  2901. * @retval None
  2902. */
  2903. __STATIC_INLINE void LL_TIM_OC_SetDeadTime(TIM_TypeDef *TIMx, uint32_t DeadTime)
  2904. {
  2905. MODIFY_REG(TIMx->BDTR, TIM_BDTR_DTG, DeadTime);
  2906. }
  2907. /**
  2908. * @brief Set compare value for output channel 1 (TIMx_CCR1).
  2909. * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
  2910. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2911. * whether or not a timer instance supports a 32 bits counter.
  2912. * @note Macro IS_TIM_CC1_INSTANCE(TIMx) can be used to check whether or not
  2913. * output channel 1 is supported by a timer instance.
  2914. * @note If dithering is activated, CompareValue can be calculated with macro @ref __LL_TIM_CALC_DELAY_DITHER .
  2915. * @rmtoll CCR1 CCR1 LL_TIM_OC_SetCompareCH1
  2916. * @param TIMx Timer instance
  2917. * @param CompareValue between Min_Data=0 and Max_Data=65535
  2918. * @retval None
  2919. */
  2920. __STATIC_INLINE void LL_TIM_OC_SetCompareCH1(TIM_TypeDef *TIMx, uint32_t CompareValue)
  2921. {
  2922. WRITE_REG(TIMx->CCR1, CompareValue);
  2923. }
  2924. /**
  2925. * @brief Set compare value for output channel 2 (TIMx_CCR2).
  2926. * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
  2927. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2928. * whether or not a timer instance supports a 32 bits counter.
  2929. * @note Macro IS_TIM_CC2_INSTANCE(TIMx) can be used to check whether or not
  2930. * output channel 2 is supported by a timer instance.
  2931. * @note If dithering is activated, CompareValue can be calculated with macro @ref __LL_TIM_CALC_DELAY_DITHER .
  2932. * @rmtoll CCR2 CCR2 LL_TIM_OC_SetCompareCH2
  2933. * @param TIMx Timer instance
  2934. * @param CompareValue between Min_Data=0 and Max_Data=65535
  2935. * @retval None
  2936. */
  2937. __STATIC_INLINE void LL_TIM_OC_SetCompareCH2(TIM_TypeDef *TIMx, uint32_t CompareValue)
  2938. {
  2939. WRITE_REG(TIMx->CCR2, CompareValue);
  2940. }
  2941. /**
  2942. * @brief Set compare value for output channel 3 (TIMx_CCR3).
  2943. * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
  2944. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2945. * whether or not a timer instance supports a 32 bits counter.
  2946. * @note Macro IS_TIM_CC3_INSTANCE(TIMx) can be used to check whether or not
  2947. * output channel is supported by a timer instance.
  2948. * @note If dithering is activated, CompareValue can be calculated with macro @ref __LL_TIM_CALC_DELAY_DITHER .
  2949. * @rmtoll CCR3 CCR3 LL_TIM_OC_SetCompareCH3
  2950. * @param TIMx Timer instance
  2951. * @param CompareValue between Min_Data=0 and Max_Data=65535
  2952. * @retval None
  2953. */
  2954. __STATIC_INLINE void LL_TIM_OC_SetCompareCH3(TIM_TypeDef *TIMx, uint32_t CompareValue)
  2955. {
  2956. WRITE_REG(TIMx->CCR3, CompareValue);
  2957. }
  2958. /**
  2959. * @brief Set compare value for output channel 4 (TIMx_CCR4).
  2960. * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
  2961. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2962. * whether or not a timer instance supports a 32 bits counter.
  2963. * @note Macro IS_TIM_CC4_INSTANCE(TIMx) can be used to check whether or not
  2964. * output channel 4 is supported by a timer instance.
  2965. * @note If dithering is activated, CompareValue can be calculated with macro @ref __LL_TIM_CALC_DELAY_DITHER .
  2966. * @rmtoll CCR4 CCR4 LL_TIM_OC_SetCompareCH4
  2967. * @param TIMx Timer instance
  2968. * @param CompareValue between Min_Data=0 and Max_Data=65535
  2969. * @retval None
  2970. */
  2971. __STATIC_INLINE void LL_TIM_OC_SetCompareCH4(TIM_TypeDef *TIMx, uint32_t CompareValue)
  2972. {
  2973. WRITE_REG(TIMx->CCR4, CompareValue);
  2974. }
  2975. /**
  2976. * @brief Set compare value for output channel 5 (TIMx_CCR5).
  2977. * @note Macro IS_TIM_CC5_INSTANCE(TIMx) can be used to check whether or not
  2978. * output channel 5 is supported by a timer instance.
  2979. * @note If dithering is activated, CompareValue can be calculated with macro @ref __LL_TIM_CALC_DELAY_DITHER .
  2980. * @rmtoll CCR5 CCR5 LL_TIM_OC_SetCompareCH5
  2981. * @param TIMx Timer instance
  2982. * @param CompareValue between Min_Data=0 and Max_Data=65535
  2983. * @retval None
  2984. */
  2985. __STATIC_INLINE void LL_TIM_OC_SetCompareCH5(TIM_TypeDef *TIMx, uint32_t CompareValue)
  2986. {
  2987. MODIFY_REG(TIMx->CCR5, TIM_CCR5_CCR5, CompareValue);
  2988. }
  2989. /**
  2990. * @brief Set compare value for output channel 6 (TIMx_CCR6).
  2991. * @note Macro IS_TIM_CC6_INSTANCE(TIMx) can be used to check whether or not
  2992. * output channel 6 is supported by a timer instance.
  2993. * @note If dithering is activated, CompareValue can be calculated with macro @ref __LL_TIM_CALC_DELAY_DITHER .
  2994. * @rmtoll CCR6 CCR6 LL_TIM_OC_SetCompareCH6
  2995. * @param TIMx Timer instance
  2996. * @param CompareValue between Min_Data=0 and Max_Data=65535
  2997. * @retval None
  2998. */
  2999. __STATIC_INLINE void LL_TIM_OC_SetCompareCH6(TIM_TypeDef *TIMx, uint32_t CompareValue)
  3000. {
  3001. WRITE_REG(TIMx->CCR6, CompareValue);
  3002. }
  3003. /**
  3004. * @brief Get compare value (TIMx_CCR1) set for output channel 1.
  3005. * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
  3006. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  3007. * whether or not a timer instance supports a 32 bits counter.
  3008. * @note Macro IS_TIM_CC1_INSTANCE(TIMx) can be used to check whether or not
  3009. * output channel 1 is supported by a timer instance.
  3010. * @note If dithering is activated, pay attention to the returned value interpretation.
  3011. * @rmtoll CCR1 CCR1 LL_TIM_OC_GetCompareCH1
  3012. * @param TIMx Timer instance
  3013. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  3014. */
  3015. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH1(const TIM_TypeDef *TIMx)
  3016. {
  3017. return (uint32_t)(READ_REG(TIMx->CCR1));
  3018. }
  3019. /**
  3020. * @brief Get compare value (TIMx_CCR2) set for output channel 2.
  3021. * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
  3022. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  3023. * whether or not a timer instance supports a 32 bits counter.
  3024. * @note Macro IS_TIM_CC2_INSTANCE(TIMx) can be used to check whether or not
  3025. * output channel 2 is supported by a timer instance.
  3026. * @note If dithering is activated, pay attention to the returned value interpretation.
  3027. * @rmtoll CCR2 CCR2 LL_TIM_OC_GetCompareCH2
  3028. * @param TIMx Timer instance
  3029. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  3030. */
  3031. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH2(const TIM_TypeDef *TIMx)
  3032. {
  3033. return (uint32_t)(READ_REG(TIMx->CCR2));
  3034. }
  3035. /**
  3036. * @brief Get compare value (TIMx_CCR3) set for output channel 3.
  3037. * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
  3038. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  3039. * whether or not a timer instance supports a 32 bits counter.
  3040. * @note Macro IS_TIM_CC3_INSTANCE(TIMx) can be used to check whether or not
  3041. * output channel 3 is supported by a timer instance.
  3042. * @note If dithering is activated, pay attention to the returned value interpretation.
  3043. * @rmtoll CCR3 CCR3 LL_TIM_OC_GetCompareCH3
  3044. * @param TIMx Timer instance
  3045. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  3046. */
  3047. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH3(const TIM_TypeDef *TIMx)
  3048. {
  3049. return (uint32_t)(READ_REG(TIMx->CCR3));
  3050. }
  3051. /**
  3052. * @brief Get compare value (TIMx_CCR4) set for output channel 4.
  3053. * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
  3054. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  3055. * whether or not a timer instance supports a 32 bits counter.
  3056. * @note Macro IS_TIM_CC4_INSTANCE(TIMx) can be used to check whether or not
  3057. * output channel 4 is supported by a timer instance.
  3058. * @note If dithering is activated, pay attention to the returned value interpretation.
  3059. * @rmtoll CCR4 CCR4 LL_TIM_OC_GetCompareCH4
  3060. * @param TIMx Timer instance
  3061. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  3062. */
  3063. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH4(const TIM_TypeDef *TIMx)
  3064. {
  3065. return (uint32_t)(READ_REG(TIMx->CCR4));
  3066. }
  3067. /**
  3068. * @brief Get compare value (TIMx_CCR5) set for output channel 5.
  3069. * @note Macro IS_TIM_CC5_INSTANCE(TIMx) can be used to check whether or not
  3070. * output channel 5 is supported by a timer instance.
  3071. * @note If dithering is activated, pay attention to the returned value interpretation.
  3072. * @rmtoll CCR5 CCR5 LL_TIM_OC_GetCompareCH5
  3073. * @param TIMx Timer instance
  3074. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  3075. */
  3076. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH5(const TIM_TypeDef *TIMx)
  3077. {
  3078. return (uint32_t)(READ_BIT(TIMx->CCR5, TIM_CCR5_CCR5));
  3079. }
  3080. /**
  3081. * @brief Get compare value (TIMx_CCR6) set for output channel 6.
  3082. * @note Macro IS_TIM_CC6_INSTANCE(TIMx) can be used to check whether or not
  3083. * output channel 6 is supported by a timer instance.
  3084. * @note If dithering is activated, pay attention to the returned value interpretation.
  3085. * @rmtoll CCR6 CCR6 LL_TIM_OC_GetCompareCH6
  3086. * @param TIMx Timer instance
  3087. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  3088. */
  3089. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH6(const TIM_TypeDef *TIMx)
  3090. {
  3091. return (uint32_t)(READ_REG(TIMx->CCR6));
  3092. }
  3093. /**
  3094. * @brief Select on which reference signal the OC5REF is combined to.
  3095. * @note Macro IS_TIM_COMBINED3PHASEPWM_INSTANCE(TIMx) can be used to check
  3096. * whether or not a timer instance supports the combined 3-phase PWM mode.
  3097. * @rmtoll CCR5 GC5C3 LL_TIM_SetCH5CombinedChannels\n
  3098. * CCR5 GC5C2 LL_TIM_SetCH5CombinedChannels\n
  3099. * CCR5 GC5C1 LL_TIM_SetCH5CombinedChannels
  3100. * @param TIMx Timer instance
  3101. * @param GroupCH5 This parameter can be a combination of the following values:
  3102. * @arg @ref LL_TIM_GROUPCH5_NONE
  3103. * @arg @ref LL_TIM_GROUPCH5_OC1REFC
  3104. * @arg @ref LL_TIM_GROUPCH5_OC2REFC
  3105. * @arg @ref LL_TIM_GROUPCH5_OC3REFC
  3106. * @retval None
  3107. */
  3108. __STATIC_INLINE void LL_TIM_SetCH5CombinedChannels(TIM_TypeDef *TIMx, uint32_t GroupCH5)
  3109. {
  3110. MODIFY_REG(TIMx->CCR5, (TIM_CCR5_GC5C3 | TIM_CCR5_GC5C2 | TIM_CCR5_GC5C1), GroupCH5);
  3111. }
  3112. /**
  3113. * @brief Set the pulse on compare pulse width prescaler.
  3114. * @note Macro IS_TIM_PULSEONCOMPARE_INSTANCE(TIMx) can be used to check
  3115. * whether or not the pulse on compare feature is supported by the timer
  3116. * instance.
  3117. * @rmtoll ECR PWPRSC LL_TIM_OC_SetPulseWidthPrescaler
  3118. * @param TIMx Timer instance
  3119. * @param PulseWidthPrescaler This parameter can be one of the following values:
  3120. * @arg @ref LL_TIM_PWPRSC_X1
  3121. * @arg @ref LL_TIM_PWPRSC_X2
  3122. * @arg @ref LL_TIM_PWPRSC_X4
  3123. * @arg @ref LL_TIM_PWPRSC_X8
  3124. * @arg @ref LL_TIM_PWPRSC_X16
  3125. * @arg @ref LL_TIM_PWPRSC_X32
  3126. * @arg @ref LL_TIM_PWPRSC_X64
  3127. * @arg @ref LL_TIM_PWPRSC_X128
  3128. * @retval None
  3129. */
  3130. __STATIC_INLINE void LL_TIM_OC_SetPulseWidthPrescaler(TIM_TypeDef *TIMx, uint32_t PulseWidthPrescaler)
  3131. {
  3132. MODIFY_REG(TIMx->ECR, TIM_ECR_PWPRSC, PulseWidthPrescaler);
  3133. }
  3134. /**
  3135. * @brief Get the pulse on compare pulse width prescaler.
  3136. * @note Macro IS_TIM_PULSEONCOMPARE_INSTANCE(TIMx) can be used to check
  3137. * whether or not the pulse on compare feature is supported by the timer
  3138. * instance.
  3139. * @rmtoll ECR PWPRSC LL_TIM_OC_GetPulseWidthPrescaler
  3140. * @param TIMx Timer instance
  3141. * @retval Returned value can be one of the following values:
  3142. * @arg @ref LL_TIM_PWPRSC_X1
  3143. * @arg @ref LL_TIM_PWPRSC_X2
  3144. * @arg @ref LL_TIM_PWPRSC_X4
  3145. * @arg @ref LL_TIM_PWPRSC_X8
  3146. * @arg @ref LL_TIM_PWPRSC_X16
  3147. * @arg @ref LL_TIM_PWPRSC_X32
  3148. * @arg @ref LL_TIM_PWPRSC_X64
  3149. * @arg @ref LL_TIM_PWPRSC_X128
  3150. */
  3151. __STATIC_INLINE uint32_t LL_TIM_OC_GetPulseWidthPrescaler(const TIM_TypeDef *TIMx)
  3152. {
  3153. return (uint32_t)(READ_BIT(TIMx->ECR, TIM_ECR_PWPRSC));
  3154. }
  3155. /**
  3156. * @brief Set the pulse on compare pulse width duration.
  3157. * @note Macro IS_TIM_PULSEONCOMPARE_INSTANCE(TIMx) can be used to check
  3158. * whether or not the pulse on compare feature is supported by the timer
  3159. * instance.
  3160. * @rmtoll ECR PW LL_TIM_OC_SetPulseWidth
  3161. * @param TIMx Timer instance
  3162. * @param PulseWidth This parameter can be between Min_Data=0 and Max_Data=255
  3163. * @retval None
  3164. */
  3165. __STATIC_INLINE void LL_TIM_OC_SetPulseWidth(TIM_TypeDef *TIMx, uint32_t PulseWidth)
  3166. {
  3167. MODIFY_REG(TIMx->ECR, TIM_ECR_PW, PulseWidth << TIM_ECR_PW_Pos);
  3168. }
  3169. /**
  3170. * @brief Get the pulse on compare pulse width duration.
  3171. * @note Macro IS_TIM_PULSEONCOMPARE_INSTANCE(TIMx) can be used to check
  3172. * whether or not the pulse on compare feature is supported by the timer
  3173. * instance.
  3174. * @rmtoll ECR PW LL_TIM_OC_GetPulseWidth
  3175. * @param TIMx Timer instance
  3176. * @retval Returned value can be between Min_Data=0 and Max_Data=255:
  3177. */
  3178. __STATIC_INLINE uint32_t LL_TIM_OC_GetPulseWidth(const TIM_TypeDef *TIMx)
  3179. {
  3180. return (uint32_t)(READ_BIT(TIMx->ECR, TIM_ECR_PW));
  3181. }
  3182. /**
  3183. * @}
  3184. */
  3185. /** @defgroup TIM_LL_EF_Input_Channel Input channel configuration
  3186. * @{
  3187. */
  3188. /**
  3189. * @brief Configure input channel.
  3190. * @rmtoll CCMR1 CC1S LL_TIM_IC_Config\n
  3191. * CCMR1 IC1PSC LL_TIM_IC_Config\n
  3192. * CCMR1 IC1F LL_TIM_IC_Config\n
  3193. * CCMR1 CC2S LL_TIM_IC_Config\n
  3194. * CCMR1 IC2PSC LL_TIM_IC_Config\n
  3195. * CCMR1 IC2F LL_TIM_IC_Config\n
  3196. * CCMR2 CC3S LL_TIM_IC_Config\n
  3197. * CCMR2 IC3PSC LL_TIM_IC_Config\n
  3198. * CCMR2 IC3F LL_TIM_IC_Config\n
  3199. * CCMR2 CC4S LL_TIM_IC_Config\n
  3200. * CCMR2 IC4PSC LL_TIM_IC_Config\n
  3201. * CCMR2 IC4F LL_TIM_IC_Config\n
  3202. * CCER CC1P LL_TIM_IC_Config\n
  3203. * CCER CC1NP LL_TIM_IC_Config\n
  3204. * CCER CC2P LL_TIM_IC_Config\n
  3205. * CCER CC2NP LL_TIM_IC_Config\n
  3206. * CCER CC3P LL_TIM_IC_Config\n
  3207. * CCER CC3NP LL_TIM_IC_Config\n
  3208. * CCER CC4P LL_TIM_IC_Config\n
  3209. * CCER CC4NP LL_TIM_IC_Config
  3210. * @param TIMx Timer instance
  3211. * @param Channel This parameter can be one of the following values:
  3212. * @arg @ref LL_TIM_CHANNEL_CH1
  3213. * @arg @ref LL_TIM_CHANNEL_CH2
  3214. * @arg @ref LL_TIM_CHANNEL_CH3
  3215. * @arg @ref LL_TIM_CHANNEL_CH4
  3216. * @param Configuration This parameter must be a combination of all the following values:
  3217. * @arg @ref LL_TIM_ACTIVEINPUT_DIRECTTI or @ref LL_TIM_ACTIVEINPUT_INDIRECTTI or @ref LL_TIM_ACTIVEINPUT_TRC
  3218. * @arg @ref LL_TIM_ICPSC_DIV1 or ... or @ref LL_TIM_ICPSC_DIV8
  3219. * @arg @ref LL_TIM_IC_FILTER_FDIV1 or ... or @ref LL_TIM_IC_FILTER_FDIV32_N8
  3220. * @arg @ref LL_TIM_IC_POLARITY_RISING or @ref LL_TIM_IC_POLARITY_FALLING or @ref LL_TIM_IC_POLARITY_BOTHEDGE
  3221. * @retval None
  3222. */
  3223. __STATIC_INLINE void LL_TIM_IC_Config(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Configuration)
  3224. {
  3225. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  3226. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  3227. MODIFY_REG(*pReg, ((TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC | TIM_CCMR1_CC1S) << SHIFT_TAB_ICxx[iChannel]),
  3228. ((Configuration >> 16U) & (TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC | TIM_CCMR1_CC1S)) \
  3229. << SHIFT_TAB_ICxx[iChannel]);
  3230. MODIFY_REG(TIMx->CCER, ((TIM_CCER_CC1NP | TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel]),
  3231. (Configuration & (TIM_CCER_CC1NP | TIM_CCER_CC1P)) << SHIFT_TAB_CCxP[iChannel]);
  3232. }
  3233. /**
  3234. * @brief Set the active input.
  3235. * @rmtoll CCMR1 CC1S LL_TIM_IC_SetActiveInput\n
  3236. * CCMR1 CC2S LL_TIM_IC_SetActiveInput\n
  3237. * CCMR2 CC3S LL_TIM_IC_SetActiveInput\n
  3238. * CCMR2 CC4S LL_TIM_IC_SetActiveInput
  3239. * @param TIMx Timer instance
  3240. * @param Channel This parameter can be one of the following values:
  3241. * @arg @ref LL_TIM_CHANNEL_CH1
  3242. * @arg @ref LL_TIM_CHANNEL_CH2
  3243. * @arg @ref LL_TIM_CHANNEL_CH3
  3244. * @arg @ref LL_TIM_CHANNEL_CH4
  3245. * @param ICActiveInput This parameter can be one of the following values:
  3246. * @arg @ref LL_TIM_ACTIVEINPUT_DIRECTTI
  3247. * @arg @ref LL_TIM_ACTIVEINPUT_INDIRECTTI
  3248. * @arg @ref LL_TIM_ACTIVEINPUT_TRC
  3249. * @retval None
  3250. */
  3251. __STATIC_INLINE void LL_TIM_IC_SetActiveInput(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICActiveInput)
  3252. {
  3253. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  3254. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  3255. MODIFY_REG(*pReg, ((TIM_CCMR1_CC1S) << SHIFT_TAB_ICxx[iChannel]), (ICActiveInput >> 16U) << SHIFT_TAB_ICxx[iChannel]);
  3256. }
  3257. /**
  3258. * @brief Get the current active input.
  3259. * @rmtoll CCMR1 CC1S LL_TIM_IC_GetActiveInput\n
  3260. * CCMR1 CC2S LL_TIM_IC_GetActiveInput\n
  3261. * CCMR2 CC3S LL_TIM_IC_GetActiveInput\n
  3262. * CCMR2 CC4S LL_TIM_IC_GetActiveInput
  3263. * @param TIMx Timer instance
  3264. * @param Channel This parameter can be one of the following values:
  3265. * @arg @ref LL_TIM_CHANNEL_CH1
  3266. * @arg @ref LL_TIM_CHANNEL_CH2
  3267. * @arg @ref LL_TIM_CHANNEL_CH3
  3268. * @arg @ref LL_TIM_CHANNEL_CH4
  3269. * @retval Returned value can be one of the following values:
  3270. * @arg @ref LL_TIM_ACTIVEINPUT_DIRECTTI
  3271. * @arg @ref LL_TIM_ACTIVEINPUT_INDIRECTTI
  3272. * @arg @ref LL_TIM_ACTIVEINPUT_TRC
  3273. */
  3274. __STATIC_INLINE uint32_t LL_TIM_IC_GetActiveInput(const TIM_TypeDef *TIMx, uint32_t Channel)
  3275. {
  3276. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  3277. const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  3278. return ((READ_BIT(*pReg, ((TIM_CCMR1_CC1S) << SHIFT_TAB_ICxx[iChannel])) >> SHIFT_TAB_ICxx[iChannel]) << 16U);
  3279. }
  3280. /**
  3281. * @brief Set the prescaler of input channel.
  3282. * @rmtoll CCMR1 IC1PSC LL_TIM_IC_SetPrescaler\n
  3283. * CCMR1 IC2PSC LL_TIM_IC_SetPrescaler\n
  3284. * CCMR2 IC3PSC LL_TIM_IC_SetPrescaler\n
  3285. * CCMR2 IC4PSC LL_TIM_IC_SetPrescaler
  3286. * @param TIMx Timer instance
  3287. * @param Channel This parameter can be one of the following values:
  3288. * @arg @ref LL_TIM_CHANNEL_CH1
  3289. * @arg @ref LL_TIM_CHANNEL_CH2
  3290. * @arg @ref LL_TIM_CHANNEL_CH3
  3291. * @arg @ref LL_TIM_CHANNEL_CH4
  3292. * @param ICPrescaler This parameter can be one of the following values:
  3293. * @arg @ref LL_TIM_ICPSC_DIV1
  3294. * @arg @ref LL_TIM_ICPSC_DIV2
  3295. * @arg @ref LL_TIM_ICPSC_DIV4
  3296. * @arg @ref LL_TIM_ICPSC_DIV8
  3297. * @retval None
  3298. */
  3299. __STATIC_INLINE void LL_TIM_IC_SetPrescaler(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICPrescaler)
  3300. {
  3301. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  3302. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  3303. MODIFY_REG(*pReg, ((TIM_CCMR1_IC1PSC) << SHIFT_TAB_ICxx[iChannel]), (ICPrescaler >> 16U) << SHIFT_TAB_ICxx[iChannel]);
  3304. }
  3305. /**
  3306. * @brief Get the current prescaler value acting on an input channel.
  3307. * @rmtoll CCMR1 IC1PSC LL_TIM_IC_GetPrescaler\n
  3308. * CCMR1 IC2PSC LL_TIM_IC_GetPrescaler\n
  3309. * CCMR2 IC3PSC LL_TIM_IC_GetPrescaler\n
  3310. * CCMR2 IC4PSC LL_TIM_IC_GetPrescaler
  3311. * @param TIMx Timer instance
  3312. * @param Channel This parameter can be one of the following values:
  3313. * @arg @ref LL_TIM_CHANNEL_CH1
  3314. * @arg @ref LL_TIM_CHANNEL_CH2
  3315. * @arg @ref LL_TIM_CHANNEL_CH3
  3316. * @arg @ref LL_TIM_CHANNEL_CH4
  3317. * @retval Returned value can be one of the following values:
  3318. * @arg @ref LL_TIM_ICPSC_DIV1
  3319. * @arg @ref LL_TIM_ICPSC_DIV2
  3320. * @arg @ref LL_TIM_ICPSC_DIV4
  3321. * @arg @ref LL_TIM_ICPSC_DIV8
  3322. */
  3323. __STATIC_INLINE uint32_t LL_TIM_IC_GetPrescaler(const TIM_TypeDef *TIMx, uint32_t Channel)
  3324. {
  3325. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  3326. const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  3327. return ((READ_BIT(*pReg, ((TIM_CCMR1_IC1PSC) << SHIFT_TAB_ICxx[iChannel])) >> SHIFT_TAB_ICxx[iChannel]) << 16U);
  3328. }
  3329. /**
  3330. * @brief Set the input filter duration.
  3331. * @rmtoll CCMR1 IC1F LL_TIM_IC_SetFilter\n
  3332. * CCMR1 IC2F LL_TIM_IC_SetFilter\n
  3333. * CCMR2 IC3F LL_TIM_IC_SetFilter\n
  3334. * CCMR2 IC4F LL_TIM_IC_SetFilter
  3335. * @param TIMx Timer instance
  3336. * @param Channel This parameter can be one of the following values:
  3337. * @arg @ref LL_TIM_CHANNEL_CH1
  3338. * @arg @ref LL_TIM_CHANNEL_CH2
  3339. * @arg @ref LL_TIM_CHANNEL_CH3
  3340. * @arg @ref LL_TIM_CHANNEL_CH4
  3341. * @param ICFilter This parameter can be one of the following values:
  3342. * @arg @ref LL_TIM_IC_FILTER_FDIV1
  3343. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N2
  3344. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N4
  3345. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N8
  3346. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N6
  3347. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N8
  3348. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N6
  3349. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N8
  3350. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N6
  3351. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N8
  3352. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N5
  3353. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N6
  3354. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N8
  3355. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N5
  3356. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N6
  3357. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N8
  3358. * @retval None
  3359. */
  3360. __STATIC_INLINE void LL_TIM_IC_SetFilter(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICFilter)
  3361. {
  3362. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  3363. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  3364. MODIFY_REG(*pReg, ((TIM_CCMR1_IC1F) << SHIFT_TAB_ICxx[iChannel]), (ICFilter >> 16U) << SHIFT_TAB_ICxx[iChannel]);
  3365. }
  3366. /**
  3367. * @brief Get the input filter duration.
  3368. * @rmtoll CCMR1 IC1F LL_TIM_IC_GetFilter\n
  3369. * CCMR1 IC2F LL_TIM_IC_GetFilter\n
  3370. * CCMR2 IC3F LL_TIM_IC_GetFilter\n
  3371. * CCMR2 IC4F LL_TIM_IC_GetFilter
  3372. * @param TIMx Timer instance
  3373. * @param Channel This parameter can be one of the following values:
  3374. * @arg @ref LL_TIM_CHANNEL_CH1
  3375. * @arg @ref LL_TIM_CHANNEL_CH2
  3376. * @arg @ref LL_TIM_CHANNEL_CH3
  3377. * @arg @ref LL_TIM_CHANNEL_CH4
  3378. * @retval Returned value can be one of the following values:
  3379. * @arg @ref LL_TIM_IC_FILTER_FDIV1
  3380. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N2
  3381. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N4
  3382. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N8
  3383. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N6
  3384. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N8
  3385. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N6
  3386. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N8
  3387. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N6
  3388. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N8
  3389. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N5
  3390. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N6
  3391. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N8
  3392. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N5
  3393. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N6
  3394. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N8
  3395. */
  3396. __STATIC_INLINE uint32_t LL_TIM_IC_GetFilter(const TIM_TypeDef *TIMx, uint32_t Channel)
  3397. {
  3398. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  3399. const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  3400. return ((READ_BIT(*pReg, ((TIM_CCMR1_IC1F) << SHIFT_TAB_ICxx[iChannel])) >> SHIFT_TAB_ICxx[iChannel]) << 16U);
  3401. }
  3402. /**
  3403. * @brief Set the input channel polarity.
  3404. * @rmtoll CCER CC1P LL_TIM_IC_SetPolarity\n
  3405. * CCER CC1NP LL_TIM_IC_SetPolarity\n
  3406. * CCER CC2P LL_TIM_IC_SetPolarity\n
  3407. * CCER CC2NP LL_TIM_IC_SetPolarity\n
  3408. * CCER CC3P LL_TIM_IC_SetPolarity\n
  3409. * CCER CC3NP LL_TIM_IC_SetPolarity\n
  3410. * CCER CC4P LL_TIM_IC_SetPolarity\n
  3411. * CCER CC4NP LL_TIM_IC_SetPolarity
  3412. * @param TIMx Timer instance
  3413. * @param Channel This parameter can be one of the following values:
  3414. * @arg @ref LL_TIM_CHANNEL_CH1
  3415. * @arg @ref LL_TIM_CHANNEL_CH2
  3416. * @arg @ref LL_TIM_CHANNEL_CH3
  3417. * @arg @ref LL_TIM_CHANNEL_CH4
  3418. * @param ICPolarity This parameter can be one of the following values:
  3419. * @arg @ref LL_TIM_IC_POLARITY_RISING
  3420. * @arg @ref LL_TIM_IC_POLARITY_FALLING
  3421. * @arg @ref LL_TIM_IC_POLARITY_BOTHEDGE
  3422. * @retval None
  3423. */
  3424. __STATIC_INLINE void LL_TIM_IC_SetPolarity(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICPolarity)
  3425. {
  3426. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  3427. MODIFY_REG(TIMx->CCER, ((TIM_CCER_CC1NP | TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel]),
  3428. ICPolarity << SHIFT_TAB_CCxP[iChannel]);
  3429. }
  3430. /**
  3431. * @brief Get the current input channel polarity.
  3432. * @rmtoll CCER CC1P LL_TIM_IC_GetPolarity\n
  3433. * CCER CC1NP LL_TIM_IC_GetPolarity\n
  3434. * CCER CC2P LL_TIM_IC_GetPolarity\n
  3435. * CCER CC2NP LL_TIM_IC_GetPolarity\n
  3436. * CCER CC3P LL_TIM_IC_GetPolarity\n
  3437. * CCER CC3NP LL_TIM_IC_GetPolarity\n
  3438. * CCER CC4P LL_TIM_IC_GetPolarity\n
  3439. * CCER CC4NP LL_TIM_IC_GetPolarity
  3440. * @param TIMx Timer instance
  3441. * @param Channel This parameter can be one of the following values:
  3442. * @arg @ref LL_TIM_CHANNEL_CH1
  3443. * @arg @ref LL_TIM_CHANNEL_CH2
  3444. * @arg @ref LL_TIM_CHANNEL_CH3
  3445. * @arg @ref LL_TIM_CHANNEL_CH4
  3446. * @retval Returned value can be one of the following values:
  3447. * @arg @ref LL_TIM_IC_POLARITY_RISING
  3448. * @arg @ref LL_TIM_IC_POLARITY_FALLING
  3449. * @arg @ref LL_TIM_IC_POLARITY_BOTHEDGE
  3450. */
  3451. __STATIC_INLINE uint32_t LL_TIM_IC_GetPolarity(const TIM_TypeDef *TIMx, uint32_t Channel)
  3452. {
  3453. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  3454. return (READ_BIT(TIMx->CCER, ((TIM_CCER_CC1NP | TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel])) >>
  3455. SHIFT_TAB_CCxP[iChannel]);
  3456. }
  3457. /**
  3458. * @brief Connect the TIMx_CH1, CH2 and CH3 pins to the TI1 input (XOR combination).
  3459. * @note Macro IS_TIM_XOR_INSTANCE(TIMx) can be used to check whether or not
  3460. * a timer instance provides an XOR input.
  3461. * @rmtoll CR2 TI1S LL_TIM_IC_EnableXORCombination
  3462. * @param TIMx Timer instance
  3463. * @retval None
  3464. */
  3465. __STATIC_INLINE void LL_TIM_IC_EnableXORCombination(TIM_TypeDef *TIMx)
  3466. {
  3467. SET_BIT(TIMx->CR2, TIM_CR2_TI1S);
  3468. }
  3469. /**
  3470. * @brief Disconnect the TIMx_CH1, CH2 and CH3 pins from the TI1 input.
  3471. * @note Macro IS_TIM_XOR_INSTANCE(TIMx) can be used to check whether or not
  3472. * a timer instance provides an XOR input.
  3473. * @rmtoll CR2 TI1S LL_TIM_IC_DisableXORCombination
  3474. * @param TIMx Timer instance
  3475. * @retval None
  3476. */
  3477. __STATIC_INLINE void LL_TIM_IC_DisableXORCombination(TIM_TypeDef *TIMx)
  3478. {
  3479. CLEAR_BIT(TIMx->CR2, TIM_CR2_TI1S);
  3480. }
  3481. /**
  3482. * @brief Indicates whether the TIMx_CH1, CH2 and CH3 pins are connectected to the TI1 input.
  3483. * @note Macro IS_TIM_XOR_INSTANCE(TIMx) can be used to check whether or not
  3484. * a timer instance provides an XOR input.
  3485. * @rmtoll CR2 TI1S LL_TIM_IC_IsEnabledXORCombination
  3486. * @param TIMx Timer instance
  3487. * @retval State of bit (1 or 0).
  3488. */
  3489. __STATIC_INLINE uint32_t LL_TIM_IC_IsEnabledXORCombination(const TIM_TypeDef *TIMx)
  3490. {
  3491. return ((READ_BIT(TIMx->CR2, TIM_CR2_TI1S) == (TIM_CR2_TI1S)) ? 1UL : 0UL);
  3492. }
  3493. /**
  3494. * @brief Get captured value for input channel 1.
  3495. * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
  3496. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  3497. * whether or not a timer instance supports a 32 bits counter.
  3498. * @note Macro IS_TIM_CC1_INSTANCE(TIMx) can be used to check whether or not
  3499. * input channel 1 is supported by a timer instance.
  3500. * @note If dithering is activated, pay attention to the returned value interpretation.
  3501. * @rmtoll CCR1 CCR1 LL_TIM_IC_GetCaptureCH1
  3502. * @param TIMx Timer instance
  3503. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  3504. */
  3505. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH1(const TIM_TypeDef *TIMx)
  3506. {
  3507. return (uint32_t)(READ_REG(TIMx->CCR1));
  3508. }
  3509. /**
  3510. * @brief Get captured value for input channel 2.
  3511. * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
  3512. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  3513. * whether or not a timer instance supports a 32 bits counter.
  3514. * @note Macro IS_TIM_CC2_INSTANCE(TIMx) can be used to check whether or not
  3515. * input channel 2 is supported by a timer instance.
  3516. * @note If dithering is activated, pay attention to the returned value interpretation.
  3517. * @rmtoll CCR2 CCR2 LL_TIM_IC_GetCaptureCH2
  3518. * @param TIMx Timer instance
  3519. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  3520. */
  3521. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH2(const TIM_TypeDef *TIMx)
  3522. {
  3523. return (uint32_t)(READ_REG(TIMx->CCR2));
  3524. }
  3525. /**
  3526. * @brief Get captured value for input channel 3.
  3527. * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
  3528. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  3529. * whether or not a timer instance supports a 32 bits counter.
  3530. * @note Macro IS_TIM_CC3_INSTANCE(TIMx) can be used to check whether or not
  3531. * input channel 3 is supported by a timer instance.
  3532. * @note If dithering is activated, pay attention to the returned value interpretation.
  3533. * @rmtoll CCR3 CCR3 LL_TIM_IC_GetCaptureCH3
  3534. * @param TIMx Timer instance
  3535. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  3536. */
  3537. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH3(const TIM_TypeDef *TIMx)
  3538. {
  3539. return (uint32_t)(READ_REG(TIMx->CCR3));
  3540. }
  3541. /**
  3542. * @brief Get captured value for input channel 4.
  3543. * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
  3544. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  3545. * whether or not a timer instance supports a 32 bits counter.
  3546. * @note Macro IS_TIM_CC4_INSTANCE(TIMx) can be used to check whether or not
  3547. * input channel 4 is supported by a timer instance.
  3548. * @note If dithering is activated, pay attention to the returned value interpretation.
  3549. * @rmtoll CCR4 CCR4 LL_TIM_IC_GetCaptureCH4
  3550. * @param TIMx Timer instance
  3551. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  3552. */
  3553. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH4(const TIM_TypeDef *TIMx)
  3554. {
  3555. return (uint32_t)(READ_REG(TIMx->CCR4));
  3556. }
  3557. /**
  3558. * @}
  3559. */
  3560. /** @defgroup TIM_LL_EF_Clock_Selection Counter clock selection
  3561. * @{
  3562. */
  3563. /**
  3564. * @brief Enable external clock mode 2.
  3565. * @note When external clock mode 2 is enabled the counter is clocked by any active edge on the ETRF signal.
  3566. * @note Macro IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  3567. * whether or not a timer instance supports external clock mode2.
  3568. * @rmtoll SMCR ECE LL_TIM_EnableExternalClock
  3569. * @param TIMx Timer instance
  3570. * @retval None
  3571. */
  3572. __STATIC_INLINE void LL_TIM_EnableExternalClock(TIM_TypeDef *TIMx)
  3573. {
  3574. SET_BIT(TIMx->SMCR, TIM_SMCR_ECE);
  3575. }
  3576. /**
  3577. * @brief Disable external clock mode 2.
  3578. * @note Macro IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  3579. * whether or not a timer instance supports external clock mode2.
  3580. * @rmtoll SMCR ECE LL_TIM_DisableExternalClock
  3581. * @param TIMx Timer instance
  3582. * @retval None
  3583. */
  3584. __STATIC_INLINE void LL_TIM_DisableExternalClock(TIM_TypeDef *TIMx)
  3585. {
  3586. CLEAR_BIT(TIMx->SMCR, TIM_SMCR_ECE);
  3587. }
  3588. /**
  3589. * @brief Indicate whether external clock mode 2 is enabled.
  3590. * @note Macro IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  3591. * whether or not a timer instance supports external clock mode2.
  3592. * @rmtoll SMCR ECE LL_TIM_IsEnabledExternalClock
  3593. * @param TIMx Timer instance
  3594. * @retval State of bit (1 or 0).
  3595. */
  3596. __STATIC_INLINE uint32_t LL_TIM_IsEnabledExternalClock(const TIM_TypeDef *TIMx)
  3597. {
  3598. return ((READ_BIT(TIMx->SMCR, TIM_SMCR_ECE) == (TIM_SMCR_ECE)) ? 1UL : 0UL);
  3599. }
  3600. /**
  3601. * @brief Set the clock source of the counter clock.
  3602. * @note when selected clock source is external clock mode 1, the timer input
  3603. * the external clock is applied is selected by calling the @ref LL_TIM_SetTriggerInput()
  3604. * function. This timer input must be configured by calling
  3605. * the @ref LL_TIM_IC_Config() function.
  3606. * @note Macro IS_TIM_CLOCKSOURCE_ETRMODE1_INSTANCE(TIMx) can be used to check
  3607. * whether or not a timer instance supports external clock mode1.
  3608. * @note Macro IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  3609. * whether or not a timer instance supports external clock mode2.
  3610. * @rmtoll SMCR SMS LL_TIM_SetClockSource\n
  3611. * SMCR ECE LL_TIM_SetClockSource
  3612. * @param TIMx Timer instance
  3613. * @param ClockSource This parameter can be one of the following values:
  3614. * @arg @ref LL_TIM_CLOCKSOURCE_INTERNAL
  3615. * @arg @ref LL_TIM_CLOCKSOURCE_EXT_MODE1
  3616. * @arg @ref LL_TIM_CLOCKSOURCE_EXT_MODE2
  3617. * @retval None
  3618. */
  3619. __STATIC_INLINE void LL_TIM_SetClockSource(TIM_TypeDef *TIMx, uint32_t ClockSource)
  3620. {
  3621. MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMS | TIM_SMCR_ECE, ClockSource);
  3622. }
  3623. /**
  3624. * @brief Set the encoder interface mode.
  3625. * @note Macro IS_TIM_ENCODER_INTERFACE_INSTANCE(TIMx) can be used to check
  3626. * whether or not a timer instance supports the encoder mode.
  3627. * @rmtoll SMCR SMS LL_TIM_SetEncoderMode
  3628. * @param TIMx Timer instance
  3629. * @param EncoderMode This parameter can be one of the following values:
  3630. * @arg @ref LL_TIM_ENCODERMODE_X2_TI1
  3631. * @arg @ref LL_TIM_ENCODERMODE_X2_TI2
  3632. * @arg @ref LL_TIM_ENCODERMODE_X4_TI12
  3633. * @arg @ref LL_TIM_ENCODERMODE_CLOCKPLUSDIRECTION_X2
  3634. * @arg @ref LL_TIM_ENCODERMODE_CLOCKPLUSDIRECTION_X1
  3635. * @arg @ref LL_TIM_ENCODERMODE_DIRECTIONALCLOCK_X2
  3636. * @arg @ref LL_TIM_ENCODERMODE_DIRECTIONALCLOCK_X1_TI12
  3637. * @arg @ref LL_TIM_ENCODERMODE_X1_TI1
  3638. * @arg @ref LL_TIM_ENCODERMODE_X1_TI2
  3639. * @retval None
  3640. */
  3641. __STATIC_INLINE void LL_TIM_SetEncoderMode(TIM_TypeDef *TIMx, uint32_t EncoderMode)
  3642. {
  3643. MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMS, EncoderMode);
  3644. }
  3645. /**
  3646. * @}
  3647. */
  3648. /** @defgroup TIM_LL_EF_Timer_Synchronization Timer synchronisation configuration
  3649. * @{
  3650. */
  3651. /**
  3652. * @brief Set the trigger output (TRGO) used for timer synchronization .
  3653. * @note Macro IS_TIM_MASTER_INSTANCE(TIMx) can be used to check
  3654. * whether or not a timer instance can operate as a master timer.
  3655. * @rmtoll CR2 MMS LL_TIM_SetTriggerOutput
  3656. * @param TIMx Timer instance
  3657. * @param TimerSynchronization This parameter can be one of the following values:
  3658. * @arg @ref LL_TIM_TRGO_RESET
  3659. * @arg @ref LL_TIM_TRGO_ENABLE
  3660. * @arg @ref LL_TIM_TRGO_UPDATE
  3661. * @arg @ref LL_TIM_TRGO_CC1IF
  3662. * @arg @ref LL_TIM_TRGO_OC1REF
  3663. * @arg @ref LL_TIM_TRGO_OC2REF
  3664. * @arg @ref LL_TIM_TRGO_OC3REF
  3665. * @arg @ref LL_TIM_TRGO_OC4REF
  3666. * @arg @ref LL_TIM_TRGO_ENCODERCLK
  3667. * @retval None
  3668. */
  3669. __STATIC_INLINE void LL_TIM_SetTriggerOutput(TIM_TypeDef *TIMx, uint32_t TimerSynchronization)
  3670. {
  3671. MODIFY_REG(TIMx->CR2, TIM_CR2_MMS, TimerSynchronization);
  3672. }
  3673. /**
  3674. * @brief Set the trigger output 2 (TRGO2) used for ADC synchronization .
  3675. * @note Macro IS_TIM_TRGO2_INSTANCE(TIMx) can be used to check
  3676. * whether or not a timer instance can be used for ADC synchronization.
  3677. * @rmtoll CR2 MMS2 LL_TIM_SetTriggerOutput2
  3678. * @param TIMx Timer Instance
  3679. * @param ADCSynchronization This parameter can be one of the following values:
  3680. * @arg @ref LL_TIM_TRGO2_RESET
  3681. * @arg @ref LL_TIM_TRGO2_ENABLE
  3682. * @arg @ref LL_TIM_TRGO2_UPDATE
  3683. * @arg @ref LL_TIM_TRGO2_CC1F
  3684. * @arg @ref LL_TIM_TRGO2_OC1
  3685. * @arg @ref LL_TIM_TRGO2_OC2
  3686. * @arg @ref LL_TIM_TRGO2_OC3
  3687. * @arg @ref LL_TIM_TRGO2_OC4
  3688. * @arg @ref LL_TIM_TRGO2_OC5
  3689. * @arg @ref LL_TIM_TRGO2_OC6
  3690. * @arg @ref LL_TIM_TRGO2_OC4_RISINGFALLING
  3691. * @arg @ref LL_TIM_TRGO2_OC6_RISINGFALLING
  3692. * @arg @ref LL_TIM_TRGO2_OC4_RISING_OC6_RISING
  3693. * @arg @ref LL_TIM_TRGO2_OC4_RISING_OC6_FALLING
  3694. * @arg @ref LL_TIM_TRGO2_OC5_RISING_OC6_RISING
  3695. * @arg @ref LL_TIM_TRGO2_OC5_RISING_OC6_FALLING
  3696. * @retval None
  3697. */
  3698. __STATIC_INLINE void LL_TIM_SetTriggerOutput2(TIM_TypeDef *TIMx, uint32_t ADCSynchronization)
  3699. {
  3700. MODIFY_REG(TIMx->CR2, TIM_CR2_MMS2, ADCSynchronization);
  3701. }
  3702. /**
  3703. * @brief Set the synchronization mode of a slave timer.
  3704. * @note Macro IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  3705. * a timer instance can operate as a slave timer.
  3706. * @rmtoll SMCR SMS LL_TIM_SetSlaveMode
  3707. * @param TIMx Timer instance
  3708. * @param SlaveMode This parameter can be one of the following values:
  3709. * @arg @ref LL_TIM_SLAVEMODE_DISABLED
  3710. * @arg @ref LL_TIM_SLAVEMODE_RESET
  3711. * @arg @ref LL_TIM_SLAVEMODE_GATED
  3712. * @arg @ref LL_TIM_SLAVEMODE_TRIGGER
  3713. * @arg @ref LL_TIM_SLAVEMODE_COMBINED_RESETTRIGGER
  3714. * @arg @ref LL_TIM_SLAVEMODE_COMBINED_GATEDRESET
  3715. * @retval None
  3716. */
  3717. __STATIC_INLINE void LL_TIM_SetSlaveMode(TIM_TypeDef *TIMx, uint32_t SlaveMode)
  3718. {
  3719. MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMS, SlaveMode);
  3720. }
  3721. /**
  3722. * @brief Set the selects the trigger input to be used to synchronize the counter.
  3723. * @note Macro IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  3724. * a timer instance can operate as a slave timer.
  3725. * @rmtoll SMCR TS LL_TIM_SetTriggerInput
  3726. * @param TIMx Timer instance
  3727. * @param TriggerInput This parameter can be one of the following values:
  3728. * @arg @ref LL_TIM_TS_ITR0
  3729. * @arg @ref LL_TIM_TS_ITR1
  3730. * @arg @ref LL_TIM_TS_ITR2
  3731. * @arg @ref LL_TIM_TS_ITR3
  3732. * @arg @ref LL_TIM_TS_ITR4
  3733. * @arg @ref LL_TIM_TS_ITR5
  3734. * @arg @ref LL_TIM_TS_ITR6
  3735. * @arg @ref LL_TIM_TS_ITR7
  3736. * @arg @ref LL_TIM_TS_ITR8
  3737. * @arg @ref LL_TIM_TS_ITR9
  3738. * @arg @ref LL_TIM_TS_ITR10
  3739. * @arg @ref LL_TIM_TS_ITR11
  3740. * @arg @ref LL_TIM_TS_TI1F_ED
  3741. * @arg @ref LL_TIM_TS_TI1FP1
  3742. * @arg @ref LL_TIM_TS_TI2FP2
  3743. * @arg @ref LL_TIM_TS_ETRF
  3744. * @retval None
  3745. */
  3746. __STATIC_INLINE void LL_TIM_SetTriggerInput(TIM_TypeDef *TIMx, uint32_t TriggerInput)
  3747. {
  3748. MODIFY_REG(TIMx->SMCR, TIM_SMCR_TS, TriggerInput);
  3749. }
  3750. /**
  3751. * @brief Enable the Master/Slave mode.
  3752. * @note Macro IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  3753. * a timer instance can operate as a slave timer.
  3754. * @rmtoll SMCR MSM LL_TIM_EnableMasterSlaveMode
  3755. * @param TIMx Timer instance
  3756. * @retval None
  3757. */
  3758. __STATIC_INLINE void LL_TIM_EnableMasterSlaveMode(TIM_TypeDef *TIMx)
  3759. {
  3760. SET_BIT(TIMx->SMCR, TIM_SMCR_MSM);
  3761. }
  3762. /**
  3763. * @brief Disable the Master/Slave mode.
  3764. * @note Macro IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  3765. * a timer instance can operate as a slave timer.
  3766. * @rmtoll SMCR MSM LL_TIM_DisableMasterSlaveMode
  3767. * @param TIMx Timer instance
  3768. * @retval None
  3769. */
  3770. __STATIC_INLINE void LL_TIM_DisableMasterSlaveMode(TIM_TypeDef *TIMx)
  3771. {
  3772. CLEAR_BIT(TIMx->SMCR, TIM_SMCR_MSM);
  3773. }
  3774. /**
  3775. * @brief Indicates whether the Master/Slave mode is enabled.
  3776. * @note Macro IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  3777. * a timer instance can operate as a slave timer.
  3778. * @rmtoll SMCR MSM LL_TIM_IsEnabledMasterSlaveMode
  3779. * @param TIMx Timer instance
  3780. * @retval State of bit (1 or 0).
  3781. */
  3782. __STATIC_INLINE uint32_t LL_TIM_IsEnabledMasterSlaveMode(const TIM_TypeDef *TIMx)
  3783. {
  3784. return ((READ_BIT(TIMx->SMCR, TIM_SMCR_MSM) == (TIM_SMCR_MSM)) ? 1UL : 0UL);
  3785. }
  3786. /**
  3787. * @brief Configure the external trigger (ETR) input.
  3788. * @note Macro IS_TIM_ETR_INSTANCE(TIMx) can be used to check whether or not
  3789. * a timer instance provides an external trigger input.
  3790. * @rmtoll SMCR ETP LL_TIM_ConfigETR\n
  3791. * SMCR ETPS LL_TIM_ConfigETR\n
  3792. * SMCR ETF LL_TIM_ConfigETR
  3793. * @param TIMx Timer instance
  3794. * @param ETRPolarity This parameter can be one of the following values:
  3795. * @arg @ref LL_TIM_ETR_POLARITY_NONINVERTED
  3796. * @arg @ref LL_TIM_ETR_POLARITY_INVERTED
  3797. * @param ETRPrescaler This parameter can be one of the following values:
  3798. * @arg @ref LL_TIM_ETR_PRESCALER_DIV1
  3799. * @arg @ref LL_TIM_ETR_PRESCALER_DIV2
  3800. * @arg @ref LL_TIM_ETR_PRESCALER_DIV4
  3801. * @arg @ref LL_TIM_ETR_PRESCALER_DIV8
  3802. * @param ETRFilter This parameter can be one of the following values:
  3803. * @arg @ref LL_TIM_ETR_FILTER_FDIV1
  3804. * @arg @ref LL_TIM_ETR_FILTER_FDIV1_N2
  3805. * @arg @ref LL_TIM_ETR_FILTER_FDIV1_N4
  3806. * @arg @ref LL_TIM_ETR_FILTER_FDIV1_N8
  3807. * @arg @ref LL_TIM_ETR_FILTER_FDIV2_N6
  3808. * @arg @ref LL_TIM_ETR_FILTER_FDIV2_N8
  3809. * @arg @ref LL_TIM_ETR_FILTER_FDIV4_N6
  3810. * @arg @ref LL_TIM_ETR_FILTER_FDIV4_N8
  3811. * @arg @ref LL_TIM_ETR_FILTER_FDIV8_N6
  3812. * @arg @ref LL_TIM_ETR_FILTER_FDIV8_N8
  3813. * @arg @ref LL_TIM_ETR_FILTER_FDIV16_N5
  3814. * @arg @ref LL_TIM_ETR_FILTER_FDIV16_N6
  3815. * @arg @ref LL_TIM_ETR_FILTER_FDIV16_N8
  3816. * @arg @ref LL_TIM_ETR_FILTER_FDIV32_N5
  3817. * @arg @ref LL_TIM_ETR_FILTER_FDIV32_N6
  3818. * @arg @ref LL_TIM_ETR_FILTER_FDIV32_N8
  3819. * @retval None
  3820. */
  3821. __STATIC_INLINE void LL_TIM_ConfigETR(TIM_TypeDef *TIMx, uint32_t ETRPolarity, uint32_t ETRPrescaler,
  3822. uint32_t ETRFilter)
  3823. {
  3824. MODIFY_REG(TIMx->SMCR, TIM_SMCR_ETP | TIM_SMCR_ETPS | TIM_SMCR_ETF, ETRPolarity | ETRPrescaler | ETRFilter);
  3825. }
  3826. /**
  3827. * @brief Select the external trigger (ETR) input source.
  3828. * @note Macro IS_TIM_ETRSEL_INSTANCE(TIMx) can be used to check whether or
  3829. * not a timer instance supports ETR source selection.
  3830. * @rmtoll AF1 ETRSEL LL_TIM_SetETRSource
  3831. * @param TIMx Timer instance
  3832. * @param ETRSource This parameter can be one of the following values:
  3833. *
  3834. * TIM1: any combination of ETR_RMP where
  3835. *
  3836. * @arg @ref LL_TIM_TIM1_ETRSOURCE_GPIO
  3837. * @arg @ref LL_TIM_TIM1_ETRSOURCE_COMP1
  3838. * @arg @ref LL_TIM_TIM1_ETRSOURCE_COMP2
  3839. * @arg @ref LL_TIM_TIM1_ETRSOURCE_COMP3
  3840. * @arg @ref LL_TIM_TIM1_ETRSOURCE_COMP4
  3841. * @arg @ref LL_TIM_TIM1_ETRSOURCE_COMP5 (*)
  3842. * @arg @ref LL_TIM_TIM1_ETRSOURCE_COMP6 (*)
  3843. * @arg @ref LL_TIM_TIM1_ETRSOURCE_COMP7 (*)
  3844. * @arg @ref LL_TIM_TIM1_ETRSOURCE_ADC1_AWD1
  3845. * @arg @ref LL_TIM_TIM1_ETRSOURCE_ADC1_AWD2
  3846. * @arg @ref LL_TIM_TIM1_ETRSOURCE_ADC1_AWD3
  3847. * @arg @ref LL_TIM_TIM1_ETRSOURCE_ADC4_AWD1 (*)
  3848. * @arg @ref LL_TIM_TIM1_ETRSOURCE_ADC4_AWD2 (*)
  3849. * @arg @ref LL_TIM_TIM1_ETRSOURCE_ADC4_AWD3 (*)
  3850. *
  3851. * TIM2: any combination of ETR_RMP where
  3852. *
  3853. * @arg @ref LL_TIM_TIM2_ETRSOURCE_GPIO
  3854. * @arg @ref LL_TIM_TIM2_ETRSOURCE_COMP1
  3855. * @arg @ref LL_TIM_TIM2_ETRSOURCE_COMP2
  3856. * @arg @ref LL_TIM_TIM2_ETRSOURCE_COMP3
  3857. * @arg @ref LL_TIM_TIM2_ETRSOURCE_COMP4
  3858. * @arg @ref LL_TIM_TIM2_ETRSOURCE_COMP5 (*)
  3859. * @arg @ref LL_TIM_TIM2_ETRSOURCE_COMP6 (*)
  3860. * @arg @ref LL_TIM_TIM2_ETRSOURCE_COMP7 (*)
  3861. * @arg @ref LL_TIM_TIM2_ETRSOURCE_TIM3_ETR
  3862. * @arg @ref LL_TIM_TIM2_ETRSOURCE_TIM4_ETR
  3863. * @arg @ref LL_TIM_TIM2_ETRSOURCE_TIM5_ETR (*)
  3864. * @arg @ref LL_TIM_TIM2_ETRSOURCE_LSE
  3865. *
  3866. * TIM3: any combination of ETR_RMP where
  3867. *
  3868. * @arg @ref LL_TIM_TIM3_ETRSOURCE_GPIO
  3869. * @arg @ref LL_TIM_TIM3_ETRSOURCE_COMP1
  3870. * @arg @ref LL_TIM_TIM3_ETRSOURCE_COMP2
  3871. * @arg @ref LL_TIM_TIM3_ETRSOURCE_COMP3
  3872. * @arg @ref LL_TIM_TIM3_ETRSOURCE_COMP4
  3873. * @arg @ref LL_TIM_TIM3_ETRSOURCE_COMP5 (*)
  3874. * @arg @ref LL_TIM_TIM3_ETRSOURCE_COMP6 (*)
  3875. * @arg @ref LL_TIM_TIM3_ETRSOURCE_COMP7 (*)
  3876. * @arg @ref LL_TIM_TIM3_ETRSOURCE_TIM2_ETR
  3877. * @arg @ref LL_TIM_TIM3_ETRSOURCE_TIM4_ETR
  3878. * @arg @ref LL_TIM_TIM3_ETRSOURCE_ADC2_AWD1
  3879. * @arg @ref LL_TIM_TIM3_ETRSOURCE_ADC2_AWD2
  3880. * @arg @ref LL_TIM_TIM3_ETRSOURCE_ADC2_AWD3
  3881. *
  3882. * TIM4: any combination of ETR_RMP where
  3883. *
  3884. * @arg @ref LL_TIM_TIM4_ETRSOURCE_GPIO
  3885. * @arg @ref LL_TIM_TIM4_ETRSOURCE_COMP1
  3886. * @arg @ref LL_TIM_TIM4_ETRSOURCE_COMP2
  3887. * @arg @ref LL_TIM_TIM4_ETRSOURCE_COMP3
  3888. * @arg @ref LL_TIM_TIM4_ETRSOURCE_COMP4
  3889. * @arg @ref LL_TIM_TIM4_ETRSOURCE_COMP5 (*)
  3890. * @arg @ref LL_TIM_TIM4_ETRSOURCE_COMP6 (*)
  3891. * @arg @ref LL_TIM_TIM4_ETRSOURCE_COMP7 (*)
  3892. * @arg @ref LL_TIM_TIM4_ETRSOURCE_TIM3_ETR
  3893. * @arg @ref LL_TIM_TIM4_ETRSOURCE_TIM5_ETR (*)
  3894. *
  3895. * TIM5: any combination of ETR_RMP where (**)
  3896. *
  3897. * @arg @ref LL_TIM_TIM5_ETRSOURCE_GPIO (*)
  3898. * @arg @ref LL_TIM_TIM5_ETRSOURCE_COMP1 (*)
  3899. * @arg @ref LL_TIM_TIM5_ETRSOURCE_COMP2 (*)
  3900. * @arg @ref LL_TIM_TIM5_ETRSOURCE_COMP3 (*)
  3901. * @arg @ref LL_TIM_TIM5_ETRSOURCE_COMP4 (*)
  3902. * @arg @ref LL_TIM_TIM5_ETRSOURCE_COMP5 (*)
  3903. * @arg @ref LL_TIM_TIM5_ETRSOURCE_COMP6 (*)
  3904. * @arg @ref LL_TIM_TIM5_ETRSOURCE_COMP7 (*)
  3905. * @arg @ref LL_TIM_TIM5_ETRSOURCE_TIM2_ETR (*)
  3906. * @arg @ref LL_TIM_TIM5_ETRSOURCE_TIM3_ETR (*)
  3907. *
  3908. * TIM8: any combination of ETR_RMP where
  3909. *
  3910. * . . ETR_RMP can be one of the following values
  3911. * @arg @ref LL_TIM_TIM8_ETRSOURCE_GPIO
  3912. * @arg @ref LL_TIM_TIM8_ETRSOURCE_COMP1
  3913. * @arg @ref LL_TIM_TIM8_ETRSOURCE_COMP2
  3914. * @arg @ref LL_TIM_TIM8_ETRSOURCE_COMP3
  3915. * @arg @ref LL_TIM_TIM8_ETRSOURCE_COMP4
  3916. * @arg @ref LL_TIM_TIM8_ETRSOURCE_COMP5 (*)
  3917. * @arg @ref LL_TIM_TIM8_ETRSOURCE_COMP6 (*)
  3918. * @arg @ref LL_TIM_TIM8_ETRSOURCE_COMP7 (*)
  3919. * @arg @ref LL_TIM_TIM8_ETRSOURCE_ADC2_AWD1
  3920. * @arg @ref LL_TIM_TIM8_ETRSOURCE_ADC2_AWD2
  3921. * @arg @ref LL_TIM_TIM8_ETRSOURCE_ADC2_AWD3
  3922. * @arg @ref LL_TIM_TIM8_ETRSOURCE_ADC3_AWD1 (*)
  3923. * @arg @ref LL_TIM_TIM8_ETRSOURCE_ADC3_AWD2 (*)
  3924. * @arg @ref LL_TIM_TIM8_ETRSOURCE_ADC3_AWD3 (*)
  3925. *
  3926. * TIM20: any combination of ETR_RMP where (**)
  3927. *
  3928. * . . ETR_RMP can be one of the following values
  3929. * @arg @ref LL_TIM_TIM20_ETRSOURCE_GPIO (*)
  3930. * @arg @ref LL_TIM_TIM20_ETRSOURCE_COMP1 (*)
  3931. * @arg @ref LL_TIM_TIM20_ETRSOURCE_COMP2 (*)
  3932. * @arg @ref LL_TIM_TIM20_ETRSOURCE_COMP3 (*)
  3933. * @arg @ref LL_TIM_TIM20_ETRSOURCE_COMP4 (*)
  3934. * @arg @ref LL_TIM_TIM20_ETRSOURCE_COMP5 (*)
  3935. * @arg @ref LL_TIM_TIM20_ETRSOURCE_COMP6 (*)
  3936. * @arg @ref LL_TIM_TIM20_ETRSOURCE_COMP7 (*)
  3937. * @arg @ref LL_TIM_TIM20_ETRSOURCE_ADC3_AWD1 (*)
  3938. * @arg @ref LL_TIM_TIM20_ETRSOURCE_ADC3_AWD2 (*)
  3939. * @arg @ref LL_TIM_TIM20_ETRSOURCE_ADC3_AWD3 (*)
  3940. * @arg @ref LL_TIM_TIM20_ETRSOURCE_ADC5_AWD1 (*)
  3941. * @arg @ref LL_TIM_TIM20_ETRSOURCE_ADC5_AWD2 (*)
  3942. * @arg @ref LL_TIM_TIM20_ETRSOURCE_ADC5_AWD3 (*)
  3943. *
  3944. * (*) Value not defined in all devices. \n
  3945. * (**) Register not available in all devices.
  3946. * @retval None
  3947. */
  3948. __STATIC_INLINE void LL_TIM_SetETRSource(TIM_TypeDef *TIMx, uint32_t ETRSource)
  3949. {
  3950. MODIFY_REG(TIMx->AF1, TIMx_AF1_ETRSEL, ETRSource);
  3951. }
  3952. /**
  3953. * @brief Enable SMS preload.
  3954. * @note Macro IS_TIM_SMS_PRELOAD_INSTANCE(TIMx) can be used to check
  3955. * whether or not a timer instance supports the preload of SMS field in SMCR register.
  3956. * @rmtoll SMCR SMSPE LL_TIM_EnableSMSPreload
  3957. * @param TIMx Timer instance
  3958. * @retval None
  3959. */
  3960. __STATIC_INLINE void LL_TIM_EnableSMSPreload(TIM_TypeDef *TIMx)
  3961. {
  3962. SET_BIT(TIMx->SMCR, TIM_SMCR_SMSPE);
  3963. }
  3964. /**
  3965. * @brief Disable SMS preload.
  3966. * @note Macro IS_TIM_SMS_PRELOAD_INSTANCE(TIMx) can be used to check
  3967. * whether or not a timer instance supports the preload of SMS field in SMCR register.
  3968. * @rmtoll SMCR SMSPE LL_TIM_DisableSMSPreload
  3969. * @param TIMx Timer instance
  3970. * @retval None
  3971. */
  3972. __STATIC_INLINE void LL_TIM_DisableSMSPreload(TIM_TypeDef *TIMx)
  3973. {
  3974. CLEAR_BIT(TIMx->SMCR, TIM_SMCR_SMSPE);
  3975. }
  3976. /**
  3977. * @brief Indicate whether SMS preload is enabled.
  3978. * @note Macro IS_TIM_SMS_PRELOAD_INSTANCE(TIMx) can be used to check
  3979. * whether or not a timer instance supports the preload of SMS field in SMCR register.
  3980. * @rmtoll SMCR SMSPE LL_TIM_IsEnabledSMSPreload
  3981. * @param TIMx Timer instance
  3982. * @retval State of bit (1 or 0).
  3983. */
  3984. __STATIC_INLINE uint32_t LL_TIM_IsEnabledSMSPreload(const TIM_TypeDef *TIMx)
  3985. {
  3986. return ((READ_BIT(TIMx->SMCR, TIM_SMCR_SMSPE) == (TIM_SMCR_SMSPE)) ? 1UL : 0UL);
  3987. }
  3988. /**
  3989. * @brief Set the preload source of SMS.
  3990. * @note Macro IS_TIM_SMS_PRELOAD_INSTANCE(TIMx) can be used to check
  3991. * whether or not a timer instance supports the preload of SMS field in SMCR register.
  3992. * @rmtoll SMCR SMSPS LL_TIM_SetSMSPreloadSource\n
  3993. * @param TIMx Timer instance
  3994. * @param PreloadSource This parameter can be one of the following values:
  3995. * @arg @ref LL_TIM_SMSPS_TIMUPDATE
  3996. * @arg @ref LL_TIM_SMSPS_INDEX
  3997. * @retval None
  3998. */
  3999. __STATIC_INLINE void LL_TIM_SetSMSPreloadSource(TIM_TypeDef *TIMx, uint32_t PreloadSource)
  4000. {
  4001. MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMSPS, PreloadSource);
  4002. }
  4003. /**
  4004. * @brief Get the preload source of SMS.
  4005. * @note Macro IS_TIM_SMS_PRELOAD_INSTANCE(TIMx) can be used to check
  4006. * whether or not a timer instance supports the preload of SMS field in SMCR register.
  4007. * @rmtoll SMCR SMSPS LL_TIM_GetSMSPreloadSource\n
  4008. * @param TIMx Timer instance
  4009. * @retval Returned value can be one of the following values:
  4010. * @arg @ref LL_TIM_SMSPS_TIMUPDATE
  4011. * @arg @ref LL_TIM_SMSPS_INDEX
  4012. */
  4013. __STATIC_INLINE uint32_t LL_TIM_GetSMSPreloadSource(const TIM_TypeDef *TIMx)
  4014. {
  4015. return (uint32_t)(READ_BIT(TIMx->SMCR, TIM_SMCR_SMSPS));
  4016. }
  4017. /**
  4018. * @}
  4019. */
  4020. /** @defgroup TIM_LL_EF_Break_Function Break function configuration
  4021. * @{
  4022. */
  4023. /**
  4024. * @brief Enable the break function.
  4025. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  4026. * a timer instance provides a break input.
  4027. * @rmtoll BDTR BKE LL_TIM_EnableBRK
  4028. * @param TIMx Timer instance
  4029. * @retval None
  4030. */
  4031. __STATIC_INLINE void LL_TIM_EnableBRK(TIM_TypeDef *TIMx)
  4032. {
  4033. SET_BIT(TIMx->BDTR, TIM_BDTR_BKE);
  4034. }
  4035. /**
  4036. * @brief Disable the break function.
  4037. * @rmtoll BDTR BKE LL_TIM_DisableBRK
  4038. * @param TIMx Timer instance
  4039. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  4040. * a timer instance provides a break input.
  4041. * @retval None
  4042. */
  4043. __STATIC_INLINE void LL_TIM_DisableBRK(TIM_TypeDef *TIMx)
  4044. {
  4045. CLEAR_BIT(TIMx->BDTR, TIM_BDTR_BKE);
  4046. }
  4047. /**
  4048. * @brief Configure the break input.
  4049. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  4050. * a timer instance provides a break input.
  4051. * @note Bidirectional mode is only supported by advanced timer instances.
  4052. * Macro IS_TIM_ADVANCED_INSTANCE(TIMx) can be used to check whether or not
  4053. * a timer instance is an advanced-control timer.
  4054. * @note In bidirectional mode (BKBID bit set), the Break input is configured both
  4055. * in input mode and in open drain output mode. Any active Break event will
  4056. * assert a low logic level on the Break input to indicate an internal break
  4057. * event to external devices.
  4058. * @note When bidirectional mode isn't supported, BreakAFMode must be set to
  4059. * LL_TIM_BREAK_AFMODE_INPUT.
  4060. * @rmtoll BDTR BKP LL_TIM_ConfigBRK\n
  4061. * BDTR BKF LL_TIM_ConfigBRK\n
  4062. * BDTR BKBID LL_TIM_ConfigBRK
  4063. * @param TIMx Timer instance
  4064. * @param BreakPolarity This parameter can be one of the following values:
  4065. * @arg @ref LL_TIM_BREAK_POLARITY_LOW
  4066. * @arg @ref LL_TIM_BREAK_POLARITY_HIGH
  4067. * @param BreakFilter This parameter can be one of the following values:
  4068. * @arg @ref LL_TIM_BREAK_FILTER_FDIV1
  4069. * @arg @ref LL_TIM_BREAK_FILTER_FDIV1_N2
  4070. * @arg @ref LL_TIM_BREAK_FILTER_FDIV1_N4
  4071. * @arg @ref LL_TIM_BREAK_FILTER_FDIV1_N8
  4072. * @arg @ref LL_TIM_BREAK_FILTER_FDIV2_N6
  4073. * @arg @ref LL_TIM_BREAK_FILTER_FDIV2_N8
  4074. * @arg @ref LL_TIM_BREAK_FILTER_FDIV4_N6
  4075. * @arg @ref LL_TIM_BREAK_FILTER_FDIV4_N8
  4076. * @arg @ref LL_TIM_BREAK_FILTER_FDIV8_N6
  4077. * @arg @ref LL_TIM_BREAK_FILTER_FDIV8_N8
  4078. * @arg @ref LL_TIM_BREAK_FILTER_FDIV16_N5
  4079. * @arg @ref LL_TIM_BREAK_FILTER_FDIV16_N6
  4080. * @arg @ref LL_TIM_BREAK_FILTER_FDIV16_N8
  4081. * @arg @ref LL_TIM_BREAK_FILTER_FDIV32_N5
  4082. * @arg @ref LL_TIM_BREAK_FILTER_FDIV32_N6
  4083. * @arg @ref LL_TIM_BREAK_FILTER_FDIV32_N8
  4084. * @param BreakAFMode This parameter can be one of the following values:
  4085. * @arg @ref LL_TIM_BREAK_AFMODE_INPUT
  4086. * @arg @ref LL_TIM_BREAK_AFMODE_BIDIRECTIONAL
  4087. * @retval None
  4088. */
  4089. __STATIC_INLINE void LL_TIM_ConfigBRK(TIM_TypeDef *TIMx, uint32_t BreakPolarity, uint32_t BreakFilter,
  4090. uint32_t BreakAFMode)
  4091. {
  4092. MODIFY_REG(TIMx->BDTR, TIM_BDTR_BKP | TIM_BDTR_BKF | TIM_BDTR_BKBID, BreakPolarity | BreakFilter | BreakAFMode);
  4093. }
  4094. /**
  4095. * @brief Disarm the break input (when it operates in bidirectional mode).
  4096. * @note The break input can be disarmed only when it is configured in
  4097. * bidirectional mode and when when MOE is reset.
  4098. * @note Purpose is to be able to have the input voltage back to high-state,
  4099. * whatever the time constant on the output .
  4100. * @rmtoll BDTR BKDSRM LL_TIM_DisarmBRK
  4101. * @param TIMx Timer instance
  4102. * @retval None
  4103. */
  4104. __STATIC_INLINE void LL_TIM_DisarmBRK(TIM_TypeDef *TIMx)
  4105. {
  4106. SET_BIT(TIMx->BDTR, TIM_BDTR_BKDSRM);
  4107. }
  4108. /**
  4109. * @brief Enable the break 2 function.
  4110. * @note Macro IS_TIM_BKIN2_INSTANCE(TIMx) can be used to check whether or not
  4111. * a timer instance provides a second break input.
  4112. * @rmtoll BDTR BK2E LL_TIM_EnableBRK2
  4113. * @param TIMx Timer instance
  4114. * @retval None
  4115. */
  4116. __STATIC_INLINE void LL_TIM_EnableBRK2(TIM_TypeDef *TIMx)
  4117. {
  4118. SET_BIT(TIMx->BDTR, TIM_BDTR_BK2E);
  4119. }
  4120. /**
  4121. * @brief Disable the break 2 function.
  4122. * @note Macro IS_TIM_BKIN2_INSTANCE(TIMx) can be used to check whether or not
  4123. * a timer instance provides a second break input.
  4124. * @rmtoll BDTR BK2E LL_TIM_DisableBRK2
  4125. * @param TIMx Timer instance
  4126. * @retval None
  4127. */
  4128. __STATIC_INLINE void LL_TIM_DisableBRK2(TIM_TypeDef *TIMx)
  4129. {
  4130. CLEAR_BIT(TIMx->BDTR, TIM_BDTR_BK2E);
  4131. }
  4132. /**
  4133. * @brief Configure the break 2 input.
  4134. * @note Macro IS_TIM_BKIN2_INSTANCE(TIMx) can be used to check whether or not
  4135. * a timer instance provides a second break input.
  4136. * @note Bidirectional mode is only supported by advanced timer instances.
  4137. * Macro IS_TIM_ADVANCED_INSTANCE(TIMx) can be used to check whether or not
  4138. * a timer instance is an advanced-control timer.
  4139. * @note In bidirectional mode (BK2BID bit set), the Break 2 input is configured both
  4140. * in input mode and in open drain output mode. Any active Break event will
  4141. * assert a low logic level on the Break 2 input to indicate an internal break
  4142. * event to external devices.
  4143. * @note When bidirectional mode isn't supported, Break2AFMode must be set to
  4144. * LL_TIM_BREAK2_AFMODE_INPUT.
  4145. * @rmtoll BDTR BK2P LL_TIM_ConfigBRK2\n
  4146. * BDTR BK2F LL_TIM_ConfigBRK2\n
  4147. * BDTR BK2BID LL_TIM_ConfigBRK2
  4148. * @param TIMx Timer instance
  4149. * @param Break2Polarity This parameter can be one of the following values:
  4150. * @arg @ref LL_TIM_BREAK2_POLARITY_LOW
  4151. * @arg @ref LL_TIM_BREAK2_POLARITY_HIGH
  4152. * @param Break2Filter This parameter can be one of the following values:
  4153. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV1
  4154. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV1_N2
  4155. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV1_N4
  4156. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV1_N8
  4157. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV2_N6
  4158. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV2_N8
  4159. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV4_N6
  4160. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV4_N8
  4161. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV8_N6
  4162. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV8_N8
  4163. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV16_N5
  4164. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV16_N6
  4165. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV16_N8
  4166. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV32_N5
  4167. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV32_N6
  4168. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV32_N8
  4169. * @param Break2AFMode This parameter can be one of the following values:
  4170. * @arg @ref LL_TIM_BREAK2_AFMODE_INPUT
  4171. * @arg @ref LL_TIM_BREAK2_AFMODE_BIDIRECTIONAL
  4172. * @retval None
  4173. */
  4174. __STATIC_INLINE void LL_TIM_ConfigBRK2(TIM_TypeDef *TIMx, uint32_t Break2Polarity, uint32_t Break2Filter,
  4175. uint32_t Break2AFMode)
  4176. {
  4177. MODIFY_REG(TIMx->BDTR, TIM_BDTR_BK2P | TIM_BDTR_BK2F | TIM_BDTR_BK2BID, Break2Polarity | Break2Filter | Break2AFMode);
  4178. }
  4179. /**
  4180. * @brief Disarm the break 2 input (when it operates in bidirectional mode).
  4181. * @note The break 2 input can be disarmed only when it is configured in
  4182. * bidirectional mode and when when MOE is reset.
  4183. * @note Purpose is to be able to have the input voltage back to high-state,
  4184. * whatever the time constant on the output.
  4185. * @rmtoll BDTR BK2DSRM LL_TIM_DisarmBRK2
  4186. * @param TIMx Timer instance
  4187. * @retval None
  4188. */
  4189. __STATIC_INLINE void LL_TIM_DisarmBRK2(TIM_TypeDef *TIMx)
  4190. {
  4191. SET_BIT(TIMx->BDTR, TIM_BDTR_BK2DSRM);
  4192. }
  4193. /**
  4194. * @brief Select the outputs off state (enabled v.s. disabled) in Idle and Run modes.
  4195. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  4196. * a timer instance provides a break input.
  4197. * @rmtoll BDTR OSSI LL_TIM_SetOffStates\n
  4198. * BDTR OSSR LL_TIM_SetOffStates
  4199. * @param TIMx Timer instance
  4200. * @param OffStateIdle This parameter can be one of the following values:
  4201. * @arg @ref LL_TIM_OSSI_DISABLE
  4202. * @arg @ref LL_TIM_OSSI_ENABLE
  4203. * @param OffStateRun This parameter can be one of the following values:
  4204. * @arg @ref LL_TIM_OSSR_DISABLE
  4205. * @arg @ref LL_TIM_OSSR_ENABLE
  4206. * @retval None
  4207. */
  4208. __STATIC_INLINE void LL_TIM_SetOffStates(TIM_TypeDef *TIMx, uint32_t OffStateIdle, uint32_t OffStateRun)
  4209. {
  4210. MODIFY_REG(TIMx->BDTR, TIM_BDTR_OSSI | TIM_BDTR_OSSR, OffStateIdle | OffStateRun);
  4211. }
  4212. /**
  4213. * @brief Enable automatic output (MOE can be set by software or automatically when a break input is active).
  4214. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  4215. * a timer instance provides a break input.
  4216. * @rmtoll BDTR AOE LL_TIM_EnableAutomaticOutput
  4217. * @param TIMx Timer instance
  4218. * @retval None
  4219. */
  4220. __STATIC_INLINE void LL_TIM_EnableAutomaticOutput(TIM_TypeDef *TIMx)
  4221. {
  4222. SET_BIT(TIMx->BDTR, TIM_BDTR_AOE);
  4223. }
  4224. /**
  4225. * @brief Disable automatic output (MOE can be set only by software).
  4226. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  4227. * a timer instance provides a break input.
  4228. * @rmtoll BDTR AOE LL_TIM_DisableAutomaticOutput
  4229. * @param TIMx Timer instance
  4230. * @retval None
  4231. */
  4232. __STATIC_INLINE void LL_TIM_DisableAutomaticOutput(TIM_TypeDef *TIMx)
  4233. {
  4234. CLEAR_BIT(TIMx->BDTR, TIM_BDTR_AOE);
  4235. }
  4236. /**
  4237. * @brief Indicate whether automatic output is enabled.
  4238. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  4239. * a timer instance provides a break input.
  4240. * @rmtoll BDTR AOE LL_TIM_IsEnabledAutomaticOutput
  4241. * @param TIMx Timer instance
  4242. * @retval State of bit (1 or 0).
  4243. */
  4244. __STATIC_INLINE uint32_t LL_TIM_IsEnabledAutomaticOutput(const TIM_TypeDef *TIMx)
  4245. {
  4246. return ((READ_BIT(TIMx->BDTR, TIM_BDTR_AOE) == (TIM_BDTR_AOE)) ? 1UL : 0UL);
  4247. }
  4248. /**
  4249. * @brief Enable the outputs (set the MOE bit in TIMx_BDTR register).
  4250. * @note The MOE bit in TIMx_BDTR register allows to enable /disable the outputs by
  4251. * software and is reset in case of break or break2 event
  4252. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  4253. * a timer instance provides a break input.
  4254. * @rmtoll BDTR MOE LL_TIM_EnableAllOutputs
  4255. * @param TIMx Timer instance
  4256. * @retval None
  4257. */
  4258. __STATIC_INLINE void LL_TIM_EnableAllOutputs(TIM_TypeDef *TIMx)
  4259. {
  4260. SET_BIT(TIMx->BDTR, TIM_BDTR_MOE);
  4261. }
  4262. /**
  4263. * @brief Disable the outputs (reset the MOE bit in TIMx_BDTR register).
  4264. * @note The MOE bit in TIMx_BDTR register allows to enable /disable the outputs by
  4265. * software and is reset in case of break or break2 event.
  4266. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  4267. * a timer instance provides a break input.
  4268. * @rmtoll BDTR MOE LL_TIM_DisableAllOutputs
  4269. * @param TIMx Timer instance
  4270. * @retval None
  4271. */
  4272. __STATIC_INLINE void LL_TIM_DisableAllOutputs(TIM_TypeDef *TIMx)
  4273. {
  4274. CLEAR_BIT(TIMx->BDTR, TIM_BDTR_MOE);
  4275. }
  4276. /**
  4277. * @brief Indicates whether outputs are enabled.
  4278. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  4279. * a timer instance provides a break input.
  4280. * @rmtoll BDTR MOE LL_TIM_IsEnabledAllOutputs
  4281. * @param TIMx Timer instance
  4282. * @retval State of bit (1 or 0).
  4283. */
  4284. __STATIC_INLINE uint32_t LL_TIM_IsEnabledAllOutputs(const TIM_TypeDef *TIMx)
  4285. {
  4286. return ((READ_BIT(TIMx->BDTR, TIM_BDTR_MOE) == (TIM_BDTR_MOE)) ? 1UL : 0UL);
  4287. }
  4288. /**
  4289. * @brief Enable the signals connected to the designated timer break input.
  4290. * @note Macro IS_TIM_BREAKSOURCE_INSTANCE(TIMx) can be used to check whether
  4291. * or not a timer instance allows for break input selection.
  4292. * @rmtoll AF1 BKINE LL_TIM_EnableBreakInputSource\n
  4293. * AF1 BKCMP1E LL_TIM_EnableBreakInputSource\n
  4294. * AF1 BKCMP2E LL_TIM_EnableBreakInputSource\n
  4295. * AF1 BKCMP3E LL_TIM_EnableBreakInputSource\n
  4296. * AF1 BKCMP4E LL_TIM_EnableBreakInputSource\n
  4297. * AF1 BKCMP5E LL_TIM_EnableBreakInputSource\n
  4298. * AF1 BKCMP6E LL_TIM_EnableBreakInputSource\n
  4299. * AF1 BKCMP7E LL_TIM_EnableBreakInputSource\n
  4300. * AF2 BK2NE LL_TIM_EnableBreakInputSource\n
  4301. * AF2 BK2CMP1E LL_TIM_EnableBreakInputSource\n
  4302. * AF2 BK2CMP2E LL_TIM_EnableBreakInputSource\n
  4303. * AF2 BK2CMP3E LL_TIM_EnableBreakInputSource\n
  4304. * AF2 BK2CMP4E LL_TIM_EnableBreakInputSource\n
  4305. * AF2 BK2CMP5E LL_TIM_EnableBreakInputSource\n
  4306. * AF2 BK2CMP6E LL_TIM_EnableBreakInputSource\n
  4307. * AF2 BK2CMP7E LL_TIM_EnableBreakInputSource
  4308. * @param TIMx Timer instance
  4309. * @param BreakInput This parameter can be one of the following values:
  4310. * @arg @ref LL_TIM_BREAK_INPUT_BKIN
  4311. * @arg @ref LL_TIM_BREAK_INPUT_BKIN2
  4312. * @param Source This parameter can be one of the following values:
  4313. * @arg @ref LL_TIM_BKIN_SOURCE_BKIN
  4314. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP1
  4315. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP2
  4316. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP3
  4317. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP4
  4318. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP5 (*)
  4319. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP6 (*)
  4320. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP7 (*)
  4321. *
  4322. * (*) Value not defined in all devices.
  4323. * @retval None
  4324. */
  4325. __STATIC_INLINE void LL_TIM_EnableBreakInputSource(TIM_TypeDef *TIMx, uint32_t BreakInput, uint32_t Source)
  4326. {
  4327. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->AF1) + BreakInput));
  4328. SET_BIT(*pReg, Source);
  4329. }
  4330. /**
  4331. * @brief Disable the signals connected to the designated timer break input.
  4332. * @note Macro IS_TIM_BREAKSOURCE_INSTANCE(TIMx) can be used to check whether
  4333. * or not a timer instance allows for break input selection.
  4334. * @rmtoll AF1 BKINE LL_TIM_DisableBreakInputSource\n
  4335. * AF1 BKCMP1E LL_TIM_DisableBreakInputSource\n
  4336. * AF1 BKCMP2E LL_TIM_DisableBreakInputSource\n
  4337. * AF1 BKCMP3E LL_TIM_DisableBreakInputSource\n
  4338. * AF1 BKCMP4E LL_TIM_DisableBreakInputSource\n
  4339. * AF1 BKCMP5E LL_TIM_DisableBreakInputSource\n
  4340. * AF1 BKCMP6E LL_TIM_DisableBreakInputSource\n
  4341. * AF1 BKCMP7E LL_TIM_DisableBreakInputSource\n
  4342. * AF2 BK2INE LL_TIM_DisableBreakInputSource\n
  4343. * AF2 BK2CMP1E LL_TIM_DisableBreakInputSource\n
  4344. * AF2 BK2CMP2E LL_TIM_DisableBreakInputSource\n
  4345. * AF2 BK2CMP3E LL_TIM_DisableBreakInputSource\n
  4346. * AF2 BK2CMP4E LL_TIM_DisableBreakInputSource\n
  4347. * AF2 BK2CMP5E LL_TIM_DisableBreakInputSource\n
  4348. * AF2 BK2CMP6E LL_TIM_DisableBreakInputSource\n
  4349. * AF2 BK2CMP7E LL_TIM_DisableBreakInputSource
  4350. * @param TIMx Timer instance
  4351. * @param BreakInput This parameter can be one of the following values:
  4352. * @arg @ref LL_TIM_BREAK_INPUT_BKIN
  4353. * @arg @ref LL_TIM_BREAK_INPUT_BKIN2
  4354. * @param Source This parameter can be one of the following values:
  4355. * @arg @ref LL_TIM_BKIN_SOURCE_BKIN
  4356. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP1
  4357. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP2
  4358. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP3
  4359. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP4
  4360. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP5 (*)
  4361. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP6 (*)
  4362. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP7 (*)
  4363. *
  4364. * (*) Value not defined in all devices.
  4365. * @retval None
  4366. */
  4367. __STATIC_INLINE void LL_TIM_DisableBreakInputSource(TIM_TypeDef *TIMx, uint32_t BreakInput, uint32_t Source)
  4368. {
  4369. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->AF1) + BreakInput));
  4370. CLEAR_BIT(*pReg, Source);
  4371. }
  4372. /**
  4373. * @brief Set the polarity of the break signal for the timer break input.
  4374. * @note Macro IS_TIM_BREAKSOURCE_INSTANCE(TIMx) can be used to check whether
  4375. * or not a timer instance allows for break input selection.
  4376. * @rmtoll AF1 BKINP LL_TIM_SetBreakInputSourcePolarity\n
  4377. * AF1 BKCMP1P LL_TIM_SetBreakInputSourcePolarity\n
  4378. * AF1 BKCMP2P LL_TIM_SetBreakInputSourcePolarity\n
  4379. * AF1 BKCMP3P LL_TIM_SetBreakInputSourcePolarity\n
  4380. * AF1 BKCMP4P LL_TIM_SetBreakInputSourcePolarity\n
  4381. * AF1 BKCMP5P LL_TIM_SetBreakInputSourcePolarity\n
  4382. * AF1 BKCMP6P LL_TIM_SetBreakInputSourcePolarity\n
  4383. * AF1 BKCMP7P LL_TIM_SetBreakInputSourcePolarity\n
  4384. * AF2 BK2INP LL_TIM_SetBreakInputSourcePolarity\n
  4385. * AF2 BK2CMP1P LL_TIM_SetBreakInputSourcePolarity\n
  4386. * AF2 BK2CMP2P LL_TIM_SetBreakInputSourcePolarity\n
  4387. * AF2 BK2CMP3P LL_TIM_SetBreakInputSourcePolarity\n
  4388. * AF2 BK2CMP4P LL_TIM_SetBreakInputSourcePolarity\n
  4389. * AF2 BK2CMP5P LL_TIM_SetBreakInputSourcePolarity\n
  4390. * AF2 BK2CMP6P LL_TIM_SetBreakInputSourcePolarity\n
  4391. * AF2 BK2CMP7P LL_TIM_SetBreakInputSourcePolarity
  4392. * @param TIMx Timer instance
  4393. * @param BreakInput This parameter can be one of the following values:
  4394. * @arg @ref LL_TIM_BREAK_INPUT_BKIN
  4395. * @arg @ref LL_TIM_BREAK_INPUT_BKIN2
  4396. * @param Source This parameter can be one of the following values:
  4397. * @arg @ref LL_TIM_BKIN_SOURCE_BKIN
  4398. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP1
  4399. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP2
  4400. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP3
  4401. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP4
  4402. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP5 (*)
  4403. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP6 (*)
  4404. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP7 (*)
  4405. * @param Polarity This parameter can be one of the following values:
  4406. * @arg @ref LL_TIM_BKIN_POLARITY_LOW
  4407. * @arg @ref LL_TIM_BKIN_POLARITY_HIGH
  4408. *
  4409. * (*) Value not defined in all devices.
  4410. * @retval None
  4411. */
  4412. __STATIC_INLINE void LL_TIM_SetBreakInputSourcePolarity(TIM_TypeDef *TIMx, uint32_t BreakInput, uint32_t Source,
  4413. uint32_t Polarity)
  4414. {
  4415. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->AF1) + BreakInput));
  4416. MODIFY_REG(*pReg, (TIMx_AF1_BKINP << TIM_POSITION_BRK_SOURCE), (Polarity << TIM_POSITION_BRK_SOURCE));
  4417. }
  4418. /**
  4419. * @brief Enable asymmetrical deadtime.
  4420. * @note Macro IS_TIM_DEADTIME_ASYMMETRICAL_INSTANCE(TIMx) can be used to check whether or not
  4421. * a timer instance provides asymmetrical deadtime.
  4422. * @rmtoll DTR2 DTAE LL_TIM_EnableAsymmetricalDeadTime
  4423. * @param TIMx Timer instance
  4424. * @retval None
  4425. */
  4426. __STATIC_INLINE void LL_TIM_EnableAsymmetricalDeadTime(TIM_TypeDef *TIMx)
  4427. {
  4428. SET_BIT(TIMx->DTR2, TIM_DTR2_DTAE);
  4429. }
  4430. /**
  4431. * @brief Disable asymmetrical dead-time.
  4432. * @note Macro IS_TIM_DEADTIME_ASYMMETRICAL_INSTANCE(TIMx) can be used to check whether or not
  4433. * a timer instance provides asymmetrical deadtime.
  4434. * @rmtoll DTR2 DTAE LL_TIM_DisableAsymmetricalDeadTime
  4435. * @param TIMx Timer instance
  4436. * @retval None
  4437. */
  4438. __STATIC_INLINE void LL_TIM_DisableAsymmetricalDeadTime(TIM_TypeDef *TIMx)
  4439. {
  4440. CLEAR_BIT(TIMx->DTR2, TIM_DTR2_DTAE);
  4441. }
  4442. /**
  4443. * @brief Indicates whether asymmetrical deadtime is activated.
  4444. * @note Macro IS_TIM_DEADTIME_ASYMMETRICAL_INSTANCE(TIMx) can be used to check whether or not
  4445. * a timer instance provides asymmetrical deadtime.
  4446. * @rmtoll DTR2 DTAE LL_TIM_IsEnabledAsymmetricalDeadTime
  4447. * @param TIMx Timer instance
  4448. * @retval State of bit (1 or 0).
  4449. */
  4450. __STATIC_INLINE uint32_t LL_TIM_IsEnabledAsymmetricalDeadTime(const TIM_TypeDef *TIMx)
  4451. {
  4452. return ((READ_BIT(TIMx->DTR2, TIM_DTR2_DTAE) == (TIM_DTR2_DTAE)) ? 1UL : 0UL);
  4453. }
  4454. /**
  4455. * @brief Set the falling edge dead-time delay (delay inserted between the falling edge of the OCxREF signal and the
  4456. * rising edge of OCxN signals).
  4457. * @note Macro IS_TIM_DEADTIME_ASYMMETRICAL_INSTANCE(TIMx) can be used to check whether or not
  4458. * asymmetrical dead-time insertion feature is supported by a timer instance.
  4459. * @note Helper macro @ref __LL_TIM_CALC_DEADTIME can be used to calculate the DeadTime parameter
  4460. * @note This bit-field can not be modified as long as LOCK level 1, 2 or 3 has been programmed
  4461. * (LOCK bits in TIMx_BDTR register).
  4462. * @rmtoll DTR2 DTGF LL_TIM_SetFallingDeadTime
  4463. * @param TIMx Timer instance
  4464. * @param DeadTime between Min_Data=0 and Max_Data=255
  4465. * @retval None
  4466. */
  4467. __STATIC_INLINE void LL_TIM_SetFallingDeadTime(TIM_TypeDef *TIMx, uint32_t DeadTime)
  4468. {
  4469. MODIFY_REG(TIMx->DTR2, TIM_DTR2_DTGF, DeadTime);
  4470. }
  4471. /**
  4472. * @brief Get the falling edge dead-time delay (delay inserted between the falling edge of the OCxREF signal and
  4473. * the rising edge of OCxN signals).
  4474. * @note Macro IS_TIM_DEADTIME_ASYMMETRICAL_INSTANCE(TIMx) can be used to check whether or not
  4475. * asymmetrical dead-time insertion feature is supported by a timer instance.
  4476. * @note This bit-field can not be modified as long as LOCK level 1, 2 or 3 has been programmed
  4477. * (LOCK bits in TIMx_BDTR register).
  4478. * @rmtoll DTR2 DTGF LL_TIM_GetFallingDeadTime
  4479. * @param TIMx Timer instance
  4480. * @retval Returned value can be between Min_Data=0 and Max_Data=255:
  4481. */
  4482. __STATIC_INLINE uint32_t LL_TIM_GetFallingDeadTime(const TIM_TypeDef *TIMx)
  4483. {
  4484. return (uint32_t)(READ_BIT(TIMx->DTR2, TIM_DTR2_DTGF));
  4485. }
  4486. /**
  4487. * @brief Enable deadtime preload.
  4488. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  4489. * a timer instance provides deadtime preload.
  4490. * @rmtoll DTR2 DTPE LL_TIM_EnableDeadTimePreload
  4491. * @param TIMx Timer instance
  4492. * @retval None
  4493. */
  4494. __STATIC_INLINE void LL_TIM_EnableDeadTimePreload(TIM_TypeDef *TIMx)
  4495. {
  4496. SET_BIT(TIMx->DTR2, TIM_DTR2_DTPE);
  4497. }
  4498. /**
  4499. * @brief Disable dead-time preload.
  4500. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  4501. * a timer instance provides deadtime preload.
  4502. * @rmtoll DTR2 DTPE LL_TIM_DisableDeadTimePreload
  4503. * @param TIMx Timer instance
  4504. * @retval None
  4505. */
  4506. __STATIC_INLINE void LL_TIM_DisableDeadTimePreload(TIM_TypeDef *TIMx)
  4507. {
  4508. CLEAR_BIT(TIMx->DTR2, TIM_DTR2_DTPE);
  4509. }
  4510. /**
  4511. * @brief Indicates whether deadtime preload is activated.
  4512. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  4513. * a timer instance provides deadtime preload.
  4514. * @rmtoll DTR2 DTPE LL_TIM_IsEnabledDeadTimePreload
  4515. * @param TIMx Timer instance
  4516. * @retval State of bit (1 or 0).
  4517. */
  4518. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDeadTimePreload(const TIM_TypeDef *TIMx)
  4519. {
  4520. return ((READ_BIT(TIMx->DTR2, TIM_DTR2_DTPE) == (TIM_DTR2_DTPE)) ? 1UL : 0UL);
  4521. }
  4522. /**
  4523. * @}
  4524. */
  4525. /** @defgroup TIM_LL_EF_DMA_Burst_Mode DMA burst mode configuration
  4526. * @{
  4527. */
  4528. /**
  4529. * @brief Configures the timer DMA burst feature.
  4530. * @note Macro IS_TIM_DMABURST_INSTANCE(TIMx) can be used to check whether or
  4531. * not a timer instance supports the DMA burst mode.
  4532. * @rmtoll DCR DBL LL_TIM_ConfigDMABurst\n
  4533. * DCR DBA LL_TIM_ConfigDMABurst
  4534. * @param TIMx Timer instance
  4535. * @param DMABurstBaseAddress This parameter can be one of the following values:
  4536. * @arg @ref LL_TIM_DMABURST_BASEADDR_CR1
  4537. * @arg @ref LL_TIM_DMABURST_BASEADDR_CR2
  4538. * @arg @ref LL_TIM_DMABURST_BASEADDR_SMCR
  4539. * @arg @ref LL_TIM_DMABURST_BASEADDR_DIER
  4540. * @arg @ref LL_TIM_DMABURST_BASEADDR_SR
  4541. * @arg @ref LL_TIM_DMABURST_BASEADDR_EGR
  4542. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCMR1
  4543. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCMR2
  4544. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCER
  4545. * @arg @ref LL_TIM_DMABURST_BASEADDR_CNT
  4546. * @arg @ref LL_TIM_DMABURST_BASEADDR_PSC
  4547. * @arg @ref LL_TIM_DMABURST_BASEADDR_ARR
  4548. * @arg @ref LL_TIM_DMABURST_BASEADDR_RCR
  4549. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR1
  4550. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR2
  4551. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR3
  4552. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR4
  4553. * @arg @ref LL_TIM_DMABURST_BASEADDR_BDTR
  4554. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCMR3
  4555. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR5
  4556. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR6
  4557. * @arg @ref LL_TIM_DMABURST_BASEADDR_DTR2
  4558. * @arg @ref LL_TIM_DMABURST_BASEADDR_ECR
  4559. * @arg @ref LL_TIM_DMABURST_BASEADDR_TISEL
  4560. * @arg @ref LL_TIM_DMABURST_BASEADDR_AF1
  4561. * @arg @ref LL_TIM_DMABURST_BASEADDR_AF2
  4562. * @arg @ref LL_TIM_DMABURST_BASEADDR_OR
  4563. * @param DMABurstLength This parameter can be one of the following values:
  4564. * @arg @ref LL_TIM_DMABURST_LENGTH_1TRANSFER
  4565. * @arg @ref LL_TIM_DMABURST_LENGTH_2TRANSFERS
  4566. * @arg @ref LL_TIM_DMABURST_LENGTH_3TRANSFERS
  4567. * @arg @ref LL_TIM_DMABURST_LENGTH_4TRANSFERS
  4568. * @arg @ref LL_TIM_DMABURST_LENGTH_5TRANSFERS
  4569. * @arg @ref LL_TIM_DMABURST_LENGTH_6TRANSFERS
  4570. * @arg @ref LL_TIM_DMABURST_LENGTH_7TRANSFERS
  4571. * @arg @ref LL_TIM_DMABURST_LENGTH_8TRANSFERS
  4572. * @arg @ref LL_TIM_DMABURST_LENGTH_9TRANSFERS
  4573. * @arg @ref LL_TIM_DMABURST_LENGTH_10TRANSFERS
  4574. * @arg @ref LL_TIM_DMABURST_LENGTH_11TRANSFERS
  4575. * @arg @ref LL_TIM_DMABURST_LENGTH_12TRANSFERS
  4576. * @arg @ref LL_TIM_DMABURST_LENGTH_13TRANSFERS
  4577. * @arg @ref LL_TIM_DMABURST_LENGTH_14TRANSFERS
  4578. * @arg @ref LL_TIM_DMABURST_LENGTH_15TRANSFERS
  4579. * @arg @ref LL_TIM_DMABURST_LENGTH_16TRANSFERS
  4580. * @arg @ref LL_TIM_DMABURST_LENGTH_17TRANSFERS
  4581. * @arg @ref LL_TIM_DMABURST_LENGTH_18TRANSFERS
  4582. * @arg @ref LL_TIM_DMABURST_LENGTH_19TRANSFERS
  4583. * @arg @ref LL_TIM_DMABURST_LENGTH_20TRANSFERS
  4584. * @arg @ref LL_TIM_DMABURST_LENGTH_21TRANSFERS
  4585. * @arg @ref LL_TIM_DMABURST_LENGTH_22TRANSFERS
  4586. * @arg @ref LL_TIM_DMABURST_LENGTH_23TRANSFERS
  4587. * @arg @ref LL_TIM_DMABURST_LENGTH_24TRANSFERS
  4588. * @arg @ref LL_TIM_DMABURST_LENGTH_25TRANSFERS
  4589. * @arg @ref LL_TIM_DMABURST_LENGTH_26TRANSFERS
  4590. * @retval None
  4591. */
  4592. __STATIC_INLINE void LL_TIM_ConfigDMABurst(TIM_TypeDef *TIMx, uint32_t DMABurstBaseAddress, uint32_t DMABurstLength)
  4593. {
  4594. MODIFY_REG(TIMx->DCR, (TIM_DCR_DBL | TIM_DCR_DBA), (DMABurstBaseAddress | DMABurstLength));
  4595. }
  4596. /**
  4597. * @}
  4598. */
  4599. /** @defgroup TIM_LL_EF_Encoder Encoder configuration
  4600. * @{
  4601. */
  4602. /**
  4603. * @brief Enable encoder index.
  4604. * @note Macro IS_TIM_INDEX_INSTANCE(TIMx) can be used to check whether or not
  4605. * a timer instance provides an index input.
  4606. * @rmtoll ECR IE LL_TIM_EnableEncoderIndex
  4607. * @param TIMx Timer instance
  4608. * @retval None
  4609. */
  4610. __STATIC_INLINE void LL_TIM_EnableEncoderIndex(TIM_TypeDef *TIMx)
  4611. {
  4612. SET_BIT(TIMx->ECR, TIM_ECR_IE);
  4613. }
  4614. /**
  4615. * @brief Disable encoder index.
  4616. * @note Macro IS_TIM_INDEX_INSTANCE(TIMx) can be used to check whether or not
  4617. * a timer instance provides an index input.
  4618. * @rmtoll ECR IE LL_TIM_DisableEncoderIndex
  4619. * @param TIMx Timer instance
  4620. * @retval None
  4621. */
  4622. __STATIC_INLINE void LL_TIM_DisableEncoderIndex(TIM_TypeDef *TIMx)
  4623. {
  4624. CLEAR_BIT(TIMx->ECR, TIM_ECR_IE);
  4625. }
  4626. /**
  4627. * @brief Indicate whether encoder index is enabled.
  4628. * @note Macro IS_TIM_INDEX_INSTANCE(TIMx) can be used to check whether or not
  4629. * a timer instance provides an index input.
  4630. * @rmtoll ECR IE LL_TIM_IsEnabledEncoderIndex
  4631. * @param TIMx Timer instance
  4632. * @retval State of bit (1 or 0).
  4633. */
  4634. __STATIC_INLINE uint32_t LL_TIM_IsEnabledEncoderIndex(const TIM_TypeDef *TIMx)
  4635. {
  4636. return ((READ_BIT(TIMx->ECR, TIM_ECR_IE) == (TIM_ECR_IE)) ? 1U : 0U);
  4637. }
  4638. /**
  4639. * @brief Set index direction
  4640. * @note Macro IS_TIM_INDEX_INSTANCE(TIMx) can be used to check whether or not
  4641. * a timer instance provides an index input.
  4642. * @rmtoll ECR IDIR LL_TIM_SetIndexDirection
  4643. * @param TIMx Timer instance
  4644. * @param IndexDirection This parameter can be one of the following values:
  4645. * @arg @ref LL_TIM_INDEX_UP_DOWN
  4646. * @arg @ref LL_TIM_INDEX_UP
  4647. * @arg @ref LL_TIM_INDEX_DOWN
  4648. * @retval None
  4649. */
  4650. __STATIC_INLINE void LL_TIM_SetIndexDirection(TIM_TypeDef *TIMx, uint32_t IndexDirection)
  4651. {
  4652. MODIFY_REG(TIMx->ECR, TIM_ECR_IDIR, IndexDirection);
  4653. }
  4654. /**
  4655. * @brief Get actual index direction
  4656. * @note Macro IS_TIM_INDEX_INSTANCE(TIMx) can be used to check whether or not
  4657. * a timer instance provides an index input.
  4658. * @rmtoll ECR IDIR LL_TIM_GetIndexDirection
  4659. * @param TIMx Timer instance
  4660. * @retval Returned value can be one of the following values:
  4661. * @arg @ref LL_TIM_INDEX_UP_DOWN
  4662. * @arg @ref LL_TIM_INDEX_UP
  4663. * @arg @ref LL_TIM_INDEX_DOWN
  4664. */
  4665. __STATIC_INLINE uint32_t LL_TIM_GetIndexDirection(const TIM_TypeDef *TIMx)
  4666. {
  4667. return (uint32_t)(READ_BIT(TIMx->ECR, TIM_ECR_IDIR));
  4668. }
  4669. /**
  4670. * @brief Enable first index.
  4671. * @note Macro IS_TIM_INDEX_INSTANCE(TIMx) can be used to check whether or not
  4672. * a timer instance provides an index input.
  4673. * @rmtoll ECR FIDX LL_TIM_EnableFirstIndex
  4674. * @param TIMx Timer instance
  4675. * @retval None
  4676. */
  4677. __STATIC_INLINE void LL_TIM_EnableFirstIndex(TIM_TypeDef *TIMx)
  4678. {
  4679. SET_BIT(TIMx->ECR, TIM_ECR_FIDX);
  4680. }
  4681. /**
  4682. * @brief Disable first index.
  4683. * @note Macro IS_TIM_INDEX_INSTANCE(TIMx) can be used to check whether or not
  4684. * a timer instance provides an index input.
  4685. * @rmtoll ECR FIDX LL_TIM_DisableFirstIndex
  4686. * @param TIMx Timer instance
  4687. * @retval None
  4688. */
  4689. __STATIC_INLINE void LL_TIM_DisableFirstIndex(TIM_TypeDef *TIMx)
  4690. {
  4691. CLEAR_BIT(TIMx->ECR, TIM_ECR_FIDX);
  4692. }
  4693. /**
  4694. * @brief Indicates whether first index is enabled.
  4695. * @note Macro IS_TIM_INDEX_INSTANCE(TIMx) can be used to check whether or not
  4696. * a timer instance provides an index input.
  4697. * @rmtoll ECR FIDX LL_TIM_IsEnabledFirstIndex
  4698. * @param TIMx Timer instance
  4699. * @retval State of bit (1 or 0).
  4700. */
  4701. __STATIC_INLINE uint32_t LL_TIM_IsEnabledFirstIndex(const TIM_TypeDef *TIMx)
  4702. {
  4703. return ((READ_BIT(TIMx->ECR, TIM_ECR_FIDX) == (TIM_ECR_FIDX)) ? 1UL : 0UL);
  4704. }
  4705. /**
  4706. * @brief Set index positioning
  4707. * @note Macro IS_TIM_INDEX_INSTANCE(TIMx) can be used to check whether or not
  4708. * a timer instance provides an index input.
  4709. * @rmtoll ECR IPOS LL_TIM_SetIndexPositionning
  4710. * @param TIMx Timer instance
  4711. * @param IndexPositionning This parameter can be one of the following values:
  4712. * @arg @ref LL_TIM_INDEX_POSITION_DOWN_DOWN
  4713. * @arg @ref LL_TIM_INDEX_POSITION_DOWN_UP
  4714. * @arg @ref LL_TIM_INDEX_POSITION_UP_DOWN
  4715. * @arg @ref LL_TIM_INDEX_POSITION_UP_UP
  4716. * @arg @ref LL_TIM_INDEX_POSITION_DOWN
  4717. * @arg @ref LL_TIM_INDEX_POSITION_UP
  4718. * @retval None
  4719. */
  4720. __STATIC_INLINE void LL_TIM_SetIndexPositionning(TIM_TypeDef *TIMx, uint32_t IndexPositionning)
  4721. {
  4722. MODIFY_REG(TIMx->ECR, TIM_ECR_IPOS, IndexPositionning);
  4723. }
  4724. /**
  4725. * @brief Get actual index positioning
  4726. * @note Macro IS_TIM_INDEX_INSTANCE(TIMx) can be used to check whether or not
  4727. * a timer instance provides an index input.
  4728. * @rmtoll ECR IPOS LL_TIM_GetIndexPositionning
  4729. * @param TIMx Timer instance
  4730. * @retval Returned value can be one of the following values:
  4731. * @arg @ref LL_TIM_INDEX_POSITION_DOWN_DOWN
  4732. * @arg @ref LL_TIM_INDEX_POSITION_DOWN_UP
  4733. * @arg @ref LL_TIM_INDEX_POSITION_UP_DOWN
  4734. * @arg @ref LL_TIM_INDEX_POSITION_UP_UP
  4735. * @arg @ref LL_TIM_INDEX_POSITION_DOWN
  4736. * @arg @ref LL_TIM_INDEX_POSITION_UP
  4737. */
  4738. __STATIC_INLINE uint32_t LL_TIM_GetIndexPositionning(const TIM_TypeDef *TIMx)
  4739. {
  4740. return (uint32_t)(READ_BIT(TIMx->ECR, TIM_ECR_IPOS));
  4741. }
  4742. /**
  4743. * @brief Configure encoder index.
  4744. * @note Macro IS_TIM_INDEX_INSTANCE(TIMx) can be used to check whether or not
  4745. * a timer instance provides an index input.
  4746. * @rmtoll ECR IDIR LL_TIM_ConfigIDX\n
  4747. * ECR FIDX LL_TIM_ConfigIDX\n
  4748. * ECR IPOS LL_TIM_ConfigIDX
  4749. * @param TIMx Timer instance
  4750. * @param Configuration This parameter must be a combination of all the following values:
  4751. * @arg @ref LL_TIM_INDEX_UP or @ref LL_TIM_INDEX_DOWN or @ref LL_TIM_INDEX_UP_DOWN
  4752. * @arg @ref LL_TIM_INDEX_ALL or @ref LL_TIM_INDEX_FIRST_ONLY
  4753. * @arg @ref LL_TIM_INDEX_POSITION_DOWN_DOWN or ... or @ref LL_TIM_INDEX_POSITION_UP
  4754. * @retval None
  4755. */
  4756. __STATIC_INLINE void LL_TIM_ConfigIDX(TIM_TypeDef *TIMx, uint32_t Configuration)
  4757. {
  4758. MODIFY_REG(TIMx->ECR, TIM_ECR_IDIR | TIM_ECR_FIDX | TIM_ECR_IPOS, Configuration);
  4759. }
  4760. /**
  4761. * @}
  4762. */
  4763. /** @defgroup TIM_LL_EF_Timer_Inputs_Remapping Timer input remapping
  4764. * @{
  4765. */
  4766. /**
  4767. * @brief Remap TIM inputs (input channel, internal/external triggers).
  4768. * @note Macro IS_TIM_REMAP_INSTANCE(TIMx) can be used to check whether or not
  4769. * a some timer inputs can be remapped.
  4770. * @rmtoll TIM1_TISEL TI1SEL LL_TIM_SetRemap\n
  4771. * TIM2_TISEL TI1SEL LL_TIM_SetRemap\n
  4772. * TIM2_TISEL TI2SEL LL_TIM_SetRemap\n
  4773. * TIM2_TISEL TI3SEL LL_TIM_SetRemap\n
  4774. * TIM2_TISEL TI4SEL LL_TIM_SetRemap\n
  4775. * TIM3_TISEL TI1SEL LL_TIM_SetRemap\n
  4776. * TIM3_TISEL TI2SEL LL_TIM_SetRemap\n
  4777. * TIM3_TISEL TI3SEL LL_TIM_SetRemap\n
  4778. * TIM4_TISEL TI1SEL LL_TIM_SetRemap\n
  4779. * TIM4_TISEL TI2SEL LL_TIM_SetRemap\n
  4780. * TIM4_TISEL TI3SEL LL_TIM_SetRemap\n
  4781. * TIM4_TISEL TI4SEL LL_TIM_SetRemap\n
  4782. * TIM5_TISEL TI1SEL LL_TIM_SetRemap\n
  4783. * TIM5_TISEL TI2SEL LL_TIM_SetRemap\n
  4784. * TIM8_TISEL TI1SEL LL_TIM_SetRemap\n
  4785. * TIM15_TISEL TI1SEL LL_TIM_SetRemap\n
  4786. * TIM15_TISEL TI2SEL LL_TIM_SetRemap\n
  4787. * TIM16_TISEL TI1SEL LL_TIM_SetRemap\n
  4788. * TIM17_TISEL TI1SEL LL_TIM_SetRemap\n
  4789. * TIM20_TISEL TI1SEL LL_TIM_SetRemap
  4790. * @param TIMx Timer instance
  4791. * @param Remap Remap param depends on the TIMx. Description available only
  4792. * in CHM version of the User Manual (not in .pdf).
  4793. * Otherwise see Reference Manual description of TISEL registers.
  4794. *
  4795. * Below description summarizes "Timer Instance" and "Remap" param combinations:
  4796. *
  4797. * TIM1: one of the following values
  4798. *
  4799. * @arg @ref LL_TIM_TIM1_TI1_RMP_GPIO
  4800. * @arg @ref LL_TIM_TIM1_TI1_RMP_COMP1
  4801. * @arg @ref LL_TIM_TIM1_TI1_RMP_COMP2
  4802. * @arg @ref LL_TIM_TIM1_TI1_RMP_COMP3
  4803. * @arg @ref LL_TIM_TIM1_TI1_RMP_COMP4
  4804. *
  4805. * TIM2: any combination of TI1_RMP, TI2_RMP, TI3_RMP and TI4_RMP where
  4806. *
  4807. * . . TI1_RMP can be one of the following values
  4808. * @arg @ref LL_TIM_TIM2_TI1_RMP_GPIO
  4809. * @arg @ref LL_TIM_TIM2_TI1_RMP_COMP1
  4810. * @arg @ref LL_TIM_TIM2_TI1_RMP_COMP2
  4811. * @arg @ref LL_TIM_TIM2_TI1_RMP_COMP3
  4812. * @arg @ref LL_TIM_TIM2_TI1_RMP_COMP4
  4813. * @arg @ref LL_TIM_TIM2_TI1_RMP_COMP5 (*)
  4814. *
  4815. * . . TI2_RMP can be one of the following values
  4816. * @arg @ref LL_TIM_TIM2_TI2_RMP_GPIO
  4817. * @arg @ref LL_TIM_TIM2_TI2_RMP_COMP1
  4818. * @arg @ref LL_TIM_TIM2_TI2_RMP_COMP2
  4819. * @arg @ref LL_TIM_TIM2_TI2_RMP_COMP3
  4820. * @arg @ref LL_TIM_TIM2_TI2_RMP_COMP4
  4821. * @arg @ref LL_TIM_TIM2_TI2_RMP_COMP6 (*)
  4822. *
  4823. * . . TI3_RMP can be one of the following values
  4824. * @arg @ref LL_TIM_TIM2_TI3_RMP_GPIO
  4825. * @arg @ref LL_TIM_TIM2_TI3_RMP_COMP4
  4826. *
  4827. * . . TI4_RMP can be one of the following values
  4828. * @arg @ref LL_TIM_TIM2_TI4_RMP_GPIO
  4829. * @arg @ref LL_TIM_TIM2_TI4_RMP_COMP1
  4830. * @arg @ref LL_TIM_TIM2_TI4_RMP_COMP2
  4831. *
  4832. * TIM3: any combination of TI1_RMP and TI2_RMP where
  4833. *
  4834. * . . TI1_RMP can be one of the following values
  4835. * @arg @ref LL_TIM_TIM3_TI1_RMP_GPIO
  4836. * @arg @ref LL_TIM_TIM3_TI1_RMP_COMP1
  4837. * @arg @ref LL_TIM_TIM3_TI1_RMP_COMP2
  4838. * @arg @ref LL_TIM_TIM3_TI1_RMP_COMP3
  4839. * @arg @ref LL_TIM_TIM3_TI1_RMP_COMP4
  4840. * @arg @ref LL_TIM_TIM3_TI1_RMP_COMP5 (*)
  4841. * @arg @ref LL_TIM_TIM3_TI1_RMP_COMP6 (*)
  4842. * @arg @ref LL_TIM_TIM3_TI1_RMP_COMP7 (*)
  4843. *
  4844. * . . TI2_RMP can be one of the following values
  4845. * @arg @ref LL_TIM_TIM3_TI2_RMP_GPIO
  4846. * @arg @ref LL_TIM_TIM3_TI2_RMP_COMP1
  4847. * @arg @ref LL_TIM_TIM3_TI2_RMP_COMP2
  4848. * @arg @ref LL_TIM_TIM3_TI2_RMP_COMP3
  4849. * @arg @ref LL_TIM_TIM3_TI2_RMP_COMP4
  4850. * @arg @ref LL_TIM_TIM3_TI2_RMP_COMP5 (*)
  4851. * @arg @ref LL_TIM_TIM3_TI2_RMP_COMP6 (*)
  4852. * @arg @ref LL_TIM_TIM3_TI2_RMP_COMP7 (*)
  4853. *
  4854. * . . TI3_RMP can be one of the following values
  4855. * @arg @ref LL_TIM_TIM3_TI3_RMP_GPIO
  4856. * @arg @ref LL_TIM_TIM3_TI3_RMP_COMP3
  4857. *
  4858. * TIM4: any combination of TI1_RMP, TI2_RMP, TI3_RMP and TI4_RMP where
  4859. *
  4860. * . . TI1_RMP can be one of the following values
  4861. * @arg @ref LL_TIM_TIM4_TI1_RMP_GPIO
  4862. * @arg @ref LL_TIM_TIM4_TI1_RMP_COMP1
  4863. * @arg @ref LL_TIM_TIM4_TI1_RMP_COMP2
  4864. * @arg @ref LL_TIM_TIM4_TI1_RMP_COMP3
  4865. * @arg @ref LL_TIM_TIM4_TI1_RMP_COMP4
  4866. * @arg @ref LL_TIM_TIM4_TI1_RMP_COMP5 (*)
  4867. * @arg @ref LL_TIM_TIM4_TI1_RMP_COMP6 (*)
  4868. * @arg @ref LL_TIM_TIM4_TI1_RMP_COMP7 (*)
  4869. *
  4870. * . . TI2_RMP can be one of the following values
  4871. * @arg @ref LL_TIM_TIM4_TI2_RMP_GPIO
  4872. * @arg @ref LL_TIM_TIM4_TI2_RMP_COMP1
  4873. * @arg @ref LL_TIM_TIM4_TI2_RMP_COMP2
  4874. * @arg @ref LL_TIM_TIM4_TI2_RMP_COMP3
  4875. * @arg @ref LL_TIM_TIM4_TI2_RMP_COMP4
  4876. * @arg @ref LL_TIM_TIM4_TI2_RMP_COMP5 (*)
  4877. * @arg @ref LL_TIM_TIM4_TI2_RMP_COMP6 (*)
  4878. * @arg @ref LL_TIM_TIM4_TI2_RMP_COMP7 (*)
  4879. *
  4880. * . . TI3_RMP can be one of the following values
  4881. * @arg @ref LL_TIM_TIM4_TI3_RMP_GPIO
  4882. * @arg @ref LL_TIM_TIM4_TI3_RMP_COMP5 (*)
  4883. *
  4884. * . . TI4_RMP can be one of the following values
  4885. * @arg @ref LL_TIM_TIM4_TI4_RMP_GPIO
  4886. * @arg @ref LL_TIM_TIM4_TI4_RMP_COMP6 (*)
  4887. *
  4888. * TIM5: any combination of TI1_RMP and TI2_RMP where (**)
  4889. *
  4890. * . . TI1_RMP can be one of the following values
  4891. * @arg @ref LL_TIM_TIM5_TI1_RMP_GPIO (*)
  4892. * @arg @ref LL_TIM_TIM5_TI1_RMP_LSI (*)
  4893. * @arg @ref LL_TIM_TIM5_TI1_RMP_LSE (*)
  4894. * @arg @ref LL_TIM_TIM5_TI1_RMP_RTC_WK (*)
  4895. * @arg @ref LL_TIM_TIM5_TI1_RMP_COMP1 (*)
  4896. * @arg @ref LL_TIM_TIM5_TI1_RMP_COMP2 (*)
  4897. * @arg @ref LL_TIM_TIM5_TI1_RMP_COMP3 (*)
  4898. * @arg @ref LL_TIM_TIM5_TI1_RMP_COMP4 (*)
  4899. * @arg @ref LL_TIM_TIM5_TI1_RMP_COMP5 (*)
  4900. * @arg @ref LL_TIM_TIM5_TI1_RMP_COMP6 (*)
  4901. * @arg @ref LL_TIM_TIM5_TI1_RMP_COMP7 (*)
  4902. *
  4903. * . . TI2_RMP can be one of the following values
  4904. * @arg @ref LL_TIM_TIM5_TI2_RMP_GPIO (*)
  4905. * @arg @ref LL_TIM_TIM5_TI2_RMP_COMP1 (*)
  4906. * @arg @ref LL_TIM_TIM5_TI2_RMP_COMP2 (*)
  4907. * @arg @ref LL_TIM_TIM5_TI2_RMP_COMP3 (*)
  4908. * @arg @ref LL_TIM_TIM5_TI2_RMP_COMP4 (*)
  4909. * @arg @ref LL_TIM_TIM5_TI2_RMP_COMP5 (*)
  4910. * @arg @ref LL_TIM_TIM5_TI2_RMP_COMP6 (*)
  4911. * @arg @ref LL_TIM_TIM5_TI2_RMP_COMP7 (*)
  4912. *
  4913. * TIM8: one of the following values
  4914. *
  4915. * @arg @ref LL_TIM_TIM8_TI1_RMP_GPIO
  4916. * @arg @ref LL_TIM_TIM8_TI1_RMP_COMP1
  4917. * @arg @ref LL_TIM_TIM8_TI1_RMP_COMP2
  4918. * @arg @ref LL_TIM_TIM8_TI1_RMP_COMP3
  4919. * @arg @ref LL_TIM_TIM8_TI1_RMP_COMP4
  4920. *
  4921. * TIM15: any combination of TI1_RMP and TI2_RMP where
  4922. *
  4923. * . . TI1_RMP can be one of the following values
  4924. * @arg @ref LL_TIM_TIM15_TI1_RMP_GPIO
  4925. * @arg @ref LL_TIM_TIM15_TI1_RMP_LSE
  4926. * @arg @ref LL_TIM_TIM15_TI1_RMP_COMP1
  4927. * @arg @ref LL_TIM_TIM15_TI1_RMP_COMP2
  4928. * @arg @ref LL_TIM_TIM15_TI1_RMP_COMP5 (*)
  4929. * @arg @ref LL_TIM_TIM15_TI1_RMP_COMP7 (*)
  4930. *
  4931. * . . TI2_RMP can be one of the following values
  4932. * @arg @ref LL_TIM_TIM15_TI2_RMP_GPIO
  4933. * @arg @ref LL_TIM_TIM15_TI2_RMP_COMP2
  4934. * @arg @ref LL_TIM_TIM15_TI2_RMP_COMP3
  4935. * @arg @ref LL_TIM_TIM15_TI2_RMP_COMP6 (*)
  4936. * @arg @ref LL_TIM_TIM15_TI2_RMP_COMP7 (*)
  4937. *
  4938. * TIM16: one of the following values
  4939. *
  4940. * @arg @ref LL_TIM_TIM16_TI1_RMP_GPIO
  4941. * @arg @ref LL_TIM_TIM16_TI1_RMP_COMP6 (*)
  4942. * @arg @ref LL_TIM_TIM16_TI1_RMP_MCO
  4943. * @arg @ref LL_TIM_TIM16_TI1_RMP_HSE_32
  4944. * @arg @ref LL_TIM_TIM16_TI1_RMP_RTC_WK
  4945. * @arg @ref LL_TIM_TIM16_TI1_RMP_LSE
  4946. * @arg @ref LL_TIM_TIM16_TI1_RMP_LSI
  4947. *
  4948. * TIM17: one of the following values
  4949. *
  4950. * @arg @ref LL_TIM_TIM17_TI1_RMP_GPIO
  4951. * @arg @ref LL_TIM_TIM17_TI1_RMP_COMP5 (*)
  4952. * @arg @ref LL_TIM_TIM17_TI1_RMP_MCO
  4953. * @arg @ref LL_TIM_TIM17_TI1_RMP_HSE_32
  4954. * @arg @ref LL_TIM_TIM17_TI1_RMP_RTC_WK
  4955. * @arg @ref LL_TIM_TIM17_TI1_RMP_LSE
  4956. * @arg @ref LL_TIM_TIM17_TI1_RMP_LSI
  4957. *
  4958. * TIM20: one of the following values (**)
  4959. *
  4960. * @arg @ref LL_TIM_TIM20_TI1_RMP_GPIO (*)
  4961. * @arg @ref LL_TIM_TIM20_TI1_RMP_COMP1 (*)
  4962. * @arg @ref LL_TIM_TIM20_TI1_RMP_COMP2 (*)
  4963. * @arg @ref LL_TIM_TIM20_TI1_RMP_COMP3 (*)
  4964. * @arg @ref LL_TIM_TIM20_TI1_RMP_COMP4 (*)
  4965. *
  4966. * (*) Value not defined in all devices. \n
  4967. * (**) Register not available in all devices.
  4968. *
  4969. *
  4970. * @retval None
  4971. */
  4972. __STATIC_INLINE void LL_TIM_SetRemap(TIM_TypeDef *TIMx, uint32_t Remap)
  4973. {
  4974. MODIFY_REG(TIMx->TISEL, (TIM_TISEL_TI1SEL | TIM_TISEL_TI2SEL | TIM_TISEL_TI3SEL | TIM_TISEL_TI4SEL), Remap);
  4975. }
  4976. /**
  4977. * @brief Enable request for HSE/32 clock used for TISEL remap.
  4978. * @note Only TIM16 and TIM17 support HSE/32 remap
  4979. * @rmtoll OR HSE32EN LL_TIM_EnableHSE32
  4980. * @param TIMx Timer instance
  4981. * @retval None
  4982. */
  4983. __STATIC_INLINE void LL_TIM_EnableHSE32(TIM_TypeDef *TIMx)
  4984. {
  4985. SET_BIT(TIMx->OR, TIM_OR_HSE32EN);
  4986. }
  4987. /**
  4988. * @brief Disable request for HSE/32 clock used for TISEL remap.
  4989. * @note Only TIM16 and TIM17 support HSE/32 remap
  4990. * @rmtoll OR HSE32EN LL_TIM_DisableHSE32
  4991. * @param TIMx Timer instance
  4992. * @retval None
  4993. */
  4994. __STATIC_INLINE void LL_TIM_DisableHSE32(TIM_TypeDef *TIMx)
  4995. {
  4996. CLEAR_BIT(TIMx->OR, TIM_OR_HSE32EN);
  4997. }
  4998. /**
  4999. * @brief Indicate whether request for HSE/32 clock is enabled.
  5000. * @note Only TIM16 and TIM17 support HSE/32 remap
  5001. * @rmtoll OR HSE32EN LL_TIM_IsEnabledHSE32
  5002. * @param TIMx Timer instance
  5003. * @retval State of bit (1 or 0).
  5004. */
  5005. __STATIC_INLINE uint32_t LL_TIM_IsEnabledHSE32(const TIM_TypeDef *TIMx)
  5006. {
  5007. return ((READ_BIT(TIMx->OR, TIM_OR_HSE32EN) == (TIM_OR_HSE32EN)) ? 1UL : 0UL);
  5008. }
  5009. /**
  5010. * @}
  5011. */
  5012. /** @defgroup TIM_LL_EF_OCREF_Clear OCREF_Clear_Management
  5013. * @{
  5014. */
  5015. /**
  5016. * @brief Set the OCREF clear input source
  5017. * @note The OCxREF signal of a given channel can be cleared when a high level is applied on the OCREF_CLR_INPUT
  5018. * @note This function can only be used in Output compare and PWM modes.
  5019. * @note Macro IS_TIM_OCCS_INSTANCE(TIMx) can be used to check whether
  5020. * or not a timer instance can configure OCREF clear input source.
  5021. * @rmtoll SMCR OCCS LL_TIM_SetOCRefClearInputSource
  5022. * @rmtoll AF2 OCRSEL LL_TIM_SetOCRefClearInputSource
  5023. * @param TIMx Timer instance
  5024. * @param OCRefClearInputSource This parameter can be one of the following values:
  5025. * @arg @ref LL_TIM_OCREF_CLR_INT_ETR
  5026. * @arg @ref LL_TIM_OCREF_CLR_INT_COMP1
  5027. * @arg @ref LL_TIM_OCREF_CLR_INT_COMP2
  5028. * @arg @ref LL_TIM_OCREF_CLR_INT_COMP3
  5029. * @arg @ref LL_TIM_OCREF_CLR_INT_COMP4
  5030. * @arg @ref LL_TIM_OCREF_CLR_INT_COMP5 (*)
  5031. * @arg @ref LL_TIM_OCREF_CLR_INT_COMP6 (*)
  5032. * @arg @ref LL_TIM_OCREF_CLR_INT_COMP7 (*)
  5033. *
  5034. * (*) Value not defined in all devices. \n
  5035. * @retval None
  5036. */
  5037. __STATIC_INLINE void LL_TIM_SetOCRefClearInputSource(TIM_TypeDef *TIMx, uint32_t OCRefClearInputSource)
  5038. {
  5039. MODIFY_REG(TIMx->SMCR, TIM_SMCR_OCCS,
  5040. ((OCRefClearInputSource & OCREF_CLEAR_SELECT_Msk) >> OCREF_CLEAR_SELECT_Pos) << TIM_SMCR_OCCS_Pos);
  5041. MODIFY_REG(TIMx->AF2, TIM1_AF2_OCRSEL, OCRefClearInputSource);
  5042. }
  5043. /**
  5044. * @}
  5045. */
  5046. /** @defgroup TIM_LL_EF_FLAG_Management FLAG-Management
  5047. * @{
  5048. */
  5049. /**
  5050. * @brief Clear the update interrupt flag (UIF).
  5051. * @rmtoll SR UIF LL_TIM_ClearFlag_UPDATE
  5052. * @param TIMx Timer instance
  5053. * @retval None
  5054. */
  5055. __STATIC_INLINE void LL_TIM_ClearFlag_UPDATE(TIM_TypeDef *TIMx)
  5056. {
  5057. WRITE_REG(TIMx->SR, ~(TIM_SR_UIF));
  5058. }
  5059. /**
  5060. * @brief Indicate whether update interrupt flag (UIF) is set (update interrupt is pending).
  5061. * @rmtoll SR UIF LL_TIM_IsActiveFlag_UPDATE
  5062. * @param TIMx Timer instance
  5063. * @retval State of bit (1 or 0).
  5064. */
  5065. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_UPDATE(const TIM_TypeDef *TIMx)
  5066. {
  5067. return ((READ_BIT(TIMx->SR, TIM_SR_UIF) == (TIM_SR_UIF)) ? 1UL : 0UL);
  5068. }
  5069. /**
  5070. * @brief Clear the Capture/Compare 1 interrupt flag (CC1F).
  5071. * @rmtoll SR CC1IF LL_TIM_ClearFlag_CC1
  5072. * @param TIMx Timer instance
  5073. * @retval None
  5074. */
  5075. __STATIC_INLINE void LL_TIM_ClearFlag_CC1(TIM_TypeDef *TIMx)
  5076. {
  5077. WRITE_REG(TIMx->SR, ~(TIM_SR_CC1IF));
  5078. }
  5079. /**
  5080. * @brief Indicate whether Capture/Compare 1 interrupt flag (CC1F) is set (Capture/Compare 1 interrupt is pending).
  5081. * @rmtoll SR CC1IF LL_TIM_IsActiveFlag_CC1
  5082. * @param TIMx Timer instance
  5083. * @retval State of bit (1 or 0).
  5084. */
  5085. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC1(const TIM_TypeDef *TIMx)
  5086. {
  5087. return ((READ_BIT(TIMx->SR, TIM_SR_CC1IF) == (TIM_SR_CC1IF)) ? 1UL : 0UL);
  5088. }
  5089. /**
  5090. * @brief Clear the Capture/Compare 2 interrupt flag (CC2F).
  5091. * @rmtoll SR CC2IF LL_TIM_ClearFlag_CC2
  5092. * @param TIMx Timer instance
  5093. * @retval None
  5094. */
  5095. __STATIC_INLINE void LL_TIM_ClearFlag_CC2(TIM_TypeDef *TIMx)
  5096. {
  5097. WRITE_REG(TIMx->SR, ~(TIM_SR_CC2IF));
  5098. }
  5099. /**
  5100. * @brief Indicate whether Capture/Compare 2 interrupt flag (CC2F) is set (Capture/Compare 2 interrupt is pending).
  5101. * @rmtoll SR CC2IF LL_TIM_IsActiveFlag_CC2
  5102. * @param TIMx Timer instance
  5103. * @retval State of bit (1 or 0).
  5104. */
  5105. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC2(const TIM_TypeDef *TIMx)
  5106. {
  5107. return ((READ_BIT(TIMx->SR, TIM_SR_CC2IF) == (TIM_SR_CC2IF)) ? 1UL : 0UL);
  5108. }
  5109. /**
  5110. * @brief Clear the Capture/Compare 3 interrupt flag (CC3F).
  5111. * @rmtoll SR CC3IF LL_TIM_ClearFlag_CC3
  5112. * @param TIMx Timer instance
  5113. * @retval None
  5114. */
  5115. __STATIC_INLINE void LL_TIM_ClearFlag_CC3(TIM_TypeDef *TIMx)
  5116. {
  5117. WRITE_REG(TIMx->SR, ~(TIM_SR_CC3IF));
  5118. }
  5119. /**
  5120. * @brief Indicate whether Capture/Compare 3 interrupt flag (CC3F) is set (Capture/Compare 3 interrupt is pending).
  5121. * @rmtoll SR CC3IF LL_TIM_IsActiveFlag_CC3
  5122. * @param TIMx Timer instance
  5123. * @retval State of bit (1 or 0).
  5124. */
  5125. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC3(const TIM_TypeDef *TIMx)
  5126. {
  5127. return ((READ_BIT(TIMx->SR, TIM_SR_CC3IF) == (TIM_SR_CC3IF)) ? 1UL : 0UL);
  5128. }
  5129. /**
  5130. * @brief Clear the Capture/Compare 4 interrupt flag (CC4F).
  5131. * @rmtoll SR CC4IF LL_TIM_ClearFlag_CC4
  5132. * @param TIMx Timer instance
  5133. * @retval None
  5134. */
  5135. __STATIC_INLINE void LL_TIM_ClearFlag_CC4(TIM_TypeDef *TIMx)
  5136. {
  5137. WRITE_REG(TIMx->SR, ~(TIM_SR_CC4IF));
  5138. }
  5139. /**
  5140. * @brief Indicate whether Capture/Compare 4 interrupt flag (CC4F) is set (Capture/Compare 4 interrupt is pending).
  5141. * @rmtoll SR CC4IF LL_TIM_IsActiveFlag_CC4
  5142. * @param TIMx Timer instance
  5143. * @retval State of bit (1 or 0).
  5144. */
  5145. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC4(const TIM_TypeDef *TIMx)
  5146. {
  5147. return ((READ_BIT(TIMx->SR, TIM_SR_CC4IF) == (TIM_SR_CC4IF)) ? 1UL : 0UL);
  5148. }
  5149. /**
  5150. * @brief Clear the Capture/Compare 5 interrupt flag (CC5F).
  5151. * @rmtoll SR CC5IF LL_TIM_ClearFlag_CC5
  5152. * @param TIMx Timer instance
  5153. * @retval None
  5154. */
  5155. __STATIC_INLINE void LL_TIM_ClearFlag_CC5(TIM_TypeDef *TIMx)
  5156. {
  5157. WRITE_REG(TIMx->SR, ~(TIM_SR_CC5IF));
  5158. }
  5159. /**
  5160. * @brief Indicate whether Capture/Compare 5 interrupt flag (CC5F) is set (Capture/Compare 5 interrupt is pending).
  5161. * @rmtoll SR CC5IF LL_TIM_IsActiveFlag_CC5
  5162. * @param TIMx Timer instance
  5163. * @retval State of bit (1 or 0).
  5164. */
  5165. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC5(const TIM_TypeDef *TIMx)
  5166. {
  5167. return ((READ_BIT(TIMx->SR, TIM_SR_CC5IF) == (TIM_SR_CC5IF)) ? 1UL : 0UL);
  5168. }
  5169. /**
  5170. * @brief Clear the Capture/Compare 6 interrupt flag (CC6F).
  5171. * @rmtoll SR CC6IF LL_TIM_ClearFlag_CC6
  5172. * @param TIMx Timer instance
  5173. * @retval None
  5174. */
  5175. __STATIC_INLINE void LL_TIM_ClearFlag_CC6(TIM_TypeDef *TIMx)
  5176. {
  5177. WRITE_REG(TIMx->SR, ~(TIM_SR_CC6IF));
  5178. }
  5179. /**
  5180. * @brief Indicate whether Capture/Compare 6 interrupt flag (CC6F) is set (Capture/Compare 6 interrupt is pending).
  5181. * @rmtoll SR CC6IF LL_TIM_IsActiveFlag_CC6
  5182. * @param TIMx Timer instance
  5183. * @retval State of bit (1 or 0).
  5184. */
  5185. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC6(const TIM_TypeDef *TIMx)
  5186. {
  5187. return ((READ_BIT(TIMx->SR, TIM_SR_CC6IF) == (TIM_SR_CC6IF)) ? 1UL : 0UL);
  5188. }
  5189. /**
  5190. * @brief Clear the commutation interrupt flag (COMIF).
  5191. * @rmtoll SR COMIF LL_TIM_ClearFlag_COM
  5192. * @param TIMx Timer instance
  5193. * @retval None
  5194. */
  5195. __STATIC_INLINE void LL_TIM_ClearFlag_COM(TIM_TypeDef *TIMx)
  5196. {
  5197. WRITE_REG(TIMx->SR, ~(TIM_SR_COMIF));
  5198. }
  5199. /**
  5200. * @brief Indicate whether commutation interrupt flag (COMIF) is set (commutation interrupt is pending).
  5201. * @rmtoll SR COMIF LL_TIM_IsActiveFlag_COM
  5202. * @param TIMx Timer instance
  5203. * @retval State of bit (1 or 0).
  5204. */
  5205. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_COM(const TIM_TypeDef *TIMx)
  5206. {
  5207. return ((READ_BIT(TIMx->SR, TIM_SR_COMIF) == (TIM_SR_COMIF)) ? 1UL : 0UL);
  5208. }
  5209. /**
  5210. * @brief Clear the trigger interrupt flag (TIF).
  5211. * @rmtoll SR TIF LL_TIM_ClearFlag_TRIG
  5212. * @param TIMx Timer instance
  5213. * @retval None
  5214. */
  5215. __STATIC_INLINE void LL_TIM_ClearFlag_TRIG(TIM_TypeDef *TIMx)
  5216. {
  5217. WRITE_REG(TIMx->SR, ~(TIM_SR_TIF));
  5218. }
  5219. /**
  5220. * @brief Indicate whether trigger interrupt flag (TIF) is set (trigger interrupt is pending).
  5221. * @rmtoll SR TIF LL_TIM_IsActiveFlag_TRIG
  5222. * @param TIMx Timer instance
  5223. * @retval State of bit (1 or 0).
  5224. */
  5225. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_TRIG(const TIM_TypeDef *TIMx)
  5226. {
  5227. return ((READ_BIT(TIMx->SR, TIM_SR_TIF) == (TIM_SR_TIF)) ? 1UL : 0UL);
  5228. }
  5229. /**
  5230. * @brief Clear the break interrupt flag (BIF).
  5231. * @rmtoll SR BIF LL_TIM_ClearFlag_BRK
  5232. * @param TIMx Timer instance
  5233. * @retval None
  5234. */
  5235. __STATIC_INLINE void LL_TIM_ClearFlag_BRK(TIM_TypeDef *TIMx)
  5236. {
  5237. WRITE_REG(TIMx->SR, ~(TIM_SR_BIF));
  5238. }
  5239. /**
  5240. * @brief Indicate whether break interrupt flag (BIF) is set (break interrupt is pending).
  5241. * @rmtoll SR BIF LL_TIM_IsActiveFlag_BRK
  5242. * @param TIMx Timer instance
  5243. * @retval State of bit (1 or 0).
  5244. */
  5245. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_BRK(const TIM_TypeDef *TIMx)
  5246. {
  5247. return ((READ_BIT(TIMx->SR, TIM_SR_BIF) == (TIM_SR_BIF)) ? 1UL : 0UL);
  5248. }
  5249. /**
  5250. * @brief Clear the break 2 interrupt flag (B2IF).
  5251. * @rmtoll SR B2IF LL_TIM_ClearFlag_BRK2
  5252. * @param TIMx Timer instance
  5253. * @retval None
  5254. */
  5255. __STATIC_INLINE void LL_TIM_ClearFlag_BRK2(TIM_TypeDef *TIMx)
  5256. {
  5257. WRITE_REG(TIMx->SR, ~(TIM_SR_B2IF));
  5258. }
  5259. /**
  5260. * @brief Indicate whether break 2 interrupt flag (B2IF) is set (break 2 interrupt is pending).
  5261. * @rmtoll SR B2IF LL_TIM_IsActiveFlag_BRK2
  5262. * @param TIMx Timer instance
  5263. * @retval State of bit (1 or 0).
  5264. */
  5265. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_BRK2(const TIM_TypeDef *TIMx)
  5266. {
  5267. return ((READ_BIT(TIMx->SR, TIM_SR_B2IF) == (TIM_SR_B2IF)) ? 1UL : 0UL);
  5268. }
  5269. /**
  5270. * @brief Clear the Capture/Compare 1 over-capture interrupt flag (CC1OF).
  5271. * @rmtoll SR CC1OF LL_TIM_ClearFlag_CC1OVR
  5272. * @param TIMx Timer instance
  5273. * @retval None
  5274. */
  5275. __STATIC_INLINE void LL_TIM_ClearFlag_CC1OVR(TIM_TypeDef *TIMx)
  5276. {
  5277. WRITE_REG(TIMx->SR, ~(TIM_SR_CC1OF));
  5278. }
  5279. /**
  5280. * @brief Indicate whether Capture/Compare 1 over-capture interrupt flag (CC1OF) is set
  5281. * (Capture/Compare 1 interrupt is pending).
  5282. * @rmtoll SR CC1OF LL_TIM_IsActiveFlag_CC1OVR
  5283. * @param TIMx Timer instance
  5284. * @retval State of bit (1 or 0).
  5285. */
  5286. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC1OVR(const TIM_TypeDef *TIMx)
  5287. {
  5288. return ((READ_BIT(TIMx->SR, TIM_SR_CC1OF) == (TIM_SR_CC1OF)) ? 1UL : 0UL);
  5289. }
  5290. /**
  5291. * @brief Clear the Capture/Compare 2 over-capture interrupt flag (CC2OF).
  5292. * @rmtoll SR CC2OF LL_TIM_ClearFlag_CC2OVR
  5293. * @param TIMx Timer instance
  5294. * @retval None
  5295. */
  5296. __STATIC_INLINE void LL_TIM_ClearFlag_CC2OVR(TIM_TypeDef *TIMx)
  5297. {
  5298. WRITE_REG(TIMx->SR, ~(TIM_SR_CC2OF));
  5299. }
  5300. /**
  5301. * @brief Indicate whether Capture/Compare 2 over-capture interrupt flag (CC2OF) is set
  5302. * (Capture/Compare 2 over-capture interrupt is pending).
  5303. * @rmtoll SR CC2OF LL_TIM_IsActiveFlag_CC2OVR
  5304. * @param TIMx Timer instance
  5305. * @retval State of bit (1 or 0).
  5306. */
  5307. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC2OVR(const TIM_TypeDef *TIMx)
  5308. {
  5309. return ((READ_BIT(TIMx->SR, TIM_SR_CC2OF) == (TIM_SR_CC2OF)) ? 1UL : 0UL);
  5310. }
  5311. /**
  5312. * @brief Clear the Capture/Compare 3 over-capture interrupt flag (CC3OF).
  5313. * @rmtoll SR CC3OF LL_TIM_ClearFlag_CC3OVR
  5314. * @param TIMx Timer instance
  5315. * @retval None
  5316. */
  5317. __STATIC_INLINE void LL_TIM_ClearFlag_CC3OVR(TIM_TypeDef *TIMx)
  5318. {
  5319. WRITE_REG(TIMx->SR, ~(TIM_SR_CC3OF));
  5320. }
  5321. /**
  5322. * @brief Indicate whether Capture/Compare 3 over-capture interrupt flag (CC3OF) is set
  5323. * (Capture/Compare 3 over-capture interrupt is pending).
  5324. * @rmtoll SR CC3OF LL_TIM_IsActiveFlag_CC3OVR
  5325. * @param TIMx Timer instance
  5326. * @retval State of bit (1 or 0).
  5327. */
  5328. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC3OVR(const TIM_TypeDef *TIMx)
  5329. {
  5330. return ((READ_BIT(TIMx->SR, TIM_SR_CC3OF) == (TIM_SR_CC3OF)) ? 1UL : 0UL);
  5331. }
  5332. /**
  5333. * @brief Clear the Capture/Compare 4 over-capture interrupt flag (CC4OF).
  5334. * @rmtoll SR CC4OF LL_TIM_ClearFlag_CC4OVR
  5335. * @param TIMx Timer instance
  5336. * @retval None
  5337. */
  5338. __STATIC_INLINE void LL_TIM_ClearFlag_CC4OVR(TIM_TypeDef *TIMx)
  5339. {
  5340. WRITE_REG(TIMx->SR, ~(TIM_SR_CC4OF));
  5341. }
  5342. /**
  5343. * @brief Indicate whether Capture/Compare 4 over-capture interrupt flag (CC4OF) is set
  5344. * (Capture/Compare 4 over-capture interrupt is pending).
  5345. * @rmtoll SR CC4OF LL_TIM_IsActiveFlag_CC4OVR
  5346. * @param TIMx Timer instance
  5347. * @retval State of bit (1 or 0).
  5348. */
  5349. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC4OVR(const TIM_TypeDef *TIMx)
  5350. {
  5351. return ((READ_BIT(TIMx->SR, TIM_SR_CC4OF) == (TIM_SR_CC4OF)) ? 1UL : 0UL);
  5352. }
  5353. /**
  5354. * @brief Clear the system break interrupt flag (SBIF).
  5355. * @rmtoll SR SBIF LL_TIM_ClearFlag_SYSBRK
  5356. * @param TIMx Timer instance
  5357. * @retval None
  5358. */
  5359. __STATIC_INLINE void LL_TIM_ClearFlag_SYSBRK(TIM_TypeDef *TIMx)
  5360. {
  5361. WRITE_REG(TIMx->SR, ~(TIM_SR_SBIF));
  5362. }
  5363. /**
  5364. * @brief Indicate whether system break interrupt flag (SBIF) is set (system break interrupt is pending).
  5365. * @rmtoll SR SBIF LL_TIM_IsActiveFlag_SYSBRK
  5366. * @param TIMx Timer instance
  5367. * @retval State of bit (1 or 0).
  5368. */
  5369. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_SYSBRK(const TIM_TypeDef *TIMx)
  5370. {
  5371. return ((READ_BIT(TIMx->SR, TIM_SR_SBIF) == (TIM_SR_SBIF)) ? 1UL : 0UL);
  5372. }
  5373. /**
  5374. * @brief Clear the transition error interrupt flag (TERRF).
  5375. * @note Macro IS_TIM_ENCODER_ERROR_INSTANCE(TIMx) can be used to check whether or not
  5376. * a timer instance provides encoder error management.
  5377. * @rmtoll SR TERRF LL_TIM_ClearFlag_TERR
  5378. * @param TIMx Timer instance
  5379. * @retval None
  5380. */
  5381. __STATIC_INLINE void LL_TIM_ClearFlag_TERR(TIM_TypeDef *TIMx)
  5382. {
  5383. WRITE_REG(TIMx->SR, ~(TIM_SR_TERRF));
  5384. }
  5385. /**
  5386. * @brief Indicate whether transition error interrupt flag (TERRF) is set (transition error interrupt is pending).
  5387. * @note Macro IS_TIM_ENCODER_ERROR_INSTANCE(TIMx) can be used to check whether or not
  5388. * a timer instance provides encoder error management.
  5389. * @rmtoll SR TERRF LL_TIM_IsActiveFlag_TERR
  5390. * @param TIMx Timer instance
  5391. * @retval State of bit (1 or 0).
  5392. */
  5393. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_TERR(const TIM_TypeDef *TIMx)
  5394. {
  5395. return ((READ_BIT(TIMx->SR, TIM_SR_TERRF) == (TIM_SR_TERRF)) ? 1UL : 0UL);
  5396. }
  5397. /**
  5398. * @brief Clear the index error interrupt flag (IERRF).
  5399. * @note Macro IS_TIM_ENCODER_ERROR_INSTANCE(TIMx) can be used to check whether or not
  5400. * a timer instance provides encoder error management.
  5401. * @rmtoll SR IERRF LL_TIM_ClearFlag_IERR
  5402. * @param TIMx Timer instance
  5403. * @retval None
  5404. */
  5405. __STATIC_INLINE void LL_TIM_ClearFlag_IERR(TIM_TypeDef *TIMx)
  5406. {
  5407. WRITE_REG(TIMx->SR, ~(TIM_SR_IERRF));
  5408. }
  5409. /**
  5410. * @brief Indicate whether index error interrupt flag (IERRF) is set (index error interrupt is pending).
  5411. * @note Macro IS_TIM_ENCODER_ERROR_INSTANCE(TIMx) can be used to check whether or not
  5412. * a timer instance provides encoder error management.
  5413. * @rmtoll SR IERRF LL_TIM_IsActiveFlag_IERR
  5414. * @param TIMx Timer instance
  5415. * @retval State of bit (1 or 0).
  5416. */
  5417. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_IERR(const TIM_TypeDef *TIMx)
  5418. {
  5419. return ((READ_BIT(TIMx->SR, TIM_SR_IERRF) == (TIM_SR_IERRF)) ? 1UL : 0UL);
  5420. }
  5421. /**
  5422. * @brief Clear the direction change interrupt flag (DIRF).
  5423. * @note Macro IS_TIM_FUNCTINONAL_ENCODER_INTERRUPT_INSTANCE(TIMx) can be used to check whether or not
  5424. * a timer instance provides encoder interrupt management.
  5425. * @rmtoll SR DIRF LL_TIM_ClearFlag_DIR
  5426. * @param TIMx Timer instance
  5427. * @retval None
  5428. */
  5429. __STATIC_INLINE void LL_TIM_ClearFlag_DIR(TIM_TypeDef *TIMx)
  5430. {
  5431. WRITE_REG(TIMx->SR, ~(TIM_SR_DIRF));
  5432. }
  5433. /**
  5434. * @brief Indicate whether direction change interrupt flag (DIRF) is set (direction change interrupt is pending).
  5435. * @note Macro IS_TIM_FUNCTINONAL_ENCODER_INTERRUPT_INSTANCE(TIMx) can be used to check whether or not
  5436. * a timer instance provides encoder interrupt management.
  5437. * @rmtoll SR DIRF LL_TIM_IsActiveFlag_DIR
  5438. * @param TIMx Timer instance
  5439. * @retval State of bit (1 or 0).
  5440. */
  5441. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_DIR(const TIM_TypeDef *TIMx)
  5442. {
  5443. return ((READ_BIT(TIMx->SR, TIM_SR_DIRF) == (TIM_SR_DIRF)) ? 1UL : 0UL);
  5444. }
  5445. /**
  5446. * @brief Clear the index interrupt flag (IDXF).
  5447. * @note Macro IS_TIM_FUNCTINONAL_ENCODER_INTERRUPT_INSTANCE(TIMx) can be used to check whether or not
  5448. * a timer instance provides encoder interrupt management.
  5449. * @rmtoll SR IDXF LL_TIM_ClearFlag_IDX
  5450. * @param TIMx Timer instance
  5451. * @retval None
  5452. */
  5453. __STATIC_INLINE void LL_TIM_ClearFlag_IDX(TIM_TypeDef *TIMx)
  5454. {
  5455. WRITE_REG(TIMx->SR, ~(TIM_SR_IDXF));
  5456. }
  5457. /**
  5458. * @brief Indicate whether index interrupt flag (IDXF) is set (index interrupt is pending).
  5459. * @note Macro IS_TIM_FUNCTINONAL_ENCODER_INTERRUPT_INSTANCE(TIMx) can be used to check whether or not
  5460. * a timer instance provides encoder interrupt management.
  5461. * @rmtoll SR IDXF LL_TIM_IsActiveFlag_IDX
  5462. * @param TIMx Timer instance
  5463. * @retval State of bit (1 or 0).
  5464. */
  5465. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_IDX(const TIM_TypeDef *TIMx)
  5466. {
  5467. return ((READ_BIT(TIMx->SR, TIM_SR_IDXF) == (TIM_SR_IDXF)) ? 1UL : 0UL);
  5468. }
  5469. /**
  5470. * @}
  5471. */
  5472. /** @defgroup TIM_LL_EF_IT_Management IT-Management
  5473. * @{
  5474. */
  5475. /**
  5476. * @brief Enable update interrupt (UIE).
  5477. * @rmtoll DIER UIE LL_TIM_EnableIT_UPDATE
  5478. * @param TIMx Timer instance
  5479. * @retval None
  5480. */
  5481. __STATIC_INLINE void LL_TIM_EnableIT_UPDATE(TIM_TypeDef *TIMx)
  5482. {
  5483. SET_BIT(TIMx->DIER, TIM_DIER_UIE);
  5484. }
  5485. /**
  5486. * @brief Disable update interrupt (UIE).
  5487. * @rmtoll DIER UIE LL_TIM_DisableIT_UPDATE
  5488. * @param TIMx Timer instance
  5489. * @retval None
  5490. */
  5491. __STATIC_INLINE void LL_TIM_DisableIT_UPDATE(TIM_TypeDef *TIMx)
  5492. {
  5493. CLEAR_BIT(TIMx->DIER, TIM_DIER_UIE);
  5494. }
  5495. /**
  5496. * @brief Indicates whether the update interrupt (UIE) is enabled.
  5497. * @rmtoll DIER UIE LL_TIM_IsEnabledIT_UPDATE
  5498. * @param TIMx Timer instance
  5499. * @retval State of bit (1 or 0).
  5500. */
  5501. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_UPDATE(const TIM_TypeDef *TIMx)
  5502. {
  5503. return ((READ_BIT(TIMx->DIER, TIM_DIER_UIE) == (TIM_DIER_UIE)) ? 1UL : 0UL);
  5504. }
  5505. /**
  5506. * @brief Enable capture/compare 1 interrupt (CC1IE).
  5507. * @rmtoll DIER CC1IE LL_TIM_EnableIT_CC1
  5508. * @param TIMx Timer instance
  5509. * @retval None
  5510. */
  5511. __STATIC_INLINE void LL_TIM_EnableIT_CC1(TIM_TypeDef *TIMx)
  5512. {
  5513. SET_BIT(TIMx->DIER, TIM_DIER_CC1IE);
  5514. }
  5515. /**
  5516. * @brief Disable capture/compare 1 interrupt (CC1IE).
  5517. * @rmtoll DIER CC1IE LL_TIM_DisableIT_CC1
  5518. * @param TIMx Timer instance
  5519. * @retval None
  5520. */
  5521. __STATIC_INLINE void LL_TIM_DisableIT_CC1(TIM_TypeDef *TIMx)
  5522. {
  5523. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC1IE);
  5524. }
  5525. /**
  5526. * @brief Indicates whether the capture/compare 1 interrupt (CC1IE) is enabled.
  5527. * @rmtoll DIER CC1IE LL_TIM_IsEnabledIT_CC1
  5528. * @param TIMx Timer instance
  5529. * @retval State of bit (1 or 0).
  5530. */
  5531. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC1(const TIM_TypeDef *TIMx)
  5532. {
  5533. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC1IE) == (TIM_DIER_CC1IE)) ? 1UL : 0UL);
  5534. }
  5535. /**
  5536. * @brief Enable capture/compare 2 interrupt (CC2IE).
  5537. * @rmtoll DIER CC2IE LL_TIM_EnableIT_CC2
  5538. * @param TIMx Timer instance
  5539. * @retval None
  5540. */
  5541. __STATIC_INLINE void LL_TIM_EnableIT_CC2(TIM_TypeDef *TIMx)
  5542. {
  5543. SET_BIT(TIMx->DIER, TIM_DIER_CC2IE);
  5544. }
  5545. /**
  5546. * @brief Disable capture/compare 2 interrupt (CC2IE).
  5547. * @rmtoll DIER CC2IE LL_TIM_DisableIT_CC2
  5548. * @param TIMx Timer instance
  5549. * @retval None
  5550. */
  5551. __STATIC_INLINE void LL_TIM_DisableIT_CC2(TIM_TypeDef *TIMx)
  5552. {
  5553. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC2IE);
  5554. }
  5555. /**
  5556. * @brief Indicates whether the capture/compare 2 interrupt (CC2IE) is enabled.
  5557. * @rmtoll DIER CC2IE LL_TIM_IsEnabledIT_CC2
  5558. * @param TIMx Timer instance
  5559. * @retval State of bit (1 or 0).
  5560. */
  5561. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC2(const TIM_TypeDef *TIMx)
  5562. {
  5563. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC2IE) == (TIM_DIER_CC2IE)) ? 1UL : 0UL);
  5564. }
  5565. /**
  5566. * @brief Enable capture/compare 3 interrupt (CC3IE).
  5567. * @rmtoll DIER CC3IE LL_TIM_EnableIT_CC3
  5568. * @param TIMx Timer instance
  5569. * @retval None
  5570. */
  5571. __STATIC_INLINE void LL_TIM_EnableIT_CC3(TIM_TypeDef *TIMx)
  5572. {
  5573. SET_BIT(TIMx->DIER, TIM_DIER_CC3IE);
  5574. }
  5575. /**
  5576. * @brief Disable capture/compare 3 interrupt (CC3IE).
  5577. * @rmtoll DIER CC3IE LL_TIM_DisableIT_CC3
  5578. * @param TIMx Timer instance
  5579. * @retval None
  5580. */
  5581. __STATIC_INLINE void LL_TIM_DisableIT_CC3(TIM_TypeDef *TIMx)
  5582. {
  5583. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC3IE);
  5584. }
  5585. /**
  5586. * @brief Indicates whether the capture/compare 3 interrupt (CC3IE) is enabled.
  5587. * @rmtoll DIER CC3IE LL_TIM_IsEnabledIT_CC3
  5588. * @param TIMx Timer instance
  5589. * @retval State of bit (1 or 0).
  5590. */
  5591. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC3(const TIM_TypeDef *TIMx)
  5592. {
  5593. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC3IE) == (TIM_DIER_CC3IE)) ? 1UL : 0UL);
  5594. }
  5595. /**
  5596. * @brief Enable capture/compare 4 interrupt (CC4IE).
  5597. * @rmtoll DIER CC4IE LL_TIM_EnableIT_CC4
  5598. * @param TIMx Timer instance
  5599. * @retval None
  5600. */
  5601. __STATIC_INLINE void LL_TIM_EnableIT_CC4(TIM_TypeDef *TIMx)
  5602. {
  5603. SET_BIT(TIMx->DIER, TIM_DIER_CC4IE);
  5604. }
  5605. /**
  5606. * @brief Disable capture/compare 4 interrupt (CC4IE).
  5607. * @rmtoll DIER CC4IE LL_TIM_DisableIT_CC4
  5608. * @param TIMx Timer instance
  5609. * @retval None
  5610. */
  5611. __STATIC_INLINE void LL_TIM_DisableIT_CC4(TIM_TypeDef *TIMx)
  5612. {
  5613. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC4IE);
  5614. }
  5615. /**
  5616. * @brief Indicates whether the capture/compare 4 interrupt (CC4IE) is enabled.
  5617. * @rmtoll DIER CC4IE LL_TIM_IsEnabledIT_CC4
  5618. * @param TIMx Timer instance
  5619. * @retval State of bit (1 or 0).
  5620. */
  5621. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC4(const TIM_TypeDef *TIMx)
  5622. {
  5623. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC4IE) == (TIM_DIER_CC4IE)) ? 1UL : 0UL);
  5624. }
  5625. /**
  5626. * @brief Enable commutation interrupt (COMIE).
  5627. * @rmtoll DIER COMIE LL_TIM_EnableIT_COM
  5628. * @param TIMx Timer instance
  5629. * @retval None
  5630. */
  5631. __STATIC_INLINE void LL_TIM_EnableIT_COM(TIM_TypeDef *TIMx)
  5632. {
  5633. SET_BIT(TIMx->DIER, TIM_DIER_COMIE);
  5634. }
  5635. /**
  5636. * @brief Disable commutation interrupt (COMIE).
  5637. * @rmtoll DIER COMIE LL_TIM_DisableIT_COM
  5638. * @param TIMx Timer instance
  5639. * @retval None
  5640. */
  5641. __STATIC_INLINE void LL_TIM_DisableIT_COM(TIM_TypeDef *TIMx)
  5642. {
  5643. CLEAR_BIT(TIMx->DIER, TIM_DIER_COMIE);
  5644. }
  5645. /**
  5646. * @brief Indicates whether the commutation interrupt (COMIE) is enabled.
  5647. * @rmtoll DIER COMIE LL_TIM_IsEnabledIT_COM
  5648. * @param TIMx Timer instance
  5649. * @retval State of bit (1 or 0).
  5650. */
  5651. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_COM(const TIM_TypeDef *TIMx)
  5652. {
  5653. return ((READ_BIT(TIMx->DIER, TIM_DIER_COMIE) == (TIM_DIER_COMIE)) ? 1UL : 0UL);
  5654. }
  5655. /**
  5656. * @brief Enable trigger interrupt (TIE).
  5657. * @rmtoll DIER TIE LL_TIM_EnableIT_TRIG
  5658. * @param TIMx Timer instance
  5659. * @retval None
  5660. */
  5661. __STATIC_INLINE void LL_TIM_EnableIT_TRIG(TIM_TypeDef *TIMx)
  5662. {
  5663. SET_BIT(TIMx->DIER, TIM_DIER_TIE);
  5664. }
  5665. /**
  5666. * @brief Disable trigger interrupt (TIE).
  5667. * @rmtoll DIER TIE LL_TIM_DisableIT_TRIG
  5668. * @param TIMx Timer instance
  5669. * @retval None
  5670. */
  5671. __STATIC_INLINE void LL_TIM_DisableIT_TRIG(TIM_TypeDef *TIMx)
  5672. {
  5673. CLEAR_BIT(TIMx->DIER, TIM_DIER_TIE);
  5674. }
  5675. /**
  5676. * @brief Indicates whether the trigger interrupt (TIE) is enabled.
  5677. * @rmtoll DIER TIE LL_TIM_IsEnabledIT_TRIG
  5678. * @param TIMx Timer instance
  5679. * @retval State of bit (1 or 0).
  5680. */
  5681. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_TRIG(const TIM_TypeDef *TIMx)
  5682. {
  5683. return ((READ_BIT(TIMx->DIER, TIM_DIER_TIE) == (TIM_DIER_TIE)) ? 1UL : 0UL);
  5684. }
  5685. /**
  5686. * @brief Enable break interrupt (BIE).
  5687. * @rmtoll DIER BIE LL_TIM_EnableIT_BRK
  5688. * @param TIMx Timer instance
  5689. * @retval None
  5690. */
  5691. __STATIC_INLINE void LL_TIM_EnableIT_BRK(TIM_TypeDef *TIMx)
  5692. {
  5693. SET_BIT(TIMx->DIER, TIM_DIER_BIE);
  5694. }
  5695. /**
  5696. * @brief Disable break interrupt (BIE).
  5697. * @rmtoll DIER BIE LL_TIM_DisableIT_BRK
  5698. * @param TIMx Timer instance
  5699. * @retval None
  5700. */
  5701. __STATIC_INLINE void LL_TIM_DisableIT_BRK(TIM_TypeDef *TIMx)
  5702. {
  5703. CLEAR_BIT(TIMx->DIER, TIM_DIER_BIE);
  5704. }
  5705. /**
  5706. * @brief Indicates whether the break interrupt (BIE) is enabled.
  5707. * @rmtoll DIER BIE LL_TIM_IsEnabledIT_BRK
  5708. * @param TIMx Timer instance
  5709. * @retval State of bit (1 or 0).
  5710. */
  5711. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_BRK(const TIM_TypeDef *TIMx)
  5712. {
  5713. return ((READ_BIT(TIMx->DIER, TIM_DIER_BIE) == (TIM_DIER_BIE)) ? 1UL : 0UL);
  5714. }
  5715. /**
  5716. * @brief Enable transition error interrupt (TERRIE).
  5717. * @note Macro IS_TIM_ENCODER_ERROR_INSTANCE(TIMx) can be used to check whether or not
  5718. * a timer instance provides encoder error management.
  5719. * @rmtoll DIER TERRIE LL_TIM_EnableIT_TERR
  5720. * @param TIMx Timer instance
  5721. * @retval None
  5722. */
  5723. __STATIC_INLINE void LL_TIM_EnableIT_TERR(TIM_TypeDef *TIMx)
  5724. {
  5725. SET_BIT(TIMx->DIER, TIM_DIER_TERRIE);
  5726. }
  5727. /**
  5728. * @brief Disable transition error interrupt (TERRIE).
  5729. * @note Macro IS_TIM_ENCODER_ERROR_INSTANCE(TIMx) can be used to check whether or not
  5730. * a timer instance provides encoder error management.
  5731. * @rmtoll DIER TERRIE LL_TIM_DisableIT_TERR
  5732. * @param TIMx Timer instance
  5733. * @retval None
  5734. */
  5735. __STATIC_INLINE void LL_TIM_DisableIT_TERR(TIM_TypeDef *TIMx)
  5736. {
  5737. CLEAR_BIT(TIMx->DIER, TIM_DIER_TERRIE);
  5738. }
  5739. /**
  5740. * @brief Indicates whether the transition error interrupt (TERRIE) is enabled.
  5741. * @note Macro IS_TIM_ENCODER_ERROR_INSTANCE(TIMx) can be used to check whether or not
  5742. * a timer instance provides encoder error management.
  5743. * @rmtoll DIER TERRIE LL_TIM_IsEnabledIT_TERR
  5744. * @param TIMx Timer instance
  5745. * @retval State of bit (1 or 0).
  5746. */
  5747. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_TERR(const TIM_TypeDef *TIMx)
  5748. {
  5749. return ((READ_BIT(TIMx->DIER, TIM_DIER_TERRIE) == (TIM_DIER_TERRIE)) ? 1UL : 0UL);
  5750. }
  5751. /**
  5752. * @brief Enable index error interrupt (IERRIE).
  5753. * @note Macro IS_TIM_ENCODER_ERROR_INSTANCE(TIMx) can be used to check whether or not
  5754. * a timer instance provides encoder error management.
  5755. * @rmtoll DIER IERRIE LL_TIM_EnableIT_IERR
  5756. * @param TIMx Timer instance
  5757. * @retval None
  5758. */
  5759. __STATIC_INLINE void LL_TIM_EnableIT_IERR(TIM_TypeDef *TIMx)
  5760. {
  5761. SET_BIT(TIMx->DIER, TIM_DIER_IERRIE);
  5762. }
  5763. /**
  5764. * @brief Disable index error interrupt (IERRIE).
  5765. * @note Macro IS_TIM_ENCODER_ERROR_INSTANCE(TIMx) can be used to check whether or not
  5766. * a timer instance provides encoder error management.
  5767. * @rmtoll DIER IERRIE LL_TIM_DisableIT_IERR
  5768. * @param TIMx Timer instance
  5769. * @retval None
  5770. */
  5771. __STATIC_INLINE void LL_TIM_DisableIT_IERR(TIM_TypeDef *TIMx)
  5772. {
  5773. CLEAR_BIT(TIMx->DIER, TIM_DIER_IERRIE);
  5774. }
  5775. /**
  5776. * @brief Indicates whether the index error interrupt (IERRIE) is enabled.
  5777. * @note Macro IS_TIM_ENCODER_ERROR_INSTANCE(TIMx) can be used to check whether or not
  5778. * a timer instance provides encoder error management.
  5779. * @rmtoll DIER IERRIE LL_TIM_IsEnabledIT_IERR
  5780. * @param TIMx Timer instance
  5781. * @retval State of bit (1 or 0).
  5782. */
  5783. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_IERR(const TIM_TypeDef *TIMx)
  5784. {
  5785. return ((READ_BIT(TIMx->DIER, TIM_DIER_IERRIE) == (TIM_DIER_IERRIE)) ? 1UL : 0UL);
  5786. }
  5787. /**
  5788. * @brief Enable direction change interrupt (DIRIE).
  5789. * @note Macro IS_TIM_FUNCTINONAL_ENCODER_INTERRUPT_INSTANCE(TIMx) can be used to check whether or not
  5790. * a timer instance provides encoder interrupt management.
  5791. * @rmtoll DIER DIRIE LL_TIM_EnableIT_DIR
  5792. * @param TIMx Timer instance
  5793. * @retval None
  5794. */
  5795. __STATIC_INLINE void LL_TIM_EnableIT_DIR(TIM_TypeDef *TIMx)
  5796. {
  5797. SET_BIT(TIMx->DIER, TIM_DIER_DIRIE);
  5798. }
  5799. /**
  5800. * @brief Disable direction change interrupt (DIRIE).
  5801. * @note Macro IS_TIM_FUNCTINONAL_ENCODER_INTERRUPT_INSTANCE(TIMx) can be used to check whether or not
  5802. * a timer instance provides encoder interrupt management.
  5803. * @rmtoll DIER DIRIE LL_TIM_DisableIT_DIR
  5804. * @param TIMx Timer instance
  5805. * @retval None
  5806. */
  5807. __STATIC_INLINE void LL_TIM_DisableIT_DIR(TIM_TypeDef *TIMx)
  5808. {
  5809. CLEAR_BIT(TIMx->DIER, TIM_DIER_DIRIE);
  5810. }
  5811. /**
  5812. * @brief Indicates whether the direction change interrupt (DIRIE) is enabled.
  5813. * @note Macro IS_TIM_FUNCTINONAL_ENCODER_INTERRUPT_INSTANCE(TIMx) can be used to check whether or not
  5814. * a timer instance provides encoder interrupt management.
  5815. * @rmtoll DIER DIRIE LL_TIM_IsEnabledIT_DIR
  5816. * @param TIMx Timer instance
  5817. * @retval State of bit (1 or 0).
  5818. */
  5819. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_DIR(const TIM_TypeDef *TIMx)
  5820. {
  5821. return ((READ_BIT(TIMx->DIER, TIM_DIER_DIRIE) == (TIM_DIER_DIRIE)) ? 1UL : 0UL);
  5822. }
  5823. /**
  5824. * @brief Enable index interrupt (IDXIE).
  5825. * @note Macro IS_TIM_FUNCTINONAL_ENCODER_INTERRUPT_INSTANCE(TIMx) can be used to check whether or not
  5826. * a timer instance provides encoder interrupt management.
  5827. * @rmtoll DIER IDXIE LL_TIM_EnableIT_IDX
  5828. * @param TIMx Timer instance
  5829. * @retval None
  5830. */
  5831. __STATIC_INLINE void LL_TIM_EnableIT_IDX(TIM_TypeDef *TIMx)
  5832. {
  5833. SET_BIT(TIMx->DIER, TIM_DIER_IDXIE);
  5834. }
  5835. /**
  5836. * @brief Disable index interrupt (IDXIE).
  5837. * @note Macro IS_TIM_FUNCTINONAL_ENCODER_INTERRUPT_INSTANCE(TIMx) can be used to check whether or not
  5838. * a timer instance provides encoder interrupt management.
  5839. * @rmtoll DIER IDXIE LL_TIM_DisableIT_IDX
  5840. * @param TIMx Timer instance
  5841. * @retval None
  5842. */
  5843. __STATIC_INLINE void LL_TIM_DisableIT_IDX(TIM_TypeDef *TIMx)
  5844. {
  5845. CLEAR_BIT(TIMx->DIER, TIM_DIER_IDXIE);
  5846. }
  5847. /**
  5848. * @brief Indicates whether the index interrupt (IDXIE) is enabled.
  5849. * @note Macro IS_TIM_FUNCTINONAL_ENCODER_INTERRUPT_INSTANCE(TIMx) can be used to check whether or not
  5850. * a timer instance provides encoder interrupt management.
  5851. * @rmtoll DIER IDXIE LL_TIM_IsEnabledIT_IDX
  5852. * @param TIMx Timer instance
  5853. * @retval State of bit (1 or 0).
  5854. */
  5855. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_IDX(const TIM_TypeDef *TIMx)
  5856. {
  5857. return ((READ_BIT(TIMx->DIER, TIM_DIER_IDXIE) == (TIM_DIER_IDXIE)) ? 1UL : 0UL);
  5858. }
  5859. /**
  5860. * @}
  5861. */
  5862. /** @defgroup TIM_LL_EF_DMA_Management DMA Management
  5863. * @{
  5864. */
  5865. /**
  5866. * @brief Enable update DMA request (UDE).
  5867. * @rmtoll DIER UDE LL_TIM_EnableDMAReq_UPDATE
  5868. * @param TIMx Timer instance
  5869. * @retval None
  5870. */
  5871. __STATIC_INLINE void LL_TIM_EnableDMAReq_UPDATE(TIM_TypeDef *TIMx)
  5872. {
  5873. SET_BIT(TIMx->DIER, TIM_DIER_UDE);
  5874. }
  5875. /**
  5876. * @brief Disable update DMA request (UDE).
  5877. * @rmtoll DIER UDE LL_TIM_DisableDMAReq_UPDATE
  5878. * @param TIMx Timer instance
  5879. * @retval None
  5880. */
  5881. __STATIC_INLINE void LL_TIM_DisableDMAReq_UPDATE(TIM_TypeDef *TIMx)
  5882. {
  5883. CLEAR_BIT(TIMx->DIER, TIM_DIER_UDE);
  5884. }
  5885. /**
  5886. * @brief Indicates whether the update DMA request (UDE) is enabled.
  5887. * @rmtoll DIER UDE LL_TIM_IsEnabledDMAReq_UPDATE
  5888. * @param TIMx Timer instance
  5889. * @retval State of bit (1 or 0).
  5890. */
  5891. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_UPDATE(const TIM_TypeDef *TIMx)
  5892. {
  5893. return ((READ_BIT(TIMx->DIER, TIM_DIER_UDE) == (TIM_DIER_UDE)) ? 1UL : 0UL);
  5894. }
  5895. /**
  5896. * @brief Enable capture/compare 1 DMA request (CC1DE).
  5897. * @rmtoll DIER CC1DE LL_TIM_EnableDMAReq_CC1
  5898. * @param TIMx Timer instance
  5899. * @retval None
  5900. */
  5901. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC1(TIM_TypeDef *TIMx)
  5902. {
  5903. SET_BIT(TIMx->DIER, TIM_DIER_CC1DE);
  5904. }
  5905. /**
  5906. * @brief Disable capture/compare 1 DMA request (CC1DE).
  5907. * @rmtoll DIER CC1DE LL_TIM_DisableDMAReq_CC1
  5908. * @param TIMx Timer instance
  5909. * @retval None
  5910. */
  5911. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC1(TIM_TypeDef *TIMx)
  5912. {
  5913. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC1DE);
  5914. }
  5915. /**
  5916. * @brief Indicates whether the capture/compare 1 DMA request (CC1DE) is enabled.
  5917. * @rmtoll DIER CC1DE LL_TIM_IsEnabledDMAReq_CC1
  5918. * @param TIMx Timer instance
  5919. * @retval State of bit (1 or 0).
  5920. */
  5921. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC1(const TIM_TypeDef *TIMx)
  5922. {
  5923. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC1DE) == (TIM_DIER_CC1DE)) ? 1UL : 0UL);
  5924. }
  5925. /**
  5926. * @brief Enable capture/compare 2 DMA request (CC2DE).
  5927. * @rmtoll DIER CC2DE LL_TIM_EnableDMAReq_CC2
  5928. * @param TIMx Timer instance
  5929. * @retval None
  5930. */
  5931. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC2(TIM_TypeDef *TIMx)
  5932. {
  5933. SET_BIT(TIMx->DIER, TIM_DIER_CC2DE);
  5934. }
  5935. /**
  5936. * @brief Disable capture/compare 2 DMA request (CC2DE).
  5937. * @rmtoll DIER CC2DE LL_TIM_DisableDMAReq_CC2
  5938. * @param TIMx Timer instance
  5939. * @retval None
  5940. */
  5941. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC2(TIM_TypeDef *TIMx)
  5942. {
  5943. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC2DE);
  5944. }
  5945. /**
  5946. * @brief Indicates whether the capture/compare 2 DMA request (CC2DE) is enabled.
  5947. * @rmtoll DIER CC2DE LL_TIM_IsEnabledDMAReq_CC2
  5948. * @param TIMx Timer instance
  5949. * @retval State of bit (1 or 0).
  5950. */
  5951. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC2(const TIM_TypeDef *TIMx)
  5952. {
  5953. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC2DE) == (TIM_DIER_CC2DE)) ? 1UL : 0UL);
  5954. }
  5955. /**
  5956. * @brief Enable capture/compare 3 DMA request (CC3DE).
  5957. * @rmtoll DIER CC3DE LL_TIM_EnableDMAReq_CC3
  5958. * @param TIMx Timer instance
  5959. * @retval None
  5960. */
  5961. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC3(TIM_TypeDef *TIMx)
  5962. {
  5963. SET_BIT(TIMx->DIER, TIM_DIER_CC3DE);
  5964. }
  5965. /**
  5966. * @brief Disable capture/compare 3 DMA request (CC3DE).
  5967. * @rmtoll DIER CC3DE LL_TIM_DisableDMAReq_CC3
  5968. * @param TIMx Timer instance
  5969. * @retval None
  5970. */
  5971. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC3(TIM_TypeDef *TIMx)
  5972. {
  5973. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC3DE);
  5974. }
  5975. /**
  5976. * @brief Indicates whether the capture/compare 3 DMA request (CC3DE) is enabled.
  5977. * @rmtoll DIER CC3DE LL_TIM_IsEnabledDMAReq_CC3
  5978. * @param TIMx Timer instance
  5979. * @retval State of bit (1 or 0).
  5980. */
  5981. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC3(const TIM_TypeDef *TIMx)
  5982. {
  5983. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC3DE) == (TIM_DIER_CC3DE)) ? 1UL : 0UL);
  5984. }
  5985. /**
  5986. * @brief Enable capture/compare 4 DMA request (CC4DE).
  5987. * @rmtoll DIER CC4DE LL_TIM_EnableDMAReq_CC4
  5988. * @param TIMx Timer instance
  5989. * @retval None
  5990. */
  5991. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC4(TIM_TypeDef *TIMx)
  5992. {
  5993. SET_BIT(TIMx->DIER, TIM_DIER_CC4DE);
  5994. }
  5995. /**
  5996. * @brief Disable capture/compare 4 DMA request (CC4DE).
  5997. * @rmtoll DIER CC4DE LL_TIM_DisableDMAReq_CC4
  5998. * @param TIMx Timer instance
  5999. * @retval None
  6000. */
  6001. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC4(TIM_TypeDef *TIMx)
  6002. {
  6003. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC4DE);
  6004. }
  6005. /**
  6006. * @brief Indicates whether the capture/compare 4 DMA request (CC4DE) is enabled.
  6007. * @rmtoll DIER CC4DE LL_TIM_IsEnabledDMAReq_CC4
  6008. * @param TIMx Timer instance
  6009. * @retval State of bit (1 or 0).
  6010. */
  6011. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC4(const TIM_TypeDef *TIMx)
  6012. {
  6013. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC4DE) == (TIM_DIER_CC4DE)) ? 1UL : 0UL);
  6014. }
  6015. /**
  6016. * @brief Enable commutation DMA request (COMDE).
  6017. * @rmtoll DIER COMDE LL_TIM_EnableDMAReq_COM
  6018. * @param TIMx Timer instance
  6019. * @retval None
  6020. */
  6021. __STATIC_INLINE void LL_TIM_EnableDMAReq_COM(TIM_TypeDef *TIMx)
  6022. {
  6023. SET_BIT(TIMx->DIER, TIM_DIER_COMDE);
  6024. }
  6025. /**
  6026. * @brief Disable commutation DMA request (COMDE).
  6027. * @rmtoll DIER COMDE LL_TIM_DisableDMAReq_COM
  6028. * @param TIMx Timer instance
  6029. * @retval None
  6030. */
  6031. __STATIC_INLINE void LL_TIM_DisableDMAReq_COM(TIM_TypeDef *TIMx)
  6032. {
  6033. CLEAR_BIT(TIMx->DIER, TIM_DIER_COMDE);
  6034. }
  6035. /**
  6036. * @brief Indicates whether the commutation DMA request (COMDE) is enabled.
  6037. * @rmtoll DIER COMDE LL_TIM_IsEnabledDMAReq_COM
  6038. * @param TIMx Timer instance
  6039. * @retval State of bit (1 or 0).
  6040. */
  6041. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_COM(const TIM_TypeDef *TIMx)
  6042. {
  6043. return ((READ_BIT(TIMx->DIER, TIM_DIER_COMDE) == (TIM_DIER_COMDE)) ? 1UL : 0UL);
  6044. }
  6045. /**
  6046. * @brief Enable trigger interrupt (TDE).
  6047. * @rmtoll DIER TDE LL_TIM_EnableDMAReq_TRIG
  6048. * @param TIMx Timer instance
  6049. * @retval None
  6050. */
  6051. __STATIC_INLINE void LL_TIM_EnableDMAReq_TRIG(TIM_TypeDef *TIMx)
  6052. {
  6053. SET_BIT(TIMx->DIER, TIM_DIER_TDE);
  6054. }
  6055. /**
  6056. * @brief Disable trigger interrupt (TDE).
  6057. * @rmtoll DIER TDE LL_TIM_DisableDMAReq_TRIG
  6058. * @param TIMx Timer instance
  6059. * @retval None
  6060. */
  6061. __STATIC_INLINE void LL_TIM_DisableDMAReq_TRIG(TIM_TypeDef *TIMx)
  6062. {
  6063. CLEAR_BIT(TIMx->DIER, TIM_DIER_TDE);
  6064. }
  6065. /**
  6066. * @brief Indicates whether the trigger interrupt (TDE) is enabled.
  6067. * @rmtoll DIER TDE LL_TIM_IsEnabledDMAReq_TRIG
  6068. * @param TIMx Timer instance
  6069. * @retval State of bit (1 or 0).
  6070. */
  6071. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_TRIG(const TIM_TypeDef *TIMx)
  6072. {
  6073. return ((READ_BIT(TIMx->DIER, TIM_DIER_TDE) == (TIM_DIER_TDE)) ? 1UL : 0UL);
  6074. }
  6075. /**
  6076. * @}
  6077. */
  6078. /** @defgroup TIM_LL_EF_EVENT_Management EVENT-Management
  6079. * @{
  6080. */
  6081. /**
  6082. * @brief Generate an update event.
  6083. * @rmtoll EGR UG LL_TIM_GenerateEvent_UPDATE
  6084. * @param TIMx Timer instance
  6085. * @retval None
  6086. */
  6087. __STATIC_INLINE void LL_TIM_GenerateEvent_UPDATE(TIM_TypeDef *TIMx)
  6088. {
  6089. SET_BIT(TIMx->EGR, TIM_EGR_UG);
  6090. }
  6091. /**
  6092. * @brief Generate Capture/Compare 1 event.
  6093. * @rmtoll EGR CC1G LL_TIM_GenerateEvent_CC1
  6094. * @param TIMx Timer instance
  6095. * @retval None
  6096. */
  6097. __STATIC_INLINE void LL_TIM_GenerateEvent_CC1(TIM_TypeDef *TIMx)
  6098. {
  6099. SET_BIT(TIMx->EGR, TIM_EGR_CC1G);
  6100. }
  6101. /**
  6102. * @brief Generate Capture/Compare 2 event.
  6103. * @rmtoll EGR CC2G LL_TIM_GenerateEvent_CC2
  6104. * @param TIMx Timer instance
  6105. * @retval None
  6106. */
  6107. __STATIC_INLINE void LL_TIM_GenerateEvent_CC2(TIM_TypeDef *TIMx)
  6108. {
  6109. SET_BIT(TIMx->EGR, TIM_EGR_CC2G);
  6110. }
  6111. /**
  6112. * @brief Generate Capture/Compare 3 event.
  6113. * @rmtoll EGR CC3G LL_TIM_GenerateEvent_CC3
  6114. * @param TIMx Timer instance
  6115. * @retval None
  6116. */
  6117. __STATIC_INLINE void LL_TIM_GenerateEvent_CC3(TIM_TypeDef *TIMx)
  6118. {
  6119. SET_BIT(TIMx->EGR, TIM_EGR_CC3G);
  6120. }
  6121. /**
  6122. * @brief Generate Capture/Compare 4 event.
  6123. * @rmtoll EGR CC4G LL_TIM_GenerateEvent_CC4
  6124. * @param TIMx Timer instance
  6125. * @retval None
  6126. */
  6127. __STATIC_INLINE void LL_TIM_GenerateEvent_CC4(TIM_TypeDef *TIMx)
  6128. {
  6129. SET_BIT(TIMx->EGR, TIM_EGR_CC4G);
  6130. }
  6131. /**
  6132. * @brief Generate commutation event.
  6133. * @rmtoll EGR COMG LL_TIM_GenerateEvent_COM
  6134. * @param TIMx Timer instance
  6135. * @retval None
  6136. */
  6137. __STATIC_INLINE void LL_TIM_GenerateEvent_COM(TIM_TypeDef *TIMx)
  6138. {
  6139. SET_BIT(TIMx->EGR, TIM_EGR_COMG);
  6140. }
  6141. /**
  6142. * @brief Generate trigger event.
  6143. * @rmtoll EGR TG LL_TIM_GenerateEvent_TRIG
  6144. * @param TIMx Timer instance
  6145. * @retval None
  6146. */
  6147. __STATIC_INLINE void LL_TIM_GenerateEvent_TRIG(TIM_TypeDef *TIMx)
  6148. {
  6149. SET_BIT(TIMx->EGR, TIM_EGR_TG);
  6150. }
  6151. /**
  6152. * @brief Generate break event.
  6153. * @rmtoll EGR BG LL_TIM_GenerateEvent_BRK
  6154. * @param TIMx Timer instance
  6155. * @retval None
  6156. */
  6157. __STATIC_INLINE void LL_TIM_GenerateEvent_BRK(TIM_TypeDef *TIMx)
  6158. {
  6159. SET_BIT(TIMx->EGR, TIM_EGR_BG);
  6160. }
  6161. /**
  6162. * @brief Generate break 2 event.
  6163. * @rmtoll EGR B2G LL_TIM_GenerateEvent_BRK2
  6164. * @param TIMx Timer instance
  6165. * @retval None
  6166. */
  6167. __STATIC_INLINE void LL_TIM_GenerateEvent_BRK2(TIM_TypeDef *TIMx)
  6168. {
  6169. SET_BIT(TIMx->EGR, TIM_EGR_B2G);
  6170. }
  6171. /**
  6172. * @}
  6173. */
  6174. #if defined(USE_FULL_LL_DRIVER)
  6175. /** @defgroup TIM_LL_EF_Init Initialisation and deinitialisation functions
  6176. * @{
  6177. */
  6178. ErrorStatus LL_TIM_DeInit(const TIM_TypeDef *TIMx);
  6179. void LL_TIM_StructInit(LL_TIM_InitTypeDef *TIM_InitStruct);
  6180. ErrorStatus LL_TIM_Init(TIM_TypeDef *TIMx, const LL_TIM_InitTypeDef *TIM_InitStruct);
  6181. void LL_TIM_OC_StructInit(LL_TIM_OC_InitTypeDef *TIM_OC_InitStruct);
  6182. ErrorStatus LL_TIM_OC_Init(TIM_TypeDef *TIMx, uint32_t Channel, const LL_TIM_OC_InitTypeDef *TIM_OC_InitStruct);
  6183. void LL_TIM_IC_StructInit(LL_TIM_IC_InitTypeDef *TIM_ICInitStruct);
  6184. ErrorStatus LL_TIM_IC_Init(TIM_TypeDef *TIMx, uint32_t Channel, const LL_TIM_IC_InitTypeDef *TIM_IC_InitStruct);
  6185. void LL_TIM_ENCODER_StructInit(LL_TIM_ENCODER_InitTypeDef *TIM_EncoderInitStruct);
  6186. ErrorStatus LL_TIM_ENCODER_Init(TIM_TypeDef *TIMx, const LL_TIM_ENCODER_InitTypeDef *TIM_EncoderInitStruct);
  6187. void LL_TIM_HALLSENSOR_StructInit(LL_TIM_HALLSENSOR_InitTypeDef *TIM_HallSensorInitStruct);
  6188. ErrorStatus LL_TIM_HALLSENSOR_Init(TIM_TypeDef *TIMx, const LL_TIM_HALLSENSOR_InitTypeDef *TIM_HallSensorInitStruct);
  6189. void LL_TIM_BDTR_StructInit(LL_TIM_BDTR_InitTypeDef *TIM_BDTRInitStruct);
  6190. ErrorStatus LL_TIM_BDTR_Init(TIM_TypeDef *TIMx, const LL_TIM_BDTR_InitTypeDef *TIM_BDTRInitStruct);
  6191. /**
  6192. * @}
  6193. */
  6194. #endif /* USE_FULL_LL_DRIVER */
  6195. /**
  6196. * @}
  6197. */
  6198. /**
  6199. * @}
  6200. */
  6201. #endif /* TIM1 || TIM2 || TIM3 || TIM4 || TIM5 || TIM6 || TIM7 || TIM8 || TIM15 || TIM16 || TIM17 || TIM20 */
  6202. /**
  6203. * @}
  6204. */
  6205. #ifdef __cplusplus
  6206. }
  6207. #endif
  6208. #endif /* __STM32G4xx_LL_TIM_H */