stm32f3xx_ll_tim.h 218 KB

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