stm32l4xx_ll_tim.h 224 KB

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