stm32g0xx_ll_tim.h 222 KB

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