stm32f3xx_ll_tim.h 219 KB

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