stm32l4xx_ll_tim.h 220 KB

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