stm32h7xx_ll_tim.h 233 KB

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