stm32f1xx_ll_tim.h 158 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833
  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_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.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef __STM32F1xx_LL_TIM_H
  21. #define __STM32F1xx_LL_TIM_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32f1xx.h"
  27. /** @addtogroup STM32F1xx_LL_Driver
  28. * @{
  29. */
  30. #if defined (TIM1) || defined (TIM2) || defined (TIM3) || defined (TIM4) || defined (TIM5) || defined (TIM6) || defined (TIM7) || defined (TIM8) || defined (TIM9) || defined (TIM10) || defined (TIM11) || defined (TIM12) || defined (TIM13) || defined (TIM14) || defined (TIM15) || defined (TIM16) || defined (TIM17)
  31. /** @defgroup TIM_LL TIM
  32. * @{
  33. */
  34. /* Private types -------------------------------------------------------------*/
  35. /* Private variables ---------------------------------------------------------*/
  36. /** @defgroup TIM_LL_Private_Variables TIM Private Variables
  37. * @{
  38. */
  39. static const uint8_t OFFSET_TAB_CCMRx[] =
  40. {
  41. 0x00U, /* 0: TIMx_CH1 */
  42. 0x00U, /* 1: TIMx_CH1N */
  43. 0x00U, /* 2: TIMx_CH2 */
  44. 0x00U, /* 3: TIMx_CH2N */
  45. 0x04U, /* 4: TIMx_CH3 */
  46. 0x04U, /* 5: TIMx_CH3N */
  47. 0x04U /* 6: TIMx_CH4 */
  48. };
  49. static const uint8_t SHIFT_TAB_OCxx[] =
  50. {
  51. 0U, /* 0: OC1M, OC1FE, OC1PE */
  52. 0U, /* 1: - NA */
  53. 8U, /* 2: OC2M, OC2FE, OC2PE */
  54. 0U, /* 3: - NA */
  55. 0U, /* 4: OC3M, OC3FE, OC3PE */
  56. 0U, /* 5: - NA */
  57. 8U /* 6: OC4M, OC4FE, OC4PE */
  58. };
  59. static const uint8_t SHIFT_TAB_ICxx[] =
  60. {
  61. 0U, /* 0: CC1S, IC1PSC, IC1F */
  62. 0U, /* 1: - NA */
  63. 8U, /* 2: CC2S, IC2PSC, IC2F */
  64. 0U, /* 3: - NA */
  65. 0U, /* 4: CC3S, IC3PSC, IC3F */
  66. 0U, /* 5: - NA */
  67. 8U /* 6: CC4S, IC4PSC, IC4F */
  68. };
  69. static const uint8_t SHIFT_TAB_CCxP[] =
  70. {
  71. 0U, /* 0: CC1P */
  72. 2U, /* 1: CC1NP */
  73. 4U, /* 2: CC2P */
  74. 6U, /* 3: CC2NP */
  75. 8U, /* 4: CC3P */
  76. 10U, /* 5: CC3NP */
  77. 12U /* 6: CC4P */
  78. };
  79. static const uint8_t SHIFT_TAB_OISx[] =
  80. {
  81. 0U, /* 0: OIS1 */
  82. 1U, /* 1: OIS1N */
  83. 2U, /* 2: OIS2 */
  84. 3U, /* 3: OIS2N */
  85. 4U, /* 4: OIS3 */
  86. 5U, /* 5: OIS3N */
  87. 6U /* 6: OIS4 */
  88. };
  89. /**
  90. * @}
  91. */
  92. /* Private constants ---------------------------------------------------------*/
  93. /** @defgroup TIM_LL_Private_Constants TIM Private Constants
  94. * @{
  95. */
  96. /* Mask used to set the TDG[x:0] of the DTG bits of the TIMx_BDTR register */
  97. #define DT_DELAY_1 ((uint8_t)0x7F)
  98. #define DT_DELAY_2 ((uint8_t)0x3F)
  99. #define DT_DELAY_3 ((uint8_t)0x1F)
  100. #define DT_DELAY_4 ((uint8_t)0x1F)
  101. /* Mask used to set the DTG[7:5] bits of the DTG bits of the TIMx_BDTR register */
  102. #define DT_RANGE_1 ((uint8_t)0x00)
  103. #define DT_RANGE_2 ((uint8_t)0x80)
  104. #define DT_RANGE_3 ((uint8_t)0xC0)
  105. #define DT_RANGE_4 ((uint8_t)0xE0)
  106. /**
  107. * @}
  108. */
  109. /* Private macros ------------------------------------------------------------*/
  110. /** @defgroup TIM_LL_Private_Macros TIM Private Macros
  111. * @{
  112. */
  113. /** @brief Convert channel id into channel index.
  114. * @param __CHANNEL__ This parameter can be one of the following values:
  115. * @arg @ref LL_TIM_CHANNEL_CH1
  116. * @arg @ref LL_TIM_CHANNEL_CH1N
  117. * @arg @ref LL_TIM_CHANNEL_CH2
  118. * @arg @ref LL_TIM_CHANNEL_CH2N
  119. * @arg @ref LL_TIM_CHANNEL_CH3
  120. * @arg @ref LL_TIM_CHANNEL_CH3N
  121. * @arg @ref LL_TIM_CHANNEL_CH4
  122. * @retval none
  123. */
  124. #define TIM_GET_CHANNEL_INDEX( __CHANNEL__) \
  125. (((__CHANNEL__) == LL_TIM_CHANNEL_CH1) ? 0U :\
  126. ((__CHANNEL__) == LL_TIM_CHANNEL_CH1N) ? 1U :\
  127. ((__CHANNEL__) == LL_TIM_CHANNEL_CH2) ? 2U :\
  128. ((__CHANNEL__) == LL_TIM_CHANNEL_CH2N) ? 3U :\
  129. ((__CHANNEL__) == LL_TIM_CHANNEL_CH3) ? 4U :\
  130. ((__CHANNEL__) == LL_TIM_CHANNEL_CH3N) ? 5U : 6U)
  131. /** @brief Calculate the deadtime sampling period(in ps).
  132. * @param __TIMCLK__ timer input clock frequency (in Hz).
  133. * @param __CKD__ This parameter can be one of the following values:
  134. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  135. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  136. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  137. * @retval none
  138. */
  139. #define TIM_CALC_DTS(__TIMCLK__, __CKD__) \
  140. (((__CKD__) == LL_TIM_CLOCKDIVISION_DIV1) ? ((uint64_t)1000000000000U/(__TIMCLK__)) : \
  141. ((__CKD__) == LL_TIM_CLOCKDIVISION_DIV2) ? ((uint64_t)1000000000000U/((__TIMCLK__) >> 1U)) : \
  142. ((uint64_t)1000000000000U/((__TIMCLK__) >> 2U)))
  143. /**
  144. * @}
  145. */
  146. /* Exported types ------------------------------------------------------------*/
  147. #if defined(USE_FULL_LL_DRIVER)
  148. /** @defgroup TIM_LL_ES_INIT TIM Exported Init structure
  149. * @{
  150. */
  151. /**
  152. * @brief TIM Time Base configuration structure definition.
  153. */
  154. typedef struct
  155. {
  156. uint16_t Prescaler; /*!< Specifies the prescaler value used to divide the TIM clock.
  157. This parameter can be a number between Min_Data=0x0000 and Max_Data=0xFFFF.
  158. This feature can be modified afterwards using unitary function @ref LL_TIM_SetPrescaler().*/
  159. uint32_t CounterMode; /*!< Specifies the counter mode.
  160. This parameter can be a value of @ref TIM_LL_EC_COUNTERMODE.
  161. This feature can be modified afterwards using unitary function @ref LL_TIM_SetCounterMode().*/
  162. uint32_t Autoreload; /*!< Specifies the auto reload value to be loaded into the active
  163. Auto-Reload Register at the next update event.
  164. This parameter must be a number between Min_Data=0x0000 and Max_Data=0xFFFF.
  165. Some timer instances may support 32 bits counters. In that case this parameter must be a number between 0x0000 and 0xFFFFFFFF.
  166. This feature can be modified afterwards using unitary function @ref LL_TIM_SetAutoReload().*/
  167. uint32_t ClockDivision; /*!< Specifies the clock division.
  168. This parameter can be a value of @ref TIM_LL_EC_CLOCKDIVISION.
  169. This feature can be modified afterwards using unitary function @ref LL_TIM_SetClockDivision().*/
  170. uint32_t RepetitionCounter; /*!< Specifies the repetition counter value. Each time the RCR downcounter
  171. reaches zero, an update event is generated and counting restarts
  172. from the RCR value (N).
  173. This means in PWM mode that (N+1) corresponds to:
  174. - the number of PWM periods in edge-aligned mode
  175. - the number of half PWM period in center-aligned mode
  176. GP timers: this parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF.
  177. Advanced timers: this parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF.
  178. This feature can be modified afterwards using unitary function @ref LL_TIM_SetRepetitionCounter().*/
  179. } LL_TIM_InitTypeDef;
  180. /**
  181. * @brief TIM Output Compare configuration structure definition.
  182. */
  183. typedef struct
  184. {
  185. uint32_t OCMode; /*!< Specifies the output mode.
  186. This parameter can be a value of @ref TIM_LL_EC_OCMODE.
  187. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetMode().*/
  188. uint32_t OCState; /*!< Specifies the TIM Output Compare state.
  189. This parameter can be a value of @ref TIM_LL_EC_OCSTATE.
  190. This feature can be modified afterwards using unitary functions @ref LL_TIM_CC_EnableChannel() or @ref LL_TIM_CC_DisableChannel().*/
  191. uint32_t OCNState; /*!< Specifies the TIM complementary Output Compare state.
  192. This parameter can be a value of @ref TIM_LL_EC_OCSTATE.
  193. This feature can be modified afterwards using unitary functions @ref LL_TIM_CC_EnableChannel() or @ref LL_TIM_CC_DisableChannel().*/
  194. uint32_t CompareValue; /*!< Specifies the Compare value to be loaded into the Capture Compare Register.
  195. This parameter can be a number between Min_Data=0x0000 and Max_Data=0xFFFF.
  196. This feature can be modified afterwards using unitary function LL_TIM_OC_SetCompareCHx (x=1..6).*/
  197. uint32_t OCPolarity; /*!< Specifies the output polarity.
  198. This parameter can be a value of @ref TIM_LL_EC_OCPOLARITY.
  199. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetPolarity().*/
  200. uint32_t OCNPolarity; /*!< Specifies the complementary output polarity.
  201. This parameter can be a value of @ref TIM_LL_EC_OCPOLARITY.
  202. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetPolarity().*/
  203. uint32_t OCIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
  204. This parameter can be a value of @ref TIM_LL_EC_OCIDLESTATE.
  205. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetIdleState().*/
  206. uint32_t OCNIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
  207. This parameter can be a value of @ref TIM_LL_EC_OCIDLESTATE.
  208. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetIdleState().*/
  209. } LL_TIM_OC_InitTypeDef;
  210. /**
  211. * @brief TIM Input Capture configuration structure definition.
  212. */
  213. typedef struct
  214. {
  215. uint32_t ICPolarity; /*!< Specifies the active edge of the input signal.
  216. This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
  217. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
  218. uint32_t ICActiveInput; /*!< Specifies the input.
  219. This parameter can be a value of @ref TIM_LL_EC_ACTIVEINPUT.
  220. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetActiveInput().*/
  221. uint32_t ICPrescaler; /*!< Specifies the Input Capture Prescaler.
  222. This parameter can be a value of @ref TIM_LL_EC_ICPSC.
  223. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
  224. uint32_t ICFilter; /*!< Specifies the input capture filter.
  225. This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
  226. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
  227. } LL_TIM_IC_InitTypeDef;
  228. /**
  229. * @brief TIM Encoder interface configuration structure definition.
  230. */
  231. typedef struct
  232. {
  233. uint32_t EncoderMode; /*!< Specifies the encoder resolution (x2 or x4).
  234. This parameter can be a value of @ref TIM_LL_EC_ENCODERMODE.
  235. This feature can be modified afterwards using unitary function @ref LL_TIM_SetEncoderMode().*/
  236. uint32_t IC1Polarity; /*!< Specifies the active edge of TI1 input.
  237. This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
  238. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
  239. uint32_t IC1ActiveInput; /*!< Specifies the TI1 input source
  240. This parameter can be a value of @ref TIM_LL_EC_ACTIVEINPUT.
  241. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetActiveInput().*/
  242. uint32_t IC1Prescaler; /*!< Specifies the TI1 input prescaler value.
  243. This parameter can be a value of @ref TIM_LL_EC_ICPSC.
  244. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
  245. uint32_t IC1Filter; /*!< Specifies the TI1 input filter.
  246. This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
  247. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
  248. uint32_t IC2Polarity; /*!< Specifies the active edge of TI2 input.
  249. This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
  250. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
  251. uint32_t IC2ActiveInput; /*!< Specifies the TI2 input source
  252. This parameter can be a value of @ref TIM_LL_EC_ACTIVEINPUT.
  253. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetActiveInput().*/
  254. uint32_t IC2Prescaler; /*!< Specifies the TI2 input prescaler value.
  255. This parameter can be a value of @ref TIM_LL_EC_ICPSC.
  256. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
  257. uint32_t IC2Filter; /*!< Specifies the TI2 input filter.
  258. This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
  259. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
  260. } LL_TIM_ENCODER_InitTypeDef;
  261. /**
  262. * @brief TIM Hall sensor interface configuration structure definition.
  263. */
  264. typedef struct
  265. {
  266. uint32_t IC1Polarity; /*!< Specifies the active edge of TI1 input.
  267. This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
  268. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
  269. uint32_t IC1Prescaler; /*!< Specifies the TI1 input prescaler value.
  270. Prescaler must be set to get a maximum counter period longer than the
  271. time interval between 2 consecutive changes on the Hall inputs.
  272. This parameter can be a value of @ref TIM_LL_EC_ICPSC.
  273. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
  274. uint32_t IC1Filter; /*!< Specifies the TI1 input filter.
  275. This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
  276. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
  277. uint32_t CommutationDelay; /*!< Specifies the compare value to be loaded into the Capture Compare Register.
  278. A positive pulse (TRGO event) is generated with a programmable delay every time
  279. a change occurs on the Hall inputs.
  280. This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF.
  281. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetCompareCH2().*/
  282. } LL_TIM_HALLSENSOR_InitTypeDef;
  283. /**
  284. * @brief BDTR (Break and Dead Time) structure definition
  285. */
  286. typedef struct
  287. {
  288. uint32_t OSSRState; /*!< Specifies the Off-State selection used in Run mode.
  289. This parameter can be a value of @ref TIM_LL_EC_OSSR
  290. This feature can be modified afterwards using unitary function @ref LL_TIM_SetOffStates()
  291. @note This bit-field cannot be modified as long as LOCK level 2 has been programmed. */
  292. uint32_t OSSIState; /*!< Specifies the Off-State used in Idle state.
  293. This parameter can be a value of @ref TIM_LL_EC_OSSI
  294. This feature can be modified afterwards using unitary function @ref LL_TIM_SetOffStates()
  295. @note This bit-field cannot be modified as long as LOCK level 2 has been programmed. */
  296. uint32_t LockLevel; /*!< Specifies the LOCK level parameters.
  297. This parameter can be a value of @ref TIM_LL_EC_LOCKLEVEL
  298. @note The LOCK bits can be written only once after the reset. Once the TIMx_BDTR register
  299. has been written, their content is frozen until the next reset.*/
  300. uint8_t DeadTime; /*!< Specifies the delay time between the switching-off and the
  301. switching-on of the outputs.
  302. This parameter can be a number between Min_Data = 0x00 and Max_Data = 0xFF.
  303. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetDeadTime()
  304. @note This bit-field can not be modified as long as LOCK level 1, 2 or 3 has been programmed. */
  305. uint16_t BreakState; /*!< Specifies whether the TIM Break input is enabled or not.
  306. This parameter can be a value of @ref TIM_LL_EC_BREAK_ENABLE
  307. This feature can be modified afterwards using unitary functions @ref LL_TIM_EnableBRK() or @ref LL_TIM_DisableBRK()
  308. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  309. uint32_t BreakPolarity; /*!< Specifies the TIM Break Input pin polarity.
  310. This parameter can be a value of @ref TIM_LL_EC_BREAK_POLARITY
  311. This feature can be modified afterwards using unitary function @ref LL_TIM_ConfigBRK()
  312. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  313. uint32_t AutomaticOutput; /*!< Specifies whether the TIM Automatic Output feature is enabled or not.
  314. This parameter can be a value of @ref TIM_LL_EC_AUTOMATICOUTPUT_ENABLE
  315. This feature can be modified afterwards using unitary functions @ref LL_TIM_EnableAutomaticOutput() or @ref LL_TIM_DisableAutomaticOutput()
  316. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  317. } LL_TIM_BDTR_InitTypeDef;
  318. /**
  319. * @}
  320. */
  321. #endif /* USE_FULL_LL_DRIVER */
  322. /* Exported constants --------------------------------------------------------*/
  323. /** @defgroup TIM_LL_Exported_Constants TIM Exported Constants
  324. * @{
  325. */
  326. /** @defgroup TIM_LL_EC_GET_FLAG Get Flags Defines
  327. * @brief Flags defines which can be used with LL_TIM_ReadReg function.
  328. * @{
  329. */
  330. #define LL_TIM_SR_UIF TIM_SR_UIF /*!< Update interrupt flag */
  331. #define LL_TIM_SR_CC1IF TIM_SR_CC1IF /*!< Capture/compare 1 interrupt flag */
  332. #define LL_TIM_SR_CC2IF TIM_SR_CC2IF /*!< Capture/compare 2 interrupt flag */
  333. #define LL_TIM_SR_CC3IF TIM_SR_CC3IF /*!< Capture/compare 3 interrupt flag */
  334. #define LL_TIM_SR_CC4IF TIM_SR_CC4IF /*!< Capture/compare 4 interrupt flag */
  335. #define LL_TIM_SR_COMIF TIM_SR_COMIF /*!< COM interrupt flag */
  336. #define LL_TIM_SR_TIF TIM_SR_TIF /*!< Trigger interrupt flag */
  337. #define LL_TIM_SR_BIF TIM_SR_BIF /*!< Break interrupt flag */
  338. #define LL_TIM_SR_CC1OF TIM_SR_CC1OF /*!< Capture/Compare 1 overcapture flag */
  339. #define LL_TIM_SR_CC2OF TIM_SR_CC2OF /*!< Capture/Compare 2 overcapture flag */
  340. #define LL_TIM_SR_CC3OF TIM_SR_CC3OF /*!< Capture/Compare 3 overcapture flag */
  341. #define LL_TIM_SR_CC4OF TIM_SR_CC4OF /*!< Capture/Compare 4 overcapture flag */
  342. /**
  343. * @}
  344. */
  345. #if defined(USE_FULL_LL_DRIVER)
  346. /** @defgroup TIM_LL_EC_BREAK_ENABLE Break Enable
  347. * @{
  348. */
  349. #define LL_TIM_BREAK_DISABLE 0x00000000U /*!< Break function disabled */
  350. #define LL_TIM_BREAK_ENABLE TIM_BDTR_BKE /*!< Break function enabled */
  351. /**
  352. * @}
  353. */
  354. /** @defgroup TIM_LL_EC_AUTOMATICOUTPUT_ENABLE Automatic output enable
  355. * @{
  356. */
  357. #define LL_TIM_AUTOMATICOUTPUT_DISABLE 0x00000000U /*!< MOE can be set only by software */
  358. #define LL_TIM_AUTOMATICOUTPUT_ENABLE TIM_BDTR_AOE /*!< MOE can be set by software or automatically at the next update event */
  359. /**
  360. * @}
  361. */
  362. #endif /* USE_FULL_LL_DRIVER */
  363. /** @defgroup TIM_LL_EC_IT IT Defines
  364. * @brief IT defines which can be used with LL_TIM_ReadReg and LL_TIM_WriteReg functions.
  365. * @{
  366. */
  367. #define LL_TIM_DIER_UIE TIM_DIER_UIE /*!< Update interrupt enable */
  368. #define LL_TIM_DIER_CC1IE TIM_DIER_CC1IE /*!< Capture/compare 1 interrupt enable */
  369. #define LL_TIM_DIER_CC2IE TIM_DIER_CC2IE /*!< Capture/compare 2 interrupt enable */
  370. #define LL_TIM_DIER_CC3IE TIM_DIER_CC3IE /*!< Capture/compare 3 interrupt enable */
  371. #define LL_TIM_DIER_CC4IE TIM_DIER_CC4IE /*!< Capture/compare 4 interrupt enable */
  372. #define LL_TIM_DIER_COMIE TIM_DIER_COMIE /*!< COM interrupt enable */
  373. #define LL_TIM_DIER_TIE TIM_DIER_TIE /*!< Trigger interrupt enable */
  374. #define LL_TIM_DIER_BIE TIM_DIER_BIE /*!< Break interrupt enable */
  375. /**
  376. * @}
  377. */
  378. /** @defgroup TIM_LL_EC_UPDATESOURCE Update Source
  379. * @{
  380. */
  381. #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 */
  382. #define LL_TIM_UPDATESOURCE_COUNTER TIM_CR1_URS /*!< Only counter overflow/underflow generates an update request */
  383. /**
  384. * @}
  385. */
  386. /** @defgroup TIM_LL_EC_ONEPULSEMODE One Pulse Mode
  387. * @{
  388. */
  389. #define LL_TIM_ONEPULSEMODE_SINGLE TIM_CR1_OPM /*!< Counter is not stopped at update event */
  390. #define LL_TIM_ONEPULSEMODE_REPETITIVE 0x00000000U /*!< Counter stops counting at the next update event */
  391. /**
  392. * @}
  393. */
  394. /** @defgroup TIM_LL_EC_COUNTERMODE Counter Mode
  395. * @{
  396. */
  397. #define LL_TIM_COUNTERMODE_UP 0x00000000U /*!<Counter used as upcounter */
  398. #define LL_TIM_COUNTERMODE_DOWN TIM_CR1_DIR /*!< Counter used as downcounter */
  399. #define LL_TIM_COUNTERMODE_CENTER_DOWN TIM_CR1_CMS_0 /*!< The counter counts up and down alternatively. Output compare interrupt flags of output channels are set only when the counter is counting down. */
  400. #define LL_TIM_COUNTERMODE_CENTER_UP TIM_CR1_CMS_1 /*!<The counter counts up and down alternatively. Output compare interrupt flags of output channels are set only when the counter is counting up */
  401. #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. */
  402. /**
  403. * @}
  404. */
  405. /** @defgroup TIM_LL_EC_CLOCKDIVISION Clock Division
  406. * @{
  407. */
  408. #define LL_TIM_CLOCKDIVISION_DIV1 0x00000000U /*!< tDTS=tCK_INT */
  409. #define LL_TIM_CLOCKDIVISION_DIV2 TIM_CR1_CKD_0 /*!< tDTS=2*tCK_INT */
  410. #define LL_TIM_CLOCKDIVISION_DIV4 TIM_CR1_CKD_1 /*!< tDTS=4*tCK_INT */
  411. /**
  412. * @}
  413. */
  414. /** @defgroup TIM_LL_EC_COUNTERDIRECTION Counter Direction
  415. * @{
  416. */
  417. #define LL_TIM_COUNTERDIRECTION_UP 0x00000000U /*!< Timer counter counts up */
  418. #define LL_TIM_COUNTERDIRECTION_DOWN TIM_CR1_DIR /*!< Timer counter counts down */
  419. /**
  420. * @}
  421. */
  422. /** @defgroup TIM_LL_EC_CCUPDATESOURCE Capture Compare Update Source
  423. * @{
  424. */
  425. #define LL_TIM_CCUPDATESOURCE_COMG_ONLY 0x00000000U /*!< Capture/compare control bits are updated by setting the COMG bit only */
  426. #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) */
  427. /**
  428. * @}
  429. */
  430. /** @defgroup TIM_LL_EC_CCDMAREQUEST Capture Compare DMA Request
  431. * @{
  432. */
  433. #define LL_TIM_CCDMAREQUEST_CC 0x00000000U /*!< CCx DMA request sent when CCx event occurs */
  434. #define LL_TIM_CCDMAREQUEST_UPDATE TIM_CR2_CCDS /*!< CCx DMA requests sent when update event occurs */
  435. /**
  436. * @}
  437. */
  438. /** @defgroup TIM_LL_EC_LOCKLEVEL Lock Level
  439. * @{
  440. */
  441. #define LL_TIM_LOCKLEVEL_OFF 0x00000000U /*!< LOCK OFF - No bit is write protected */
  442. #define LL_TIM_LOCKLEVEL_1 TIM_BDTR_LOCK_0 /*!< LOCK Level 1 */
  443. #define LL_TIM_LOCKLEVEL_2 TIM_BDTR_LOCK_1 /*!< LOCK Level 2 */
  444. #define LL_TIM_LOCKLEVEL_3 TIM_BDTR_LOCK /*!< LOCK Level 3 */
  445. /**
  446. * @}
  447. */
  448. /** @defgroup TIM_LL_EC_CHANNEL Channel
  449. * @{
  450. */
  451. #define LL_TIM_CHANNEL_CH1 TIM_CCER_CC1E /*!< Timer input/output channel 1 */
  452. #define LL_TIM_CHANNEL_CH1N TIM_CCER_CC1NE /*!< Timer complementary output channel 1 */
  453. #define LL_TIM_CHANNEL_CH2 TIM_CCER_CC2E /*!< Timer input/output channel 2 */
  454. #define LL_TIM_CHANNEL_CH2N TIM_CCER_CC2NE /*!< Timer complementary output channel 2 */
  455. #define LL_TIM_CHANNEL_CH3 TIM_CCER_CC3E /*!< Timer input/output channel 3 */
  456. #define LL_TIM_CHANNEL_CH3N TIM_CCER_CC3NE /*!< Timer complementary output channel 3 */
  457. #define LL_TIM_CHANNEL_CH4 TIM_CCER_CC4E /*!< Timer input/output channel 4 */
  458. /**
  459. * @}
  460. */
  461. #if defined(USE_FULL_LL_DRIVER)
  462. /** @defgroup TIM_LL_EC_OCSTATE Output Configuration State
  463. * @{
  464. */
  465. #define LL_TIM_OCSTATE_DISABLE 0x00000000U /*!< OCx is not active */
  466. #define LL_TIM_OCSTATE_ENABLE TIM_CCER_CC1E /*!< OCx signal is output on the corresponding output pin */
  467. /**
  468. * @}
  469. */
  470. #endif /* USE_FULL_LL_DRIVER */
  471. /** @defgroup TIM_LL_EC_OCMODE Output Configuration Mode
  472. * @{
  473. */
  474. #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 */
  475. #define LL_TIM_OCMODE_ACTIVE TIM_CCMR1_OC1M_0 /*!<OCyREF is forced high on compare match*/
  476. #define LL_TIM_OCMODE_INACTIVE TIM_CCMR1_OC1M_1 /*!<OCyREF is forced low on compare match*/
  477. #define LL_TIM_OCMODE_TOGGLE (TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0) /*!<OCyREF toggles on compare match*/
  478. #define LL_TIM_OCMODE_FORCED_INACTIVE TIM_CCMR1_OC1M_2 /*!<OCyREF is forced low*/
  479. #define LL_TIM_OCMODE_FORCED_ACTIVE (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_0) /*!<OCyREF is forced high*/
  480. #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.*/
  481. #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*/
  482. /**
  483. * @}
  484. */
  485. /** @defgroup TIM_LL_EC_OCPOLARITY Output Configuration Polarity
  486. * @{
  487. */
  488. #define LL_TIM_OCPOLARITY_HIGH 0x00000000U /*!< OCxactive high*/
  489. #define LL_TIM_OCPOLARITY_LOW TIM_CCER_CC1P /*!< OCxactive low*/
  490. /**
  491. * @}
  492. */
  493. /** @defgroup TIM_LL_EC_OCIDLESTATE Output Configuration Idle State
  494. * @{
  495. */
  496. #define LL_TIM_OCIDLESTATE_LOW 0x00000000U /*!<OCx=0 (after a dead-time if OC is implemented) when MOE=0*/
  497. #define LL_TIM_OCIDLESTATE_HIGH TIM_CR2_OIS1 /*!<OCx=1 (after a dead-time if OC is implemented) when MOE=0*/
  498. /**
  499. * @}
  500. */
  501. /** @defgroup TIM_LL_EC_ACTIVEINPUT Active Input Selection
  502. * @{
  503. */
  504. #define LL_TIM_ACTIVEINPUT_DIRECTTI (TIM_CCMR1_CC1S_0 << 16U) /*!< ICx is mapped on TIx */
  505. #define LL_TIM_ACTIVEINPUT_INDIRECTTI (TIM_CCMR1_CC1S_1 << 16U) /*!< ICx is mapped on TIy */
  506. #define LL_TIM_ACTIVEINPUT_TRC (TIM_CCMR1_CC1S << 16U) /*!< ICx is mapped on TRC */
  507. /**
  508. * @}
  509. */
  510. /** @defgroup TIM_LL_EC_ICPSC Input Configuration Prescaler
  511. * @{
  512. */
  513. #define LL_TIM_ICPSC_DIV1 0x00000000U /*!< No prescaler, capture is done each time an edge is detected on the capture input */
  514. #define LL_TIM_ICPSC_DIV2 (TIM_CCMR1_IC1PSC_0 << 16U) /*!< Capture is done once every 2 events */
  515. #define LL_TIM_ICPSC_DIV4 (TIM_CCMR1_IC1PSC_1 << 16U) /*!< Capture is done once every 4 events */
  516. #define LL_TIM_ICPSC_DIV8 (TIM_CCMR1_IC1PSC << 16U) /*!< Capture is done once every 8 events */
  517. /**
  518. * @}
  519. */
  520. /** @defgroup TIM_LL_EC_IC_FILTER Input Configuration Filter
  521. * @{
  522. */
  523. #define LL_TIM_IC_FILTER_FDIV1 0x00000000U /*!< No filter, sampling is done at fDTS */
  524. #define LL_TIM_IC_FILTER_FDIV1_N2 (TIM_CCMR1_IC1F_0 << 16U) /*!< fSAMPLING=fCK_INT, N=2 */
  525. #define LL_TIM_IC_FILTER_FDIV1_N4 (TIM_CCMR1_IC1F_1 << 16U) /*!< fSAMPLING=fCK_INT, N=4 */
  526. #define LL_TIM_IC_FILTER_FDIV1_N8 ((TIM_CCMR1_IC1F_1 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fCK_INT, N=8 */
  527. #define LL_TIM_IC_FILTER_FDIV2_N6 (TIM_CCMR1_IC1F_2 << 16U) /*!< fSAMPLING=fDTS/2, N=6 */
  528. #define LL_TIM_IC_FILTER_FDIV2_N8 ((TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/2, N=8 */
  529. #define LL_TIM_IC_FILTER_FDIV4_N6 ((TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_1) << 16U) /*!< fSAMPLING=fDTS/4, N=6 */
  530. #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 */
  531. #define LL_TIM_IC_FILTER_FDIV8_N6 (TIM_CCMR1_IC1F_3 << 16U) /*!< fSAMPLING=fDTS/8, N=6 */
  532. #define LL_TIM_IC_FILTER_FDIV8_N8 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/8, N=8 */
  533. #define LL_TIM_IC_FILTER_FDIV16_N5 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_1) << 16U) /*!< fSAMPLING=fDTS/16, N=5 */
  534. #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 */
  535. #define LL_TIM_IC_FILTER_FDIV16_N8 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_2) << 16U) /*!< fSAMPLING=fDTS/16, N=8 */
  536. #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 */
  537. #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 */
  538. #define LL_TIM_IC_FILTER_FDIV32_N8 (TIM_CCMR1_IC1F << 16U) /*!< fSAMPLING=fDTS/32, N=8 */
  539. /**
  540. * @}
  541. */
  542. /** @defgroup TIM_LL_EC_IC_POLARITY Input Configuration Polarity
  543. * @{
  544. */
  545. #define LL_TIM_IC_POLARITY_RISING 0x00000000U /*!< The circuit is sensitive to TIxFP1 rising edge, TIxFP1 is not inverted */
  546. #define LL_TIM_IC_POLARITY_FALLING TIM_CCER_CC1P /*!< The circuit is sensitive to TIxFP1 falling edge, TIxFP1 is inverted */
  547. /**
  548. * @}
  549. */
  550. /** @defgroup TIM_LL_EC_CLOCKSOURCE Clock Source
  551. * @{
  552. */
  553. #define LL_TIM_CLOCKSOURCE_INTERNAL 0x00000000U /*!< The timer is clocked by the internal clock provided from the RCC */
  554. #define LL_TIM_CLOCKSOURCE_EXT_MODE1 (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0) /*!< Counter counts at each rising or falling edge on a selected input*/
  555. #define LL_TIM_CLOCKSOURCE_EXT_MODE2 TIM_SMCR_ECE /*!< Counter counts at each rising or falling edge on the external trigger input ETR */
  556. /**
  557. * @}
  558. */
  559. /** @defgroup TIM_LL_EC_ENCODERMODE Encoder Mode
  560. * @{
  561. */
  562. #define LL_TIM_ENCODERMODE_X2_TI1 TIM_SMCR_SMS_0 /*!< Quadrature encoder mode 1, x2 mode - Counter counts up/down on TI1FP1 edge depending on TI2FP2 level */
  563. #define LL_TIM_ENCODERMODE_X2_TI2 TIM_SMCR_SMS_1 /*!< Quadrature encoder mode 2, x2 mode - Counter counts up/down on TI2FP2 edge depending on TI1FP1 level */
  564. #define LL_TIM_ENCODERMODE_X4_TI12 (TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0) /*!< Quadrature encoder mode 3, x4 mode - Counter counts up/down on both TI1FP1 and TI2FP2 edges depending on the level of the other input */
  565. /**
  566. * @}
  567. */
  568. /** @defgroup TIM_LL_EC_TRGO Trigger Output
  569. * @{
  570. */
  571. #define LL_TIM_TRGO_RESET 0x00000000U /*!< UG bit from the TIMx_EGR register is used as trigger output */
  572. #define LL_TIM_TRGO_ENABLE TIM_CR2_MMS_0 /*!< Counter Enable signal (CNT_EN) is used as trigger output */
  573. #define LL_TIM_TRGO_UPDATE TIM_CR2_MMS_1 /*!< Update event is used as trigger output */
  574. #define LL_TIM_TRGO_CC1IF (TIM_CR2_MMS_1 | TIM_CR2_MMS_0) /*!< CC1 capture or a compare match is used as trigger output */
  575. #define LL_TIM_TRGO_OC1REF TIM_CR2_MMS_2 /*!< OC1REF signal is used as trigger output */
  576. #define LL_TIM_TRGO_OC2REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_0) /*!< OC2REF signal is used as trigger output */
  577. #define LL_TIM_TRGO_OC3REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_1) /*!< OC3REF signal is used as trigger output */
  578. #define LL_TIM_TRGO_OC4REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_1 | TIM_CR2_MMS_0) /*!< OC4REF signal is used as trigger output */
  579. /**
  580. * @}
  581. */
  582. /** @defgroup TIM_LL_EC_SLAVEMODE Slave Mode
  583. * @{
  584. */
  585. #define LL_TIM_SLAVEMODE_DISABLED 0x00000000U /*!< Slave mode disabled */
  586. #define LL_TIM_SLAVEMODE_RESET TIM_SMCR_SMS_2 /*!< Reset Mode - Rising edge of the selected trigger input (TRGI) reinitializes the counter */
  587. #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 */
  588. #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 */
  589. /**
  590. * @}
  591. */
  592. /** @defgroup TIM_LL_EC_TS Trigger Selection
  593. * @{
  594. */
  595. #define LL_TIM_TS_ITR0 0x00000000U /*!< Internal Trigger 0 (ITR0) is used as trigger input */
  596. #define LL_TIM_TS_ITR1 TIM_SMCR_TS_0 /*!< Internal Trigger 1 (ITR1) is used as trigger input */
  597. #define LL_TIM_TS_ITR2 TIM_SMCR_TS_1 /*!< Internal Trigger 2 (ITR2) is used as trigger input */
  598. #define LL_TIM_TS_ITR3 (TIM_SMCR_TS_0 | TIM_SMCR_TS_1) /*!< Internal Trigger 3 (ITR3) is used as trigger input */
  599. #define LL_TIM_TS_TI1F_ED TIM_SMCR_TS_2 /*!< TI1 Edge Detector (TI1F_ED) is used as trigger input */
  600. #define LL_TIM_TS_TI1FP1 (TIM_SMCR_TS_2 | TIM_SMCR_TS_0) /*!< Filtered Timer Input 1 (TI1FP1) is used as trigger input */
  601. #define LL_TIM_TS_TI2FP2 (TIM_SMCR_TS_2 | TIM_SMCR_TS_1) /*!< Filtered Timer Input 2 (TI12P2) is used as trigger input */
  602. #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 */
  603. /**
  604. * @}
  605. */
  606. /** @defgroup TIM_LL_EC_ETR_POLARITY External Trigger Polarity
  607. * @{
  608. */
  609. #define LL_TIM_ETR_POLARITY_NONINVERTED 0x00000000U /*!< ETR is non-inverted, active at high level or rising edge */
  610. #define LL_TIM_ETR_POLARITY_INVERTED TIM_SMCR_ETP /*!< ETR is inverted, active at low level or falling edge */
  611. /**
  612. * @}
  613. */
  614. /** @defgroup TIM_LL_EC_ETR_PRESCALER External Trigger Prescaler
  615. * @{
  616. */
  617. #define LL_TIM_ETR_PRESCALER_DIV1 0x00000000U /*!< ETR prescaler OFF */
  618. #define LL_TIM_ETR_PRESCALER_DIV2 TIM_SMCR_ETPS_0 /*!< ETR frequency is divided by 2 */
  619. #define LL_TIM_ETR_PRESCALER_DIV4 TIM_SMCR_ETPS_1 /*!< ETR frequency is divided by 4 */
  620. #define LL_TIM_ETR_PRESCALER_DIV8 TIM_SMCR_ETPS /*!< ETR frequency is divided by 8 */
  621. /**
  622. * @}
  623. */
  624. /** @defgroup TIM_LL_EC_ETR_FILTER External Trigger Filter
  625. * @{
  626. */
  627. #define LL_TIM_ETR_FILTER_FDIV1 0x00000000U /*!< No filter, sampling is done at fDTS */
  628. #define LL_TIM_ETR_FILTER_FDIV1_N2 TIM_SMCR_ETF_0 /*!< fSAMPLING=fCK_INT, N=2 */
  629. #define LL_TIM_ETR_FILTER_FDIV1_N4 TIM_SMCR_ETF_1 /*!< fSAMPLING=fCK_INT, N=4 */
  630. #define LL_TIM_ETR_FILTER_FDIV1_N8 (TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fCK_INT, N=8 */
  631. #define LL_TIM_ETR_FILTER_FDIV2_N6 TIM_SMCR_ETF_2 /*!< fSAMPLING=fDTS/2, N=6 */
  632. #define LL_TIM_ETR_FILTER_FDIV2_N8 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/2, N=8 */
  633. #define LL_TIM_ETR_FILTER_FDIV4_N6 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/4, N=6 */
  634. #define LL_TIM_ETR_FILTER_FDIV4_N8 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/4, N=8 */
  635. #define LL_TIM_ETR_FILTER_FDIV8_N6 TIM_SMCR_ETF_3 /*!< fSAMPLING=fDTS/8, N=8 */
  636. #define LL_TIM_ETR_FILTER_FDIV8_N8 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/16, N=5 */
  637. #define LL_TIM_ETR_FILTER_FDIV16_N5 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/16, N=6 */
  638. #define LL_TIM_ETR_FILTER_FDIV16_N6 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/16, N=8 */
  639. #define LL_TIM_ETR_FILTER_FDIV16_N8 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2) /*!< fSAMPLING=fDTS/16, N=5 */
  640. #define LL_TIM_ETR_FILTER_FDIV32_N5 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/32, N=5 */
  641. #define LL_TIM_ETR_FILTER_FDIV32_N6 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/32, N=6 */
  642. #define LL_TIM_ETR_FILTER_FDIV32_N8 TIM_SMCR_ETF /*!< fSAMPLING=fDTS/32, N=8 */
  643. /**
  644. * @}
  645. */
  646. /** @defgroup TIM_LL_EC_BREAK_POLARITY break polarity
  647. * @{
  648. */
  649. #define LL_TIM_BREAK_POLARITY_LOW 0x00000000U /*!< Break input BRK is active low */
  650. #define LL_TIM_BREAK_POLARITY_HIGH TIM_BDTR_BKP /*!< Break input BRK is active high */
  651. /**
  652. * @}
  653. */
  654. /** @defgroup TIM_LL_EC_OSSI OSSI
  655. * @{
  656. */
  657. #define LL_TIM_OSSI_DISABLE 0x00000000U /*!< When inactive, OCx/OCxN outputs are disabled */
  658. #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 */
  659. /**
  660. * @}
  661. */
  662. /** @defgroup TIM_LL_EC_OSSR OSSR
  663. * @{
  664. */
  665. #define LL_TIM_OSSR_DISABLE 0x00000000U /*!< When inactive, OCx/OCxN outputs are disabled */
  666. #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 */
  667. /**
  668. * @}
  669. */
  670. /** @defgroup TIM_LL_EC_DMABURST_BASEADDR DMA Burst Base Address
  671. * @{
  672. */
  673. #define LL_TIM_DMABURST_BASEADDR_CR1 0x00000000U /*!< TIMx_CR1 register is the DMA base address for DMA burst */
  674. #define LL_TIM_DMABURST_BASEADDR_CR2 TIM_DCR_DBA_0 /*!< TIMx_CR2 register is the DMA base address for DMA burst */
  675. #define LL_TIM_DMABURST_BASEADDR_SMCR TIM_DCR_DBA_1 /*!< TIMx_SMCR register is the DMA base address for DMA burst */
  676. #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 */
  677. #define LL_TIM_DMABURST_BASEADDR_SR TIM_DCR_DBA_2 /*!< TIMx_SR register is the DMA base address for DMA burst */
  678. #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 */
  679. #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 */
  680. #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 */
  681. #define LL_TIM_DMABURST_BASEADDR_CCER TIM_DCR_DBA_3 /*!< TIMx_CCER register is the DMA base address for DMA burst */
  682. #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 */
  683. #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 */
  684. #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 */
  685. #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 */
  686. #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 */
  687. #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 */
  688. #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 */
  689. #define LL_TIM_DMABURST_BASEADDR_CCR4 TIM_DCR_DBA_4 /*!< TIMx_CCR4 register is the DMA base address for DMA burst */
  690. #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 */
  691. /**
  692. * @}
  693. */
  694. /** @defgroup TIM_LL_EC_DMABURST_LENGTH DMA Burst Length
  695. * @{
  696. */
  697. #define LL_TIM_DMABURST_LENGTH_1TRANSFER 0x00000000U /*!< Transfer is done to 1 register starting from the DMA burst base address */
  698. #define LL_TIM_DMABURST_LENGTH_2TRANSFERS TIM_DCR_DBL_0 /*!< Transfer is done to 2 registers starting from the DMA burst base address */
  699. #define LL_TIM_DMABURST_LENGTH_3TRANSFERS TIM_DCR_DBL_1 /*!< Transfer is done to 3 registers starting from the DMA burst base address */
  700. #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 */
  701. #define LL_TIM_DMABURST_LENGTH_5TRANSFERS TIM_DCR_DBL_2 /*!< Transfer is done to 5 registers starting from the DMA burst base address */
  702. #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 */
  703. #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 */
  704. #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 */
  705. #define LL_TIM_DMABURST_LENGTH_9TRANSFERS TIM_DCR_DBL_3 /*!< Transfer is done to 9 registers starting from the DMA burst base address */
  706. #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 */
  707. #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 */
  708. #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 */
  709. #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 */
  710. #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 */
  711. #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 */
  712. #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 */
  713. #define LL_TIM_DMABURST_LENGTH_17TRANSFERS TIM_DCR_DBL_4 /*!< Transfer is done to 17 registers starting from the DMA burst base address */
  714. #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 */
  715. /**
  716. * @}
  717. */
  718. /**
  719. * @}
  720. */
  721. /* Exported macro ------------------------------------------------------------*/
  722. /** @defgroup TIM_LL_Exported_Macros TIM Exported Macros
  723. * @{
  724. */
  725. /** @defgroup TIM_LL_EM_WRITE_READ Common Write and read registers Macros
  726. * @{
  727. */
  728. /**
  729. * @brief Write a value in TIM register.
  730. * @param __INSTANCE__ TIM Instance
  731. * @param __REG__ Register to be written
  732. * @param __VALUE__ Value to be written in the register
  733. * @retval None
  734. */
  735. #define LL_TIM_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG((__INSTANCE__)->__REG__, (__VALUE__))
  736. /**
  737. * @brief Read a value in TIM register.
  738. * @param __INSTANCE__ TIM Instance
  739. * @param __REG__ Register to be read
  740. * @retval Register value
  741. */
  742. #define LL_TIM_ReadReg(__INSTANCE__, __REG__) READ_REG((__INSTANCE__)->__REG__)
  743. /**
  744. * @}
  745. */
  746. /** @defgroup TIM_LL_EM_Exported_Macros Exported_Macros
  747. * @{
  748. */
  749. /**
  750. * @brief HELPER macro calculating DTG[0:7] in the TIMx_BDTR register to achieve the requested dead time duration.
  751. * @note ex: @ref __LL_TIM_CALC_DEADTIME (80000000, @ref LL_TIM_GetClockDivision (), 120);
  752. * @param __TIMCLK__ timer input clock frequency (in Hz)
  753. * @param __CKD__ This parameter can be one of the following values:
  754. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  755. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  756. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  757. * @param __DT__ deadtime duration (in ns)
  758. * @retval DTG[0:7]
  759. */
  760. #define __LL_TIM_CALC_DEADTIME(__TIMCLK__, __CKD__, __DT__) \
  761. ( (((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) : \
  762. (((uint64_t)((__DT__)*1000U)) < ((64U + (DT_DELAY_2+1U)) * 2U * TIM_CALC_DTS((__TIMCLK__), (__CKD__)))) ? (uint8_t)(DT_RANGE_2 | ((uint8_t)((uint8_t)((((uint64_t)((__DT__)*1000U))/ TIM_CALC_DTS((__TIMCLK__), (__CKD__))) >> 1U) - (uint8_t) 64) & DT_DELAY_2)) :\
  763. (((uint64_t)((__DT__)*1000U)) < ((32U + (DT_DELAY_3+1U)) * 8U * TIM_CALC_DTS((__TIMCLK__), (__CKD__)))) ? (uint8_t)(DT_RANGE_3 | ((uint8_t)((uint8_t)(((((uint64_t)(__DT__)*1000U))/ TIM_CALC_DTS((__TIMCLK__), (__CKD__))) >> 3U) - (uint8_t) 32) & DT_DELAY_3)) :\
  764. (((uint64_t)((__DT__)*1000U)) < ((32U + (DT_DELAY_4+1U)) * 16U * TIM_CALC_DTS((__TIMCLK__), (__CKD__)))) ? (uint8_t)(DT_RANGE_4 | ((uint8_t)((uint8_t)(((((uint64_t)(__DT__)*1000U))/ TIM_CALC_DTS((__TIMCLK__), (__CKD__))) >> 4U) - (uint8_t) 32) & DT_DELAY_4)) :\
  765. 0U)
  766. /**
  767. * @brief HELPER macro calculating the prescaler value to achieve the required counter clock frequency.
  768. * @note ex: @ref __LL_TIM_CALC_PSC (80000000, 1000000);
  769. * @param __TIMCLK__ timer input clock frequency (in Hz)
  770. * @param __CNTCLK__ counter clock frequency (in Hz)
  771. * @retval Prescaler value (between Min_Data=0 and Max_Data=65535)
  772. */
  773. #define __LL_TIM_CALC_PSC(__TIMCLK__, __CNTCLK__) \
  774. (((__TIMCLK__) >= (__CNTCLK__)) ? (uint32_t)(((__TIMCLK__)/(__CNTCLK__)) - 1U) : 0U)
  775. /**
  776. * @brief HELPER macro calculating the auto-reload value to achieve the required output signal frequency.
  777. * @note ex: @ref __LL_TIM_CALC_ARR (1000000, @ref LL_TIM_GetPrescaler (), 10000);
  778. * @param __TIMCLK__ timer input clock frequency (in Hz)
  779. * @param __PSC__ prescaler
  780. * @param __FREQ__ output signal frequency (in Hz)
  781. * @retval Auto-reload value (between Min_Data=0 and Max_Data=65535)
  782. */
  783. #define __LL_TIM_CALC_ARR(__TIMCLK__, __PSC__, __FREQ__) \
  784. ((((__TIMCLK__)/((__PSC__) + 1U)) >= (__FREQ__)) ? (((__TIMCLK__)/((__FREQ__) * ((__PSC__) + 1U))) - 1U) : 0U)
  785. /**
  786. * @brief HELPER macro calculating the compare value required to achieve the required timer output compare active/inactive delay.
  787. * @note ex: @ref __LL_TIM_CALC_DELAY (1000000, @ref LL_TIM_GetPrescaler (), 10);
  788. * @param __TIMCLK__ timer input clock frequency (in Hz)
  789. * @param __PSC__ prescaler
  790. * @param __DELAY__ timer output compare active/inactive delay (in us)
  791. * @retval Compare value (between Min_Data=0 and Max_Data=65535)
  792. */
  793. #define __LL_TIM_CALC_DELAY(__TIMCLK__, __PSC__, __DELAY__) \
  794. ((uint32_t)(((uint64_t)(__TIMCLK__) * (uint64_t)(__DELAY__)) \
  795. / ((uint64_t)1000000U * (uint64_t)((__PSC__) + 1U))))
  796. /**
  797. * @brief HELPER macro calculating the auto-reload value to achieve the required pulse duration (when the timer operates in one pulse mode).
  798. * @note ex: @ref __LL_TIM_CALC_PULSE (1000000, @ref LL_TIM_GetPrescaler (), 10, 20);
  799. * @param __TIMCLK__ timer input clock frequency (in Hz)
  800. * @param __PSC__ prescaler
  801. * @param __DELAY__ timer output compare active/inactive delay (in us)
  802. * @param __PULSE__ pulse duration (in us)
  803. * @retval Auto-reload value (between Min_Data=0 and Max_Data=65535)
  804. */
  805. #define __LL_TIM_CALC_PULSE(__TIMCLK__, __PSC__, __DELAY__, __PULSE__) \
  806. ((uint32_t)(__LL_TIM_CALC_DELAY((__TIMCLK__), (__PSC__), (__PULSE__)) \
  807. + __LL_TIM_CALC_DELAY((__TIMCLK__), (__PSC__), (__DELAY__))))
  808. /**
  809. * @brief HELPER macro retrieving the ratio of the input capture prescaler
  810. * @note ex: @ref __LL_TIM_GET_ICPSC_RATIO (@ref LL_TIM_IC_GetPrescaler ());
  811. * @param __ICPSC__ This parameter can be one of the following values:
  812. * @arg @ref LL_TIM_ICPSC_DIV1
  813. * @arg @ref LL_TIM_ICPSC_DIV2
  814. * @arg @ref LL_TIM_ICPSC_DIV4
  815. * @arg @ref LL_TIM_ICPSC_DIV8
  816. * @retval Input capture prescaler ratio (1, 2, 4 or 8)
  817. */
  818. #define __LL_TIM_GET_ICPSC_RATIO(__ICPSC__) \
  819. ((uint32_t)(0x01U << (((__ICPSC__) >> 16U) >> TIM_CCMR1_IC1PSC_Pos)))
  820. /**
  821. * @}
  822. */
  823. /**
  824. * @}
  825. */
  826. /* Exported functions --------------------------------------------------------*/
  827. /** @defgroup TIM_LL_Exported_Functions TIM Exported Functions
  828. * @{
  829. */
  830. /** @defgroup TIM_LL_EF_Time_Base Time Base configuration
  831. * @{
  832. */
  833. /**
  834. * @brief Enable timer counter.
  835. * @rmtoll CR1 CEN LL_TIM_EnableCounter
  836. * @param TIMx Timer instance
  837. * @retval None
  838. */
  839. __STATIC_INLINE void LL_TIM_EnableCounter(TIM_TypeDef *TIMx)
  840. {
  841. SET_BIT(TIMx->CR1, TIM_CR1_CEN);
  842. }
  843. /**
  844. * @brief Disable timer counter.
  845. * @rmtoll CR1 CEN LL_TIM_DisableCounter
  846. * @param TIMx Timer instance
  847. * @retval None
  848. */
  849. __STATIC_INLINE void LL_TIM_DisableCounter(TIM_TypeDef *TIMx)
  850. {
  851. CLEAR_BIT(TIMx->CR1, TIM_CR1_CEN);
  852. }
  853. /**
  854. * @brief Indicates whether the timer counter is enabled.
  855. * @rmtoll CR1 CEN LL_TIM_IsEnabledCounter
  856. * @param TIMx Timer instance
  857. * @retval State of bit (1 or 0).
  858. */
  859. __STATIC_INLINE uint32_t LL_TIM_IsEnabledCounter(TIM_TypeDef *TIMx)
  860. {
  861. return ((READ_BIT(TIMx->CR1, TIM_CR1_CEN) == (TIM_CR1_CEN)) ? 1UL : 0UL);
  862. }
  863. /**
  864. * @brief Enable update event generation.
  865. * @rmtoll CR1 UDIS LL_TIM_EnableUpdateEvent
  866. * @param TIMx Timer instance
  867. * @retval None
  868. */
  869. __STATIC_INLINE void LL_TIM_EnableUpdateEvent(TIM_TypeDef *TIMx)
  870. {
  871. CLEAR_BIT(TIMx->CR1, TIM_CR1_UDIS);
  872. }
  873. /**
  874. * @brief Disable update event generation.
  875. * @rmtoll CR1 UDIS LL_TIM_DisableUpdateEvent
  876. * @param TIMx Timer instance
  877. * @retval None
  878. */
  879. __STATIC_INLINE void LL_TIM_DisableUpdateEvent(TIM_TypeDef *TIMx)
  880. {
  881. SET_BIT(TIMx->CR1, TIM_CR1_UDIS);
  882. }
  883. /**
  884. * @brief Indicates whether update event generation is enabled.
  885. * @rmtoll CR1 UDIS LL_TIM_IsEnabledUpdateEvent
  886. * @param TIMx Timer instance
  887. * @retval Inverted state of bit (0 or 1).
  888. */
  889. __STATIC_INLINE uint32_t LL_TIM_IsEnabledUpdateEvent(TIM_TypeDef *TIMx)
  890. {
  891. return ((READ_BIT(TIMx->CR1, TIM_CR1_UDIS) == (uint32_t)RESET) ? 1UL : 0UL);
  892. }
  893. /**
  894. * @brief Set update event source
  895. * @note Update event source set to LL_TIM_UPDATESOURCE_REGULAR: any of the following events
  896. * generate an update interrupt or DMA request if enabled:
  897. * - Counter overflow/underflow
  898. * - Setting the UG bit
  899. * - Update generation through the slave mode controller
  900. * @note Update event source set to LL_TIM_UPDATESOURCE_COUNTER: only counter
  901. * overflow/underflow generates an update interrupt or DMA request if enabled.
  902. * @rmtoll CR1 URS LL_TIM_SetUpdateSource
  903. * @param TIMx Timer instance
  904. * @param UpdateSource This parameter can be one of the following values:
  905. * @arg @ref LL_TIM_UPDATESOURCE_REGULAR
  906. * @arg @ref LL_TIM_UPDATESOURCE_COUNTER
  907. * @retval None
  908. */
  909. __STATIC_INLINE void LL_TIM_SetUpdateSource(TIM_TypeDef *TIMx, uint32_t UpdateSource)
  910. {
  911. MODIFY_REG(TIMx->CR1, TIM_CR1_URS, UpdateSource);
  912. }
  913. /**
  914. * @brief Get actual event update source
  915. * @rmtoll CR1 URS LL_TIM_GetUpdateSource
  916. * @param TIMx Timer instance
  917. * @retval Returned value can be one of the following values:
  918. * @arg @ref LL_TIM_UPDATESOURCE_REGULAR
  919. * @arg @ref LL_TIM_UPDATESOURCE_COUNTER
  920. */
  921. __STATIC_INLINE uint32_t LL_TIM_GetUpdateSource(TIM_TypeDef *TIMx)
  922. {
  923. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_URS));
  924. }
  925. /**
  926. * @brief Set one pulse mode (one shot v.s. repetitive).
  927. * @rmtoll CR1 OPM LL_TIM_SetOnePulseMode
  928. * @param TIMx Timer instance
  929. * @param OnePulseMode This parameter can be one of the following values:
  930. * @arg @ref LL_TIM_ONEPULSEMODE_SINGLE
  931. * @arg @ref LL_TIM_ONEPULSEMODE_REPETITIVE
  932. * @retval None
  933. */
  934. __STATIC_INLINE void LL_TIM_SetOnePulseMode(TIM_TypeDef *TIMx, uint32_t OnePulseMode)
  935. {
  936. MODIFY_REG(TIMx->CR1, TIM_CR1_OPM, OnePulseMode);
  937. }
  938. /**
  939. * @brief Get actual one pulse mode.
  940. * @rmtoll CR1 OPM LL_TIM_GetOnePulseMode
  941. * @param TIMx Timer instance
  942. * @retval Returned value can be one of the following values:
  943. * @arg @ref LL_TIM_ONEPULSEMODE_SINGLE
  944. * @arg @ref LL_TIM_ONEPULSEMODE_REPETITIVE
  945. */
  946. __STATIC_INLINE uint32_t LL_TIM_GetOnePulseMode(TIM_TypeDef *TIMx)
  947. {
  948. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_OPM));
  949. }
  950. /**
  951. * @brief Set the timer counter counting mode.
  952. * @note Macro IS_TIM_COUNTER_MODE_SELECT_INSTANCE(TIMx) can be used to
  953. * check whether or not the counter mode selection feature is supported
  954. * by a timer instance.
  955. * @note Switching from Center Aligned counter mode to Edge counter mode (or reverse)
  956. * requires a timer reset to avoid unexpected direction
  957. * due to DIR bit readonly in center aligned mode.
  958. * @rmtoll CR1 DIR LL_TIM_SetCounterMode\n
  959. * CR1 CMS LL_TIM_SetCounterMode
  960. * @param TIMx Timer instance
  961. * @param CounterMode This parameter can be one of the following values:
  962. * @arg @ref LL_TIM_COUNTERMODE_UP
  963. * @arg @ref LL_TIM_COUNTERMODE_DOWN
  964. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP
  965. * @arg @ref LL_TIM_COUNTERMODE_CENTER_DOWN
  966. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP_DOWN
  967. * @retval None
  968. */
  969. __STATIC_INLINE void LL_TIM_SetCounterMode(TIM_TypeDef *TIMx, uint32_t CounterMode)
  970. {
  971. MODIFY_REG(TIMx->CR1, (TIM_CR1_DIR | TIM_CR1_CMS), CounterMode);
  972. }
  973. /**
  974. * @brief Get actual counter mode.
  975. * @note Macro IS_TIM_COUNTER_MODE_SELECT_INSTANCE(TIMx) can be used to
  976. * check whether or not the counter mode selection feature is supported
  977. * by a timer instance.
  978. * @rmtoll CR1 DIR LL_TIM_GetCounterMode\n
  979. * CR1 CMS LL_TIM_GetCounterMode
  980. * @param TIMx Timer instance
  981. * @retval Returned value can be one of the following values:
  982. * @arg @ref LL_TIM_COUNTERMODE_UP
  983. * @arg @ref LL_TIM_COUNTERMODE_DOWN
  984. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP
  985. * @arg @ref LL_TIM_COUNTERMODE_CENTER_DOWN
  986. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP_DOWN
  987. */
  988. __STATIC_INLINE uint32_t LL_TIM_GetCounterMode(TIM_TypeDef *TIMx)
  989. {
  990. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_DIR | TIM_CR1_CMS));
  991. }
  992. /**
  993. * @brief Enable auto-reload (ARR) preload.
  994. * @rmtoll CR1 ARPE LL_TIM_EnableARRPreload
  995. * @param TIMx Timer instance
  996. * @retval None
  997. */
  998. __STATIC_INLINE void LL_TIM_EnableARRPreload(TIM_TypeDef *TIMx)
  999. {
  1000. SET_BIT(TIMx->CR1, TIM_CR1_ARPE);
  1001. }
  1002. /**
  1003. * @brief Disable auto-reload (ARR) preload.
  1004. * @rmtoll CR1 ARPE LL_TIM_DisableARRPreload
  1005. * @param TIMx Timer instance
  1006. * @retval None
  1007. */
  1008. __STATIC_INLINE void LL_TIM_DisableARRPreload(TIM_TypeDef *TIMx)
  1009. {
  1010. CLEAR_BIT(TIMx->CR1, TIM_CR1_ARPE);
  1011. }
  1012. /**
  1013. * @brief Indicates whether auto-reload (ARR) preload is enabled.
  1014. * @rmtoll CR1 ARPE LL_TIM_IsEnabledARRPreload
  1015. * @param TIMx Timer instance
  1016. * @retval State of bit (1 or 0).
  1017. */
  1018. __STATIC_INLINE uint32_t LL_TIM_IsEnabledARRPreload(TIM_TypeDef *TIMx)
  1019. {
  1020. return ((READ_BIT(TIMx->CR1, TIM_CR1_ARPE) == (TIM_CR1_ARPE)) ? 1UL : 0UL);
  1021. }
  1022. /**
  1023. * @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.
  1024. * @note Macro IS_TIM_CLOCK_DIVISION_INSTANCE(TIMx) can be used to check
  1025. * whether or not the clock division feature is supported by the timer
  1026. * instance.
  1027. * @rmtoll CR1 CKD LL_TIM_SetClockDivision
  1028. * @param TIMx Timer instance
  1029. * @param ClockDivision This parameter can be one of the following values:
  1030. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  1031. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  1032. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  1033. * @retval None
  1034. */
  1035. __STATIC_INLINE void LL_TIM_SetClockDivision(TIM_TypeDef *TIMx, uint32_t ClockDivision)
  1036. {
  1037. MODIFY_REG(TIMx->CR1, TIM_CR1_CKD, ClockDivision);
  1038. }
  1039. /**
  1040. * @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.
  1041. * @note Macro IS_TIM_CLOCK_DIVISION_INSTANCE(TIMx) can be used to check
  1042. * whether or not the clock division feature is supported by the timer
  1043. * instance.
  1044. * @rmtoll CR1 CKD LL_TIM_GetClockDivision
  1045. * @param TIMx Timer instance
  1046. * @retval Returned value can be one of the following values:
  1047. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  1048. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  1049. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  1050. */
  1051. __STATIC_INLINE uint32_t LL_TIM_GetClockDivision(TIM_TypeDef *TIMx)
  1052. {
  1053. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_CKD));
  1054. }
  1055. /**
  1056. * @brief Set the counter value.
  1057. * @rmtoll CNT CNT LL_TIM_SetCounter
  1058. * @param TIMx Timer instance
  1059. * @param Counter Counter value (between Min_Data=0 and Max_Data=0xFFFF)
  1060. * @retval None
  1061. */
  1062. __STATIC_INLINE void LL_TIM_SetCounter(TIM_TypeDef *TIMx, uint32_t Counter)
  1063. {
  1064. WRITE_REG(TIMx->CNT, Counter);
  1065. }
  1066. /**
  1067. * @brief Get the counter value.
  1068. * @rmtoll CNT CNT LL_TIM_GetCounter
  1069. * @param TIMx Timer instance
  1070. * @retval Counter value (between Min_Data=0 and Max_Data=0xFFFF)
  1071. */
  1072. __STATIC_INLINE uint32_t LL_TIM_GetCounter(TIM_TypeDef *TIMx)
  1073. {
  1074. return (uint32_t)(READ_REG(TIMx->CNT));
  1075. }
  1076. /**
  1077. * @brief Get the current direction of the counter
  1078. * @rmtoll CR1 DIR LL_TIM_GetDirection
  1079. * @param TIMx Timer instance
  1080. * @retval Returned value can be one of the following values:
  1081. * @arg @ref LL_TIM_COUNTERDIRECTION_UP
  1082. * @arg @ref LL_TIM_COUNTERDIRECTION_DOWN
  1083. */
  1084. __STATIC_INLINE uint32_t LL_TIM_GetDirection(TIM_TypeDef *TIMx)
  1085. {
  1086. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_DIR));
  1087. }
  1088. /**
  1089. * @brief Set the prescaler value.
  1090. * @note The counter clock frequency CK_CNT is equal to fCK_PSC / (PSC[15:0] + 1).
  1091. * @note The prescaler can be changed on the fly as this control register is buffered. The new
  1092. * prescaler ratio is taken into account at the next update event.
  1093. * @note Helper macro @ref __LL_TIM_CALC_PSC can be used to calculate the Prescaler parameter
  1094. * @rmtoll PSC PSC LL_TIM_SetPrescaler
  1095. * @param TIMx Timer instance
  1096. * @param Prescaler between Min_Data=0 and Max_Data=65535
  1097. * @retval None
  1098. */
  1099. __STATIC_INLINE void LL_TIM_SetPrescaler(TIM_TypeDef *TIMx, uint32_t Prescaler)
  1100. {
  1101. WRITE_REG(TIMx->PSC, Prescaler);
  1102. }
  1103. /**
  1104. * @brief Get the prescaler value.
  1105. * @rmtoll PSC PSC LL_TIM_GetPrescaler
  1106. * @param TIMx Timer instance
  1107. * @retval Prescaler value between Min_Data=0 and Max_Data=65535
  1108. */
  1109. __STATIC_INLINE uint32_t LL_TIM_GetPrescaler(TIM_TypeDef *TIMx)
  1110. {
  1111. return (uint32_t)(READ_REG(TIMx->PSC));
  1112. }
  1113. /**
  1114. * @brief Set the auto-reload value.
  1115. * @note The counter is blocked while the auto-reload value is null.
  1116. * @note Helper macro @ref __LL_TIM_CALC_ARR can be used to calculate the AutoReload parameter
  1117. * @rmtoll ARR ARR LL_TIM_SetAutoReload
  1118. * @param TIMx Timer instance
  1119. * @param AutoReload between Min_Data=0 and Max_Data=65535
  1120. * @retval None
  1121. */
  1122. __STATIC_INLINE void LL_TIM_SetAutoReload(TIM_TypeDef *TIMx, uint32_t AutoReload)
  1123. {
  1124. WRITE_REG(TIMx->ARR, AutoReload);
  1125. }
  1126. /**
  1127. * @brief Get the auto-reload value.
  1128. * @rmtoll ARR ARR LL_TIM_GetAutoReload
  1129. * @param TIMx Timer instance
  1130. * @retval Auto-reload value
  1131. */
  1132. __STATIC_INLINE uint32_t LL_TIM_GetAutoReload(TIM_TypeDef *TIMx)
  1133. {
  1134. return (uint32_t)(READ_REG(TIMx->ARR));
  1135. }
  1136. /**
  1137. * @brief Set the repetition counter value.
  1138. * @note Macro IS_TIM_REPETITION_COUNTER_INSTANCE(TIMx) can be used to check
  1139. * whether or not a timer instance supports a repetition counter.
  1140. * @rmtoll RCR REP LL_TIM_SetRepetitionCounter
  1141. * @param TIMx Timer instance
  1142. * @param RepetitionCounter between Min_Data=0 and Max_Data=255 or 65535 for advanced timer.
  1143. * @retval None
  1144. */
  1145. __STATIC_INLINE void LL_TIM_SetRepetitionCounter(TIM_TypeDef *TIMx, uint32_t RepetitionCounter)
  1146. {
  1147. WRITE_REG(TIMx->RCR, RepetitionCounter);
  1148. }
  1149. /**
  1150. * @brief Get the repetition counter value.
  1151. * @note Macro IS_TIM_REPETITION_COUNTER_INSTANCE(TIMx) can be used to check
  1152. * whether or not a timer instance supports a repetition counter.
  1153. * @rmtoll RCR REP LL_TIM_GetRepetitionCounter
  1154. * @param TIMx Timer instance
  1155. * @retval Repetition counter value
  1156. */
  1157. __STATIC_INLINE uint32_t LL_TIM_GetRepetitionCounter(TIM_TypeDef *TIMx)
  1158. {
  1159. return (uint32_t)(READ_REG(TIMx->RCR));
  1160. }
  1161. /**
  1162. * @}
  1163. */
  1164. /** @defgroup TIM_LL_EF_Capture_Compare Capture Compare configuration
  1165. * @{
  1166. */
  1167. /**
  1168. * @brief Enable the capture/compare control bits (CCxE, CCxNE and OCxM) preload.
  1169. * @note CCxE, CCxNE and OCxM bits are preloaded, after having been written,
  1170. * they are updated only when a commutation event (COM) occurs.
  1171. * @note Only on channels that have a complementary output.
  1172. * @note Macro IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
  1173. * whether or not a timer instance is able to generate a commutation event.
  1174. * @rmtoll CR2 CCPC LL_TIM_CC_EnablePreload
  1175. * @param TIMx Timer instance
  1176. * @retval None
  1177. */
  1178. __STATIC_INLINE void LL_TIM_CC_EnablePreload(TIM_TypeDef *TIMx)
  1179. {
  1180. SET_BIT(TIMx->CR2, TIM_CR2_CCPC);
  1181. }
  1182. /**
  1183. * @brief Disable the capture/compare control bits (CCxE, CCxNE and OCxM) preload.
  1184. * @note Macro IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
  1185. * whether or not a timer instance is able to generate a commutation event.
  1186. * @rmtoll CR2 CCPC LL_TIM_CC_DisablePreload
  1187. * @param TIMx Timer instance
  1188. * @retval None
  1189. */
  1190. __STATIC_INLINE void LL_TIM_CC_DisablePreload(TIM_TypeDef *TIMx)
  1191. {
  1192. CLEAR_BIT(TIMx->CR2, TIM_CR2_CCPC);
  1193. }
  1194. /**
  1195. * @brief Set the updated source of the capture/compare control bits (CCxE, CCxNE and OCxM).
  1196. * @note Macro IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
  1197. * whether or not a timer instance is able to generate a commutation event.
  1198. * @rmtoll CR2 CCUS LL_TIM_CC_SetUpdate
  1199. * @param TIMx Timer instance
  1200. * @param CCUpdateSource This parameter can be one of the following values:
  1201. * @arg @ref LL_TIM_CCUPDATESOURCE_COMG_ONLY
  1202. * @arg @ref LL_TIM_CCUPDATESOURCE_COMG_AND_TRGI
  1203. * @retval None
  1204. */
  1205. __STATIC_INLINE void LL_TIM_CC_SetUpdate(TIM_TypeDef *TIMx, uint32_t CCUpdateSource)
  1206. {
  1207. MODIFY_REG(TIMx->CR2, TIM_CR2_CCUS, CCUpdateSource);
  1208. }
  1209. /**
  1210. * @brief Set the trigger of the capture/compare DMA request.
  1211. * @rmtoll CR2 CCDS LL_TIM_CC_SetDMAReqTrigger
  1212. * @param TIMx Timer instance
  1213. * @param DMAReqTrigger This parameter can be one of the following values:
  1214. * @arg @ref LL_TIM_CCDMAREQUEST_CC
  1215. * @arg @ref LL_TIM_CCDMAREQUEST_UPDATE
  1216. * @retval None
  1217. */
  1218. __STATIC_INLINE void LL_TIM_CC_SetDMAReqTrigger(TIM_TypeDef *TIMx, uint32_t DMAReqTrigger)
  1219. {
  1220. MODIFY_REG(TIMx->CR2, TIM_CR2_CCDS, DMAReqTrigger);
  1221. }
  1222. /**
  1223. * @brief Get actual trigger of the capture/compare DMA request.
  1224. * @rmtoll CR2 CCDS LL_TIM_CC_GetDMAReqTrigger
  1225. * @param TIMx Timer instance
  1226. * @retval Returned value can be one of the following values:
  1227. * @arg @ref LL_TIM_CCDMAREQUEST_CC
  1228. * @arg @ref LL_TIM_CCDMAREQUEST_UPDATE
  1229. */
  1230. __STATIC_INLINE uint32_t LL_TIM_CC_GetDMAReqTrigger(TIM_TypeDef *TIMx)
  1231. {
  1232. return (uint32_t)(READ_BIT(TIMx->CR2, TIM_CR2_CCDS));
  1233. }
  1234. /**
  1235. * @brief Set the lock level to freeze the
  1236. * configuration of several capture/compare parameters.
  1237. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  1238. * the lock mechanism is supported by a timer instance.
  1239. * @rmtoll BDTR LOCK LL_TIM_CC_SetLockLevel
  1240. * @param TIMx Timer instance
  1241. * @param LockLevel This parameter can be one of the following values:
  1242. * @arg @ref LL_TIM_LOCKLEVEL_OFF
  1243. * @arg @ref LL_TIM_LOCKLEVEL_1
  1244. * @arg @ref LL_TIM_LOCKLEVEL_2
  1245. * @arg @ref LL_TIM_LOCKLEVEL_3
  1246. * @retval None
  1247. */
  1248. __STATIC_INLINE void LL_TIM_CC_SetLockLevel(TIM_TypeDef *TIMx, uint32_t LockLevel)
  1249. {
  1250. MODIFY_REG(TIMx->BDTR, TIM_BDTR_LOCK, LockLevel);
  1251. }
  1252. /**
  1253. * @brief Enable capture/compare channels.
  1254. * @rmtoll CCER CC1E LL_TIM_CC_EnableChannel\n
  1255. * CCER CC1NE LL_TIM_CC_EnableChannel\n
  1256. * CCER CC2E LL_TIM_CC_EnableChannel\n
  1257. * CCER CC2NE LL_TIM_CC_EnableChannel\n
  1258. * CCER CC3E LL_TIM_CC_EnableChannel\n
  1259. * CCER CC3NE LL_TIM_CC_EnableChannel\n
  1260. * CCER CC4E LL_TIM_CC_EnableChannel
  1261. * @param TIMx Timer instance
  1262. * @param Channels This parameter can be a combination of the following values:
  1263. * @arg @ref LL_TIM_CHANNEL_CH1
  1264. * @arg @ref LL_TIM_CHANNEL_CH1N
  1265. * @arg @ref LL_TIM_CHANNEL_CH2
  1266. * @arg @ref LL_TIM_CHANNEL_CH2N
  1267. * @arg @ref LL_TIM_CHANNEL_CH3
  1268. * @arg @ref LL_TIM_CHANNEL_CH3N
  1269. * @arg @ref LL_TIM_CHANNEL_CH4
  1270. * @retval None
  1271. */
  1272. __STATIC_INLINE void LL_TIM_CC_EnableChannel(TIM_TypeDef *TIMx, uint32_t Channels)
  1273. {
  1274. SET_BIT(TIMx->CCER, Channels);
  1275. }
  1276. /**
  1277. * @brief Disable capture/compare channels.
  1278. * @rmtoll CCER CC1E LL_TIM_CC_DisableChannel\n
  1279. * CCER CC1NE LL_TIM_CC_DisableChannel\n
  1280. * CCER CC2E LL_TIM_CC_DisableChannel\n
  1281. * CCER CC2NE LL_TIM_CC_DisableChannel\n
  1282. * CCER CC3E LL_TIM_CC_DisableChannel\n
  1283. * CCER CC3NE LL_TIM_CC_DisableChannel\n
  1284. * CCER CC4E LL_TIM_CC_DisableChannel
  1285. * @param TIMx Timer instance
  1286. * @param Channels This parameter can be a combination of the following values:
  1287. * @arg @ref LL_TIM_CHANNEL_CH1
  1288. * @arg @ref LL_TIM_CHANNEL_CH1N
  1289. * @arg @ref LL_TIM_CHANNEL_CH2
  1290. * @arg @ref LL_TIM_CHANNEL_CH2N
  1291. * @arg @ref LL_TIM_CHANNEL_CH3
  1292. * @arg @ref LL_TIM_CHANNEL_CH3N
  1293. * @arg @ref LL_TIM_CHANNEL_CH4
  1294. * @retval None
  1295. */
  1296. __STATIC_INLINE void LL_TIM_CC_DisableChannel(TIM_TypeDef *TIMx, uint32_t Channels)
  1297. {
  1298. CLEAR_BIT(TIMx->CCER, Channels);
  1299. }
  1300. /**
  1301. * @brief Indicate whether channel(s) is(are) enabled.
  1302. * @rmtoll CCER CC1E LL_TIM_CC_IsEnabledChannel\n
  1303. * CCER CC1NE LL_TIM_CC_IsEnabledChannel\n
  1304. * CCER CC2E LL_TIM_CC_IsEnabledChannel\n
  1305. * CCER CC2NE LL_TIM_CC_IsEnabledChannel\n
  1306. * CCER CC3E LL_TIM_CC_IsEnabledChannel\n
  1307. * CCER CC3NE LL_TIM_CC_IsEnabledChannel\n
  1308. * CCER CC4E LL_TIM_CC_IsEnabledChannel
  1309. * @param TIMx Timer instance
  1310. * @param Channels This parameter can be a combination of the following values:
  1311. * @arg @ref LL_TIM_CHANNEL_CH1
  1312. * @arg @ref LL_TIM_CHANNEL_CH1N
  1313. * @arg @ref LL_TIM_CHANNEL_CH2
  1314. * @arg @ref LL_TIM_CHANNEL_CH2N
  1315. * @arg @ref LL_TIM_CHANNEL_CH3
  1316. * @arg @ref LL_TIM_CHANNEL_CH3N
  1317. * @arg @ref LL_TIM_CHANNEL_CH4
  1318. * @retval State of bit (1 or 0).
  1319. */
  1320. __STATIC_INLINE uint32_t LL_TIM_CC_IsEnabledChannel(TIM_TypeDef *TIMx, uint32_t Channels)
  1321. {
  1322. return ((READ_BIT(TIMx->CCER, Channels) == (Channels)) ? 1UL : 0UL);
  1323. }
  1324. /**
  1325. * @}
  1326. */
  1327. /** @defgroup TIM_LL_EF_Output_Channel Output channel configuration
  1328. * @{
  1329. */
  1330. /**
  1331. * @brief Configure an output channel.
  1332. * @rmtoll CCMR1 CC1S LL_TIM_OC_ConfigOutput\n
  1333. * CCMR1 CC2S LL_TIM_OC_ConfigOutput\n
  1334. * CCMR2 CC3S LL_TIM_OC_ConfigOutput\n
  1335. * CCMR2 CC4S LL_TIM_OC_ConfigOutput\n
  1336. * CCER CC1P LL_TIM_OC_ConfigOutput\n
  1337. * CCER CC2P LL_TIM_OC_ConfigOutput\n
  1338. * CCER CC3P LL_TIM_OC_ConfigOutput\n
  1339. * CCER CC4P LL_TIM_OC_ConfigOutput\n
  1340. * CR2 OIS1 LL_TIM_OC_ConfigOutput\n
  1341. * CR2 OIS2 LL_TIM_OC_ConfigOutput\n
  1342. * CR2 OIS3 LL_TIM_OC_ConfigOutput\n
  1343. * CR2 OIS4 LL_TIM_OC_ConfigOutput
  1344. * @param TIMx Timer instance
  1345. * @param Channel This parameter can be one of the following values:
  1346. * @arg @ref LL_TIM_CHANNEL_CH1
  1347. * @arg @ref LL_TIM_CHANNEL_CH2
  1348. * @arg @ref LL_TIM_CHANNEL_CH3
  1349. * @arg @ref LL_TIM_CHANNEL_CH4
  1350. * @param Configuration This parameter must be a combination of all the following values:
  1351. * @arg @ref LL_TIM_OCPOLARITY_HIGH or @ref LL_TIM_OCPOLARITY_LOW
  1352. * @arg @ref LL_TIM_OCIDLESTATE_LOW or @ref LL_TIM_OCIDLESTATE_HIGH
  1353. * @retval None
  1354. */
  1355. __STATIC_INLINE void LL_TIM_OC_ConfigOutput(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Configuration)
  1356. {
  1357. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1358. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1359. CLEAR_BIT(*pReg, (TIM_CCMR1_CC1S << SHIFT_TAB_OCxx[iChannel]));
  1360. MODIFY_REG(TIMx->CCER, (TIM_CCER_CC1P << SHIFT_TAB_CCxP[iChannel]),
  1361. (Configuration & TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel]);
  1362. MODIFY_REG(TIMx->CR2, (TIM_CR2_OIS1 << SHIFT_TAB_OISx[iChannel]),
  1363. (Configuration & TIM_CR2_OIS1) << SHIFT_TAB_OISx[iChannel]);
  1364. }
  1365. /**
  1366. * @brief Define the behavior of the output reference signal OCxREF from which
  1367. * OCx and OCxN (when relevant) are derived.
  1368. * @rmtoll CCMR1 OC1M LL_TIM_OC_SetMode\n
  1369. * CCMR1 OC2M LL_TIM_OC_SetMode\n
  1370. * CCMR2 OC3M LL_TIM_OC_SetMode\n
  1371. * CCMR2 OC4M LL_TIM_OC_SetMode
  1372. * @param TIMx Timer instance
  1373. * @param Channel This parameter can be one of the following values:
  1374. * @arg @ref LL_TIM_CHANNEL_CH1
  1375. * @arg @ref LL_TIM_CHANNEL_CH2
  1376. * @arg @ref LL_TIM_CHANNEL_CH3
  1377. * @arg @ref LL_TIM_CHANNEL_CH4
  1378. * @param Mode This parameter can be one of the following values:
  1379. * @arg @ref LL_TIM_OCMODE_FROZEN
  1380. * @arg @ref LL_TIM_OCMODE_ACTIVE
  1381. * @arg @ref LL_TIM_OCMODE_INACTIVE
  1382. * @arg @ref LL_TIM_OCMODE_TOGGLE
  1383. * @arg @ref LL_TIM_OCMODE_FORCED_INACTIVE
  1384. * @arg @ref LL_TIM_OCMODE_FORCED_ACTIVE
  1385. * @arg @ref LL_TIM_OCMODE_PWM1
  1386. * @arg @ref LL_TIM_OCMODE_PWM2
  1387. * @retval None
  1388. */
  1389. __STATIC_INLINE void LL_TIM_OC_SetMode(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Mode)
  1390. {
  1391. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1392. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1393. MODIFY_REG(*pReg, ((TIM_CCMR1_OC1M | TIM_CCMR1_CC1S) << SHIFT_TAB_OCxx[iChannel]), Mode << SHIFT_TAB_OCxx[iChannel]);
  1394. }
  1395. /**
  1396. * @brief Get the output compare mode of an output channel.
  1397. * @rmtoll CCMR1 OC1M LL_TIM_OC_GetMode\n
  1398. * CCMR1 OC2M LL_TIM_OC_GetMode\n
  1399. * CCMR2 OC3M LL_TIM_OC_GetMode\n
  1400. * CCMR2 OC4M LL_TIM_OC_GetMode
  1401. * @param TIMx Timer instance
  1402. * @param Channel This parameter can be one of the following values:
  1403. * @arg @ref LL_TIM_CHANNEL_CH1
  1404. * @arg @ref LL_TIM_CHANNEL_CH2
  1405. * @arg @ref LL_TIM_CHANNEL_CH3
  1406. * @arg @ref LL_TIM_CHANNEL_CH4
  1407. * @retval Returned value can be one of the following values:
  1408. * @arg @ref LL_TIM_OCMODE_FROZEN
  1409. * @arg @ref LL_TIM_OCMODE_ACTIVE
  1410. * @arg @ref LL_TIM_OCMODE_INACTIVE
  1411. * @arg @ref LL_TIM_OCMODE_TOGGLE
  1412. * @arg @ref LL_TIM_OCMODE_FORCED_INACTIVE
  1413. * @arg @ref LL_TIM_OCMODE_FORCED_ACTIVE
  1414. * @arg @ref LL_TIM_OCMODE_PWM1
  1415. * @arg @ref LL_TIM_OCMODE_PWM2
  1416. */
  1417. __STATIC_INLINE uint32_t LL_TIM_OC_GetMode(TIM_TypeDef *TIMx, uint32_t Channel)
  1418. {
  1419. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1420. const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1421. return (READ_BIT(*pReg, ((TIM_CCMR1_OC1M | TIM_CCMR1_CC1S) << SHIFT_TAB_OCxx[iChannel])) >> SHIFT_TAB_OCxx[iChannel]);
  1422. }
  1423. /**
  1424. * @brief Set the polarity of an output channel.
  1425. * @rmtoll CCER CC1P LL_TIM_OC_SetPolarity\n
  1426. * CCER CC1NP LL_TIM_OC_SetPolarity\n
  1427. * CCER CC2P LL_TIM_OC_SetPolarity\n
  1428. * CCER CC2NP LL_TIM_OC_SetPolarity\n
  1429. * CCER CC3P LL_TIM_OC_SetPolarity\n
  1430. * CCER CC3NP LL_TIM_OC_SetPolarity\n
  1431. * CCER CC4P LL_TIM_OC_SetPolarity
  1432. * @param TIMx Timer instance
  1433. * @param Channel This parameter can be one of the following values:
  1434. * @arg @ref LL_TIM_CHANNEL_CH1
  1435. * @arg @ref LL_TIM_CHANNEL_CH1N
  1436. * @arg @ref LL_TIM_CHANNEL_CH2
  1437. * @arg @ref LL_TIM_CHANNEL_CH2N
  1438. * @arg @ref LL_TIM_CHANNEL_CH3
  1439. * @arg @ref LL_TIM_CHANNEL_CH3N
  1440. * @arg @ref LL_TIM_CHANNEL_CH4
  1441. * @param Polarity This parameter can be one of the following values:
  1442. * @arg @ref LL_TIM_OCPOLARITY_HIGH
  1443. * @arg @ref LL_TIM_OCPOLARITY_LOW
  1444. * @retval None
  1445. */
  1446. __STATIC_INLINE void LL_TIM_OC_SetPolarity(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Polarity)
  1447. {
  1448. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1449. MODIFY_REG(TIMx->CCER, (TIM_CCER_CC1P << SHIFT_TAB_CCxP[iChannel]), Polarity << SHIFT_TAB_CCxP[iChannel]);
  1450. }
  1451. /**
  1452. * @brief Get the polarity of an output channel.
  1453. * @rmtoll CCER CC1P LL_TIM_OC_GetPolarity\n
  1454. * CCER CC1NP LL_TIM_OC_GetPolarity\n
  1455. * CCER CC2P LL_TIM_OC_GetPolarity\n
  1456. * CCER CC2NP LL_TIM_OC_GetPolarity\n
  1457. * CCER CC3P LL_TIM_OC_GetPolarity\n
  1458. * CCER CC3NP LL_TIM_OC_GetPolarity\n
  1459. * CCER CC4P LL_TIM_OC_GetPolarity
  1460. * @param TIMx Timer instance
  1461. * @param Channel This parameter can be one of the following values:
  1462. * @arg @ref LL_TIM_CHANNEL_CH1
  1463. * @arg @ref LL_TIM_CHANNEL_CH1N
  1464. * @arg @ref LL_TIM_CHANNEL_CH2
  1465. * @arg @ref LL_TIM_CHANNEL_CH2N
  1466. * @arg @ref LL_TIM_CHANNEL_CH3
  1467. * @arg @ref LL_TIM_CHANNEL_CH3N
  1468. * @arg @ref LL_TIM_CHANNEL_CH4
  1469. * @retval Returned value can be one of the following values:
  1470. * @arg @ref LL_TIM_OCPOLARITY_HIGH
  1471. * @arg @ref LL_TIM_OCPOLARITY_LOW
  1472. */
  1473. __STATIC_INLINE uint32_t LL_TIM_OC_GetPolarity(TIM_TypeDef *TIMx, uint32_t Channel)
  1474. {
  1475. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1476. return (READ_BIT(TIMx->CCER, (TIM_CCER_CC1P << SHIFT_TAB_CCxP[iChannel])) >> SHIFT_TAB_CCxP[iChannel]);
  1477. }
  1478. /**
  1479. * @brief Set the IDLE state of an output channel
  1480. * @note This function is significant only for the timer instances
  1481. * supporting the break feature. Macro IS_TIM_BREAK_INSTANCE(TIMx)
  1482. * can be used to check whether or not a timer instance provides
  1483. * a break input.
  1484. * @rmtoll CR2 OIS1 LL_TIM_OC_SetIdleState\n
  1485. * CR2 OIS1N LL_TIM_OC_SetIdleState\n
  1486. * CR2 OIS2 LL_TIM_OC_SetIdleState\n
  1487. * CR2 OIS2N LL_TIM_OC_SetIdleState\n
  1488. * CR2 OIS3 LL_TIM_OC_SetIdleState\n
  1489. * CR2 OIS3N LL_TIM_OC_SetIdleState\n
  1490. * CR2 OIS4 LL_TIM_OC_SetIdleState
  1491. * @param TIMx Timer instance
  1492. * @param Channel This parameter can be one of the following values:
  1493. * @arg @ref LL_TIM_CHANNEL_CH1
  1494. * @arg @ref LL_TIM_CHANNEL_CH1N
  1495. * @arg @ref LL_TIM_CHANNEL_CH2
  1496. * @arg @ref LL_TIM_CHANNEL_CH2N
  1497. * @arg @ref LL_TIM_CHANNEL_CH3
  1498. * @arg @ref LL_TIM_CHANNEL_CH3N
  1499. * @arg @ref LL_TIM_CHANNEL_CH4
  1500. * @param IdleState This parameter can be one of the following values:
  1501. * @arg @ref LL_TIM_OCIDLESTATE_LOW
  1502. * @arg @ref LL_TIM_OCIDLESTATE_HIGH
  1503. * @retval None
  1504. */
  1505. __STATIC_INLINE void LL_TIM_OC_SetIdleState(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t IdleState)
  1506. {
  1507. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1508. MODIFY_REG(TIMx->CR2, (TIM_CR2_OIS1 << SHIFT_TAB_OISx[iChannel]), IdleState << SHIFT_TAB_OISx[iChannel]);
  1509. }
  1510. /**
  1511. * @brief Get the IDLE state of an output channel
  1512. * @rmtoll CR2 OIS1 LL_TIM_OC_GetIdleState\n
  1513. * CR2 OIS1N LL_TIM_OC_GetIdleState\n
  1514. * CR2 OIS2 LL_TIM_OC_GetIdleState\n
  1515. * CR2 OIS2N LL_TIM_OC_GetIdleState\n
  1516. * CR2 OIS3 LL_TIM_OC_GetIdleState\n
  1517. * CR2 OIS3N LL_TIM_OC_GetIdleState\n
  1518. * CR2 OIS4 LL_TIM_OC_GetIdleState
  1519. * @param TIMx Timer instance
  1520. * @param Channel This parameter can be one of the following values:
  1521. * @arg @ref LL_TIM_CHANNEL_CH1
  1522. * @arg @ref LL_TIM_CHANNEL_CH1N
  1523. * @arg @ref LL_TIM_CHANNEL_CH2
  1524. * @arg @ref LL_TIM_CHANNEL_CH2N
  1525. * @arg @ref LL_TIM_CHANNEL_CH3
  1526. * @arg @ref LL_TIM_CHANNEL_CH3N
  1527. * @arg @ref LL_TIM_CHANNEL_CH4
  1528. * @retval Returned value can be one of the following values:
  1529. * @arg @ref LL_TIM_OCIDLESTATE_LOW
  1530. * @arg @ref LL_TIM_OCIDLESTATE_HIGH
  1531. */
  1532. __STATIC_INLINE uint32_t LL_TIM_OC_GetIdleState(TIM_TypeDef *TIMx, uint32_t Channel)
  1533. {
  1534. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1535. return (READ_BIT(TIMx->CR2, (TIM_CR2_OIS1 << SHIFT_TAB_OISx[iChannel])) >> SHIFT_TAB_OISx[iChannel]);
  1536. }
  1537. /**
  1538. * @brief Enable fast mode for the output channel.
  1539. * @note Acts only if the channel is configured in PWM1 or PWM2 mode.
  1540. * @rmtoll CCMR1 OC1FE LL_TIM_OC_EnableFast\n
  1541. * CCMR1 OC2FE LL_TIM_OC_EnableFast\n
  1542. * CCMR2 OC3FE LL_TIM_OC_EnableFast\n
  1543. * CCMR2 OC4FE LL_TIM_OC_EnableFast
  1544. * @param TIMx Timer instance
  1545. * @param Channel This parameter can be one of the following values:
  1546. * @arg @ref LL_TIM_CHANNEL_CH1
  1547. * @arg @ref LL_TIM_CHANNEL_CH2
  1548. * @arg @ref LL_TIM_CHANNEL_CH3
  1549. * @arg @ref LL_TIM_CHANNEL_CH4
  1550. * @retval None
  1551. */
  1552. __STATIC_INLINE void LL_TIM_OC_EnableFast(TIM_TypeDef *TIMx, uint32_t Channel)
  1553. {
  1554. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1555. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1556. SET_BIT(*pReg, (TIM_CCMR1_OC1FE << SHIFT_TAB_OCxx[iChannel]));
  1557. }
  1558. /**
  1559. * @brief Disable fast mode for the output channel.
  1560. * @rmtoll CCMR1 OC1FE LL_TIM_OC_DisableFast\n
  1561. * CCMR1 OC2FE LL_TIM_OC_DisableFast\n
  1562. * CCMR2 OC3FE LL_TIM_OC_DisableFast\n
  1563. * CCMR2 OC4FE LL_TIM_OC_DisableFast
  1564. * @param TIMx Timer instance
  1565. * @param Channel This parameter can be one of the following values:
  1566. * @arg @ref LL_TIM_CHANNEL_CH1
  1567. * @arg @ref LL_TIM_CHANNEL_CH2
  1568. * @arg @ref LL_TIM_CHANNEL_CH3
  1569. * @arg @ref LL_TIM_CHANNEL_CH4
  1570. * @retval None
  1571. */
  1572. __STATIC_INLINE void LL_TIM_OC_DisableFast(TIM_TypeDef *TIMx, uint32_t Channel)
  1573. {
  1574. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1575. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1576. CLEAR_BIT(*pReg, (TIM_CCMR1_OC1FE << SHIFT_TAB_OCxx[iChannel]));
  1577. }
  1578. /**
  1579. * @brief Indicates whether fast mode is enabled for the output channel.
  1580. * @rmtoll CCMR1 OC1FE LL_TIM_OC_IsEnabledFast\n
  1581. * CCMR1 OC2FE LL_TIM_OC_IsEnabledFast\n
  1582. * CCMR2 OC3FE LL_TIM_OC_IsEnabledFast\n
  1583. * CCMR2 OC4FE LL_TIM_OC_IsEnabledFast\n
  1584. * @param TIMx Timer instance
  1585. * @param Channel This parameter can be one of the following values:
  1586. * @arg @ref LL_TIM_CHANNEL_CH1
  1587. * @arg @ref LL_TIM_CHANNEL_CH2
  1588. * @arg @ref LL_TIM_CHANNEL_CH3
  1589. * @arg @ref LL_TIM_CHANNEL_CH4
  1590. * @retval State of bit (1 or 0).
  1591. */
  1592. __STATIC_INLINE uint32_t LL_TIM_OC_IsEnabledFast(TIM_TypeDef *TIMx, uint32_t Channel)
  1593. {
  1594. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1595. const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1596. uint32_t bitfield = TIM_CCMR1_OC1FE << SHIFT_TAB_OCxx[iChannel];
  1597. return ((READ_BIT(*pReg, bitfield) == bitfield) ? 1UL : 0UL);
  1598. }
  1599. /**
  1600. * @brief Enable compare register (TIMx_CCRx) preload for the output channel.
  1601. * @rmtoll CCMR1 OC1PE LL_TIM_OC_EnablePreload\n
  1602. * CCMR1 OC2PE LL_TIM_OC_EnablePreload\n
  1603. * CCMR2 OC3PE LL_TIM_OC_EnablePreload\n
  1604. * CCMR2 OC4PE LL_TIM_OC_EnablePreload
  1605. * @param TIMx Timer instance
  1606. * @param Channel This parameter can be one of the following values:
  1607. * @arg @ref LL_TIM_CHANNEL_CH1
  1608. * @arg @ref LL_TIM_CHANNEL_CH2
  1609. * @arg @ref LL_TIM_CHANNEL_CH3
  1610. * @arg @ref LL_TIM_CHANNEL_CH4
  1611. * @retval None
  1612. */
  1613. __STATIC_INLINE void LL_TIM_OC_EnablePreload(TIM_TypeDef *TIMx, uint32_t Channel)
  1614. {
  1615. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1616. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1617. SET_BIT(*pReg, (TIM_CCMR1_OC1PE << SHIFT_TAB_OCxx[iChannel]));
  1618. }
  1619. /**
  1620. * @brief Disable compare register (TIMx_CCRx) preload for the output channel.
  1621. * @rmtoll CCMR1 OC1PE LL_TIM_OC_DisablePreload\n
  1622. * CCMR1 OC2PE LL_TIM_OC_DisablePreload\n
  1623. * CCMR2 OC3PE LL_TIM_OC_DisablePreload\n
  1624. * CCMR2 OC4PE LL_TIM_OC_DisablePreload
  1625. * @param TIMx Timer instance
  1626. * @param Channel This parameter can be one of the following values:
  1627. * @arg @ref LL_TIM_CHANNEL_CH1
  1628. * @arg @ref LL_TIM_CHANNEL_CH2
  1629. * @arg @ref LL_TIM_CHANNEL_CH3
  1630. * @arg @ref LL_TIM_CHANNEL_CH4
  1631. * @retval None
  1632. */
  1633. __STATIC_INLINE void LL_TIM_OC_DisablePreload(TIM_TypeDef *TIMx, uint32_t Channel)
  1634. {
  1635. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1636. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1637. CLEAR_BIT(*pReg, (TIM_CCMR1_OC1PE << SHIFT_TAB_OCxx[iChannel]));
  1638. }
  1639. /**
  1640. * @brief Indicates whether compare register (TIMx_CCRx) preload is enabled for the output channel.
  1641. * @rmtoll CCMR1 OC1PE LL_TIM_OC_IsEnabledPreload\n
  1642. * CCMR1 OC2PE LL_TIM_OC_IsEnabledPreload\n
  1643. * CCMR2 OC3PE LL_TIM_OC_IsEnabledPreload\n
  1644. * CCMR2 OC4PE LL_TIM_OC_IsEnabledPreload\n
  1645. * @param TIMx Timer instance
  1646. * @param Channel This parameter can be one of the following values:
  1647. * @arg @ref LL_TIM_CHANNEL_CH1
  1648. * @arg @ref LL_TIM_CHANNEL_CH2
  1649. * @arg @ref LL_TIM_CHANNEL_CH3
  1650. * @arg @ref LL_TIM_CHANNEL_CH4
  1651. * @retval State of bit (1 or 0).
  1652. */
  1653. __STATIC_INLINE uint32_t LL_TIM_OC_IsEnabledPreload(TIM_TypeDef *TIMx, uint32_t Channel)
  1654. {
  1655. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1656. const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1657. uint32_t bitfield = TIM_CCMR1_OC1PE << SHIFT_TAB_OCxx[iChannel];
  1658. return ((READ_BIT(*pReg, bitfield) == bitfield) ? 1UL : 0UL);
  1659. }
  1660. /**
  1661. * @brief Enable clearing the output channel on an external event.
  1662. * @note This function can only be used in Output compare and PWM modes. It does not work in Forced mode.
  1663. * @note Macro IS_TIM_OCXREF_CLEAR_INSTANCE(TIMx) can be used to check whether
  1664. * or not a timer instance can clear the OCxREF signal on an external event.
  1665. * @rmtoll CCMR1 OC1CE LL_TIM_OC_EnableClear\n
  1666. * CCMR1 OC2CE LL_TIM_OC_EnableClear\n
  1667. * CCMR2 OC3CE LL_TIM_OC_EnableClear\n
  1668. * CCMR2 OC4CE LL_TIM_OC_EnableClear
  1669. * @param TIMx Timer instance
  1670. * @param Channel This parameter can be one of the following values:
  1671. * @arg @ref LL_TIM_CHANNEL_CH1
  1672. * @arg @ref LL_TIM_CHANNEL_CH2
  1673. * @arg @ref LL_TIM_CHANNEL_CH3
  1674. * @arg @ref LL_TIM_CHANNEL_CH4
  1675. * @retval None
  1676. */
  1677. __STATIC_INLINE void LL_TIM_OC_EnableClear(TIM_TypeDef *TIMx, uint32_t Channel)
  1678. {
  1679. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1680. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1681. SET_BIT(*pReg, (TIM_CCMR1_OC1CE << SHIFT_TAB_OCxx[iChannel]));
  1682. }
  1683. /**
  1684. * @brief Disable clearing the output channel on an external event.
  1685. * @note Macro IS_TIM_OCXREF_CLEAR_INSTANCE(TIMx) can be used to check whether
  1686. * or not a timer instance can clear the OCxREF signal on an external event.
  1687. * @rmtoll CCMR1 OC1CE LL_TIM_OC_DisableClear\n
  1688. * CCMR1 OC2CE LL_TIM_OC_DisableClear\n
  1689. * CCMR2 OC3CE LL_TIM_OC_DisableClear\n
  1690. * CCMR2 OC4CE LL_TIM_OC_DisableClear
  1691. * @param TIMx Timer instance
  1692. * @param Channel This parameter can be one of the following values:
  1693. * @arg @ref LL_TIM_CHANNEL_CH1
  1694. * @arg @ref LL_TIM_CHANNEL_CH2
  1695. * @arg @ref LL_TIM_CHANNEL_CH3
  1696. * @arg @ref LL_TIM_CHANNEL_CH4
  1697. * @retval None
  1698. */
  1699. __STATIC_INLINE void LL_TIM_OC_DisableClear(TIM_TypeDef *TIMx, uint32_t Channel)
  1700. {
  1701. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1702. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1703. CLEAR_BIT(*pReg, (TIM_CCMR1_OC1CE << SHIFT_TAB_OCxx[iChannel]));
  1704. }
  1705. /**
  1706. * @brief Indicates clearing the output channel on an external event is enabled for the output channel.
  1707. * @note This function enables clearing the output channel on an external event.
  1708. * @note This function can only be used in Output compare and PWM modes. It does not work in Forced mode.
  1709. * @note Macro IS_TIM_OCXREF_CLEAR_INSTANCE(TIMx) can be used to check whether
  1710. * or not a timer instance can clear the OCxREF signal on an external event.
  1711. * @rmtoll CCMR1 OC1CE LL_TIM_OC_IsEnabledClear\n
  1712. * CCMR1 OC2CE LL_TIM_OC_IsEnabledClear\n
  1713. * CCMR2 OC3CE LL_TIM_OC_IsEnabledClear\n
  1714. * CCMR2 OC4CE LL_TIM_OC_IsEnabledClear\n
  1715. * @param TIMx Timer instance
  1716. * @param Channel This parameter can be one of the following values:
  1717. * @arg @ref LL_TIM_CHANNEL_CH1
  1718. * @arg @ref LL_TIM_CHANNEL_CH2
  1719. * @arg @ref LL_TIM_CHANNEL_CH3
  1720. * @arg @ref LL_TIM_CHANNEL_CH4
  1721. * @retval State of bit (1 or 0).
  1722. */
  1723. __STATIC_INLINE uint32_t LL_TIM_OC_IsEnabledClear(TIM_TypeDef *TIMx, uint32_t Channel)
  1724. {
  1725. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1726. const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1727. uint32_t bitfield = TIM_CCMR1_OC1CE << SHIFT_TAB_OCxx[iChannel];
  1728. return ((READ_BIT(*pReg, bitfield) == bitfield) ? 1UL : 0UL);
  1729. }
  1730. /**
  1731. * @brief Set the dead-time delay (delay inserted between the rising edge of the OCxREF signal and the rising edge of the Ocx and OCxN signals).
  1732. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  1733. * dead-time insertion feature is supported by a timer instance.
  1734. * @note Helper macro @ref __LL_TIM_CALC_DEADTIME can be used to calculate the DeadTime parameter
  1735. * @rmtoll BDTR DTG LL_TIM_OC_SetDeadTime
  1736. * @param TIMx Timer instance
  1737. * @param DeadTime between Min_Data=0 and Max_Data=255
  1738. * @retval None
  1739. */
  1740. __STATIC_INLINE void LL_TIM_OC_SetDeadTime(TIM_TypeDef *TIMx, uint32_t DeadTime)
  1741. {
  1742. MODIFY_REG(TIMx->BDTR, TIM_BDTR_DTG, DeadTime);
  1743. }
  1744. /**
  1745. * @brief Set compare value for output channel 1 (TIMx_CCR1).
  1746. * @note Macro IS_TIM_CC1_INSTANCE(TIMx) can be used to check whether or not
  1747. * output channel 1 is supported by a timer instance.
  1748. * @rmtoll CCR1 CCR1 LL_TIM_OC_SetCompareCH1
  1749. * @param TIMx Timer instance
  1750. * @param CompareValue between Min_Data=0 and Max_Data=65535
  1751. * @retval None
  1752. */
  1753. __STATIC_INLINE void LL_TIM_OC_SetCompareCH1(TIM_TypeDef *TIMx, uint32_t CompareValue)
  1754. {
  1755. WRITE_REG(TIMx->CCR1, CompareValue);
  1756. }
  1757. /**
  1758. * @brief Set compare value for output channel 2 (TIMx_CCR2).
  1759. * @note Macro IS_TIM_CC2_INSTANCE(TIMx) can be used to check whether or not
  1760. * output channel 2 is supported by a timer instance.
  1761. * @rmtoll CCR2 CCR2 LL_TIM_OC_SetCompareCH2
  1762. * @param TIMx Timer instance
  1763. * @param CompareValue between Min_Data=0 and Max_Data=65535
  1764. * @retval None
  1765. */
  1766. __STATIC_INLINE void LL_TIM_OC_SetCompareCH2(TIM_TypeDef *TIMx, uint32_t CompareValue)
  1767. {
  1768. WRITE_REG(TIMx->CCR2, CompareValue);
  1769. }
  1770. /**
  1771. * @brief Set compare value for output channel 3 (TIMx_CCR3).
  1772. * @note Macro IS_TIM_CC3_INSTANCE(TIMx) can be used to check whether or not
  1773. * output channel is supported by a timer instance.
  1774. * @rmtoll CCR3 CCR3 LL_TIM_OC_SetCompareCH3
  1775. * @param TIMx Timer instance
  1776. * @param CompareValue between Min_Data=0 and Max_Data=65535
  1777. * @retval None
  1778. */
  1779. __STATIC_INLINE void LL_TIM_OC_SetCompareCH3(TIM_TypeDef *TIMx, uint32_t CompareValue)
  1780. {
  1781. WRITE_REG(TIMx->CCR3, CompareValue);
  1782. }
  1783. /**
  1784. * @brief Set compare value for output channel 4 (TIMx_CCR4).
  1785. * @note Macro IS_TIM_CC4_INSTANCE(TIMx) can be used to check whether or not
  1786. * output channel 4 is supported by a timer instance.
  1787. * @rmtoll CCR4 CCR4 LL_TIM_OC_SetCompareCH4
  1788. * @param TIMx Timer instance
  1789. * @param CompareValue between Min_Data=0 and Max_Data=65535
  1790. * @retval None
  1791. */
  1792. __STATIC_INLINE void LL_TIM_OC_SetCompareCH4(TIM_TypeDef *TIMx, uint32_t CompareValue)
  1793. {
  1794. WRITE_REG(TIMx->CCR4, CompareValue);
  1795. }
  1796. /**
  1797. * @brief Get compare value (TIMx_CCR1) set for output channel 1.
  1798. * @note Macro IS_TIM_CC1_INSTANCE(TIMx) can be used to check whether or not
  1799. * output channel 1 is supported by a timer instance.
  1800. * @rmtoll CCR1 CCR1 LL_TIM_OC_GetCompareCH1
  1801. * @param TIMx Timer instance
  1802. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  1803. */
  1804. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH1(TIM_TypeDef *TIMx)
  1805. {
  1806. return (uint32_t)(READ_REG(TIMx->CCR1));
  1807. }
  1808. /**
  1809. * @brief Get compare value (TIMx_CCR2) set for output channel 2.
  1810. * @note Macro IS_TIM_CC2_INSTANCE(TIMx) can be used to check whether or not
  1811. * output channel 2 is supported by a timer instance.
  1812. * @rmtoll CCR2 CCR2 LL_TIM_OC_GetCompareCH2
  1813. * @param TIMx Timer instance
  1814. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  1815. */
  1816. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH2(TIM_TypeDef *TIMx)
  1817. {
  1818. return (uint32_t)(READ_REG(TIMx->CCR2));
  1819. }
  1820. /**
  1821. * @brief Get compare value (TIMx_CCR3) set for output channel 3.
  1822. * @note Macro IS_TIM_CC3_INSTANCE(TIMx) can be used to check whether or not
  1823. * output channel 3 is supported by a timer instance.
  1824. * @rmtoll CCR3 CCR3 LL_TIM_OC_GetCompareCH3
  1825. * @param TIMx Timer instance
  1826. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  1827. */
  1828. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH3(TIM_TypeDef *TIMx)
  1829. {
  1830. return (uint32_t)(READ_REG(TIMx->CCR3));
  1831. }
  1832. /**
  1833. * @brief Get compare value (TIMx_CCR4) set for output channel 4.
  1834. * @note Macro IS_TIM_CC4_INSTANCE(TIMx) can be used to check whether or not
  1835. * output channel 4 is supported by a timer instance.
  1836. * @rmtoll CCR4 CCR4 LL_TIM_OC_GetCompareCH4
  1837. * @param TIMx Timer instance
  1838. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  1839. */
  1840. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH4(TIM_TypeDef *TIMx)
  1841. {
  1842. return (uint32_t)(READ_REG(TIMx->CCR4));
  1843. }
  1844. /**
  1845. * @}
  1846. */
  1847. /** @defgroup TIM_LL_EF_Input_Channel Input channel configuration
  1848. * @{
  1849. */
  1850. /**
  1851. * @brief Configure input channel.
  1852. * @rmtoll CCMR1 CC1S LL_TIM_IC_Config\n
  1853. * CCMR1 IC1PSC LL_TIM_IC_Config\n
  1854. * CCMR1 IC1F LL_TIM_IC_Config\n
  1855. * CCMR1 CC2S LL_TIM_IC_Config\n
  1856. * CCMR1 IC2PSC LL_TIM_IC_Config\n
  1857. * CCMR1 IC2F LL_TIM_IC_Config\n
  1858. * CCMR2 CC3S LL_TIM_IC_Config\n
  1859. * CCMR2 IC3PSC LL_TIM_IC_Config\n
  1860. * CCMR2 IC3F LL_TIM_IC_Config\n
  1861. * CCMR2 CC4S LL_TIM_IC_Config\n
  1862. * CCMR2 IC4PSC LL_TIM_IC_Config\n
  1863. * CCMR2 IC4F LL_TIM_IC_Config\n
  1864. * CCER CC1P LL_TIM_IC_Config\n
  1865. * CCER CC1NP LL_TIM_IC_Config\n
  1866. * CCER CC2P LL_TIM_IC_Config\n
  1867. * CCER CC2NP LL_TIM_IC_Config\n
  1868. * CCER CC3P LL_TIM_IC_Config\n
  1869. * CCER CC3NP LL_TIM_IC_Config\n
  1870. * CCER CC4P LL_TIM_IC_Config\n
  1871. * @param TIMx Timer instance
  1872. * @param Channel This parameter can be one of the following values:
  1873. * @arg @ref LL_TIM_CHANNEL_CH1
  1874. * @arg @ref LL_TIM_CHANNEL_CH2
  1875. * @arg @ref LL_TIM_CHANNEL_CH3
  1876. * @arg @ref LL_TIM_CHANNEL_CH4
  1877. * @param Configuration This parameter must be a combination of all the following values:
  1878. * @arg @ref LL_TIM_ACTIVEINPUT_DIRECTTI or @ref LL_TIM_ACTIVEINPUT_INDIRECTTI or @ref LL_TIM_ACTIVEINPUT_TRC
  1879. * @arg @ref LL_TIM_ICPSC_DIV1 or ... or @ref LL_TIM_ICPSC_DIV8
  1880. * @arg @ref LL_TIM_IC_FILTER_FDIV1 or ... or @ref LL_TIM_IC_FILTER_FDIV32_N8
  1881. * @arg @ref LL_TIM_IC_POLARITY_RISING or @ref LL_TIM_IC_POLARITY_FALLING
  1882. * @retval None
  1883. */
  1884. __STATIC_INLINE void LL_TIM_IC_Config(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Configuration)
  1885. {
  1886. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1887. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1888. MODIFY_REG(*pReg, ((TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC | TIM_CCMR1_CC1S) << SHIFT_TAB_ICxx[iChannel]),
  1889. ((Configuration >> 16U) & (TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC | TIM_CCMR1_CC1S)) << SHIFT_TAB_ICxx[iChannel]);
  1890. MODIFY_REG(TIMx->CCER, ((TIM_CCER_CC1NP | TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel]),
  1891. (Configuration & (TIM_CCER_CC1NP | TIM_CCER_CC1P)) << SHIFT_TAB_CCxP[iChannel]);
  1892. }
  1893. /**
  1894. * @brief Set the active input.
  1895. * @rmtoll CCMR1 CC1S LL_TIM_IC_SetActiveInput\n
  1896. * CCMR1 CC2S LL_TIM_IC_SetActiveInput\n
  1897. * CCMR2 CC3S LL_TIM_IC_SetActiveInput\n
  1898. * CCMR2 CC4S LL_TIM_IC_SetActiveInput
  1899. * @param TIMx Timer instance
  1900. * @param Channel This parameter can be one of the following values:
  1901. * @arg @ref LL_TIM_CHANNEL_CH1
  1902. * @arg @ref LL_TIM_CHANNEL_CH2
  1903. * @arg @ref LL_TIM_CHANNEL_CH3
  1904. * @arg @ref LL_TIM_CHANNEL_CH4
  1905. * @param ICActiveInput This parameter can be one of the following values:
  1906. * @arg @ref LL_TIM_ACTIVEINPUT_DIRECTTI
  1907. * @arg @ref LL_TIM_ACTIVEINPUT_INDIRECTTI
  1908. * @arg @ref LL_TIM_ACTIVEINPUT_TRC
  1909. * @retval None
  1910. */
  1911. __STATIC_INLINE void LL_TIM_IC_SetActiveInput(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICActiveInput)
  1912. {
  1913. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1914. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1915. MODIFY_REG(*pReg, ((TIM_CCMR1_CC1S) << SHIFT_TAB_ICxx[iChannel]), (ICActiveInput >> 16U) << SHIFT_TAB_ICxx[iChannel]);
  1916. }
  1917. /**
  1918. * @brief Get the current active input.
  1919. * @rmtoll CCMR1 CC1S LL_TIM_IC_GetActiveInput\n
  1920. * CCMR1 CC2S LL_TIM_IC_GetActiveInput\n
  1921. * CCMR2 CC3S LL_TIM_IC_GetActiveInput\n
  1922. * CCMR2 CC4S LL_TIM_IC_GetActiveInput
  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_CH2
  1927. * @arg @ref LL_TIM_CHANNEL_CH3
  1928. * @arg @ref LL_TIM_CHANNEL_CH4
  1929. * @retval Returned value can be one of the following values:
  1930. * @arg @ref LL_TIM_ACTIVEINPUT_DIRECTTI
  1931. * @arg @ref LL_TIM_ACTIVEINPUT_INDIRECTTI
  1932. * @arg @ref LL_TIM_ACTIVEINPUT_TRC
  1933. */
  1934. __STATIC_INLINE uint32_t LL_TIM_IC_GetActiveInput(TIM_TypeDef *TIMx, uint32_t Channel)
  1935. {
  1936. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1937. const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1938. return ((READ_BIT(*pReg, ((TIM_CCMR1_CC1S) << SHIFT_TAB_ICxx[iChannel])) >> SHIFT_TAB_ICxx[iChannel]) << 16U);
  1939. }
  1940. /**
  1941. * @brief Set the prescaler of input channel.
  1942. * @rmtoll CCMR1 IC1PSC LL_TIM_IC_SetPrescaler\n
  1943. * CCMR1 IC2PSC LL_TIM_IC_SetPrescaler\n
  1944. * CCMR2 IC3PSC LL_TIM_IC_SetPrescaler\n
  1945. * CCMR2 IC4PSC LL_TIM_IC_SetPrescaler
  1946. * @param TIMx Timer instance
  1947. * @param Channel This parameter can be one of the following values:
  1948. * @arg @ref LL_TIM_CHANNEL_CH1
  1949. * @arg @ref LL_TIM_CHANNEL_CH2
  1950. * @arg @ref LL_TIM_CHANNEL_CH3
  1951. * @arg @ref LL_TIM_CHANNEL_CH4
  1952. * @param ICPrescaler This parameter can be one of the following values:
  1953. * @arg @ref LL_TIM_ICPSC_DIV1
  1954. * @arg @ref LL_TIM_ICPSC_DIV2
  1955. * @arg @ref LL_TIM_ICPSC_DIV4
  1956. * @arg @ref LL_TIM_ICPSC_DIV8
  1957. * @retval None
  1958. */
  1959. __STATIC_INLINE void LL_TIM_IC_SetPrescaler(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICPrescaler)
  1960. {
  1961. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1962. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1963. MODIFY_REG(*pReg, ((TIM_CCMR1_IC1PSC) << SHIFT_TAB_ICxx[iChannel]), (ICPrescaler >> 16U) << SHIFT_TAB_ICxx[iChannel]);
  1964. }
  1965. /**
  1966. * @brief Get the current prescaler value acting on an input channel.
  1967. * @rmtoll CCMR1 IC1PSC LL_TIM_IC_GetPrescaler\n
  1968. * CCMR1 IC2PSC LL_TIM_IC_GetPrescaler\n
  1969. * CCMR2 IC3PSC LL_TIM_IC_GetPrescaler\n
  1970. * CCMR2 IC4PSC LL_TIM_IC_GetPrescaler
  1971. * @param TIMx Timer instance
  1972. * @param Channel This parameter can be one of the following values:
  1973. * @arg @ref LL_TIM_CHANNEL_CH1
  1974. * @arg @ref LL_TIM_CHANNEL_CH2
  1975. * @arg @ref LL_TIM_CHANNEL_CH3
  1976. * @arg @ref LL_TIM_CHANNEL_CH4
  1977. * @retval Returned value can be one of the following values:
  1978. * @arg @ref LL_TIM_ICPSC_DIV1
  1979. * @arg @ref LL_TIM_ICPSC_DIV2
  1980. * @arg @ref LL_TIM_ICPSC_DIV4
  1981. * @arg @ref LL_TIM_ICPSC_DIV8
  1982. */
  1983. __STATIC_INLINE uint32_t LL_TIM_IC_GetPrescaler(TIM_TypeDef *TIMx, uint32_t Channel)
  1984. {
  1985. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1986. const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1987. return ((READ_BIT(*pReg, ((TIM_CCMR1_IC1PSC) << SHIFT_TAB_ICxx[iChannel])) >> SHIFT_TAB_ICxx[iChannel]) << 16U);
  1988. }
  1989. /**
  1990. * @brief Set the input filter duration.
  1991. * @rmtoll CCMR1 IC1F LL_TIM_IC_SetFilter\n
  1992. * CCMR1 IC2F LL_TIM_IC_SetFilter\n
  1993. * CCMR2 IC3F LL_TIM_IC_SetFilter\n
  1994. * CCMR2 IC4F LL_TIM_IC_SetFilter
  1995. * @param TIMx Timer instance
  1996. * @param Channel This parameter can be one of the following values:
  1997. * @arg @ref LL_TIM_CHANNEL_CH1
  1998. * @arg @ref LL_TIM_CHANNEL_CH2
  1999. * @arg @ref LL_TIM_CHANNEL_CH3
  2000. * @arg @ref LL_TIM_CHANNEL_CH4
  2001. * @param ICFilter This parameter can be one of the following values:
  2002. * @arg @ref LL_TIM_IC_FILTER_FDIV1
  2003. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N2
  2004. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N4
  2005. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N8
  2006. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N6
  2007. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N8
  2008. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N6
  2009. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N8
  2010. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N6
  2011. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N8
  2012. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N5
  2013. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N6
  2014. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N8
  2015. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N5
  2016. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N6
  2017. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N8
  2018. * @retval None
  2019. */
  2020. __STATIC_INLINE void LL_TIM_IC_SetFilter(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICFilter)
  2021. {
  2022. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2023. __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2024. MODIFY_REG(*pReg, ((TIM_CCMR1_IC1F) << SHIFT_TAB_ICxx[iChannel]), (ICFilter >> 16U) << SHIFT_TAB_ICxx[iChannel]);
  2025. }
  2026. /**
  2027. * @brief Get the input filter duration.
  2028. * @rmtoll CCMR1 IC1F LL_TIM_IC_GetFilter\n
  2029. * CCMR1 IC2F LL_TIM_IC_GetFilter\n
  2030. * CCMR2 IC3F LL_TIM_IC_GetFilter\n
  2031. * CCMR2 IC4F LL_TIM_IC_GetFilter
  2032. * @param TIMx Timer instance
  2033. * @param Channel This parameter can be one of the following values:
  2034. * @arg @ref LL_TIM_CHANNEL_CH1
  2035. * @arg @ref LL_TIM_CHANNEL_CH2
  2036. * @arg @ref LL_TIM_CHANNEL_CH3
  2037. * @arg @ref LL_TIM_CHANNEL_CH4
  2038. * @retval Returned value can be one of the following values:
  2039. * @arg @ref LL_TIM_IC_FILTER_FDIV1
  2040. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N2
  2041. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N4
  2042. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N8
  2043. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N6
  2044. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N8
  2045. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N6
  2046. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N8
  2047. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N6
  2048. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N8
  2049. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N5
  2050. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N6
  2051. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N8
  2052. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N5
  2053. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N6
  2054. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N8
  2055. */
  2056. __STATIC_INLINE uint32_t LL_TIM_IC_GetFilter(TIM_TypeDef *TIMx, uint32_t Channel)
  2057. {
  2058. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2059. const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2060. return ((READ_BIT(*pReg, ((TIM_CCMR1_IC1F) << SHIFT_TAB_ICxx[iChannel])) >> SHIFT_TAB_ICxx[iChannel]) << 16U);
  2061. }
  2062. /**
  2063. * @brief Set the input channel polarity.
  2064. * @rmtoll CCER CC1P LL_TIM_IC_SetPolarity\n
  2065. * CCER CC1NP LL_TIM_IC_SetPolarity\n
  2066. * CCER CC2P LL_TIM_IC_SetPolarity\n
  2067. * CCER CC2NP LL_TIM_IC_SetPolarity\n
  2068. * CCER CC3P LL_TIM_IC_SetPolarity\n
  2069. * CCER CC3NP LL_TIM_IC_SetPolarity\n
  2070. * CCER CC4P LL_TIM_IC_SetPolarity\n
  2071. * @param TIMx Timer instance
  2072. * @param Channel This parameter can be one of the following values:
  2073. * @arg @ref LL_TIM_CHANNEL_CH1
  2074. * @arg @ref LL_TIM_CHANNEL_CH2
  2075. * @arg @ref LL_TIM_CHANNEL_CH3
  2076. * @arg @ref LL_TIM_CHANNEL_CH4
  2077. * @param ICPolarity This parameter can be one of the following values:
  2078. * @arg @ref LL_TIM_IC_POLARITY_RISING
  2079. * @arg @ref LL_TIM_IC_POLARITY_FALLING
  2080. * @retval None
  2081. */
  2082. __STATIC_INLINE void LL_TIM_IC_SetPolarity(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICPolarity)
  2083. {
  2084. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2085. MODIFY_REG(TIMx->CCER, ((TIM_CCER_CC1NP | TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel]),
  2086. ICPolarity << SHIFT_TAB_CCxP[iChannel]);
  2087. }
  2088. /**
  2089. * @brief Get the current input channel polarity.
  2090. * @rmtoll CCER CC1P LL_TIM_IC_GetPolarity\n
  2091. * CCER CC1NP LL_TIM_IC_GetPolarity\n
  2092. * CCER CC2P LL_TIM_IC_GetPolarity\n
  2093. * CCER CC2NP LL_TIM_IC_GetPolarity\n
  2094. * CCER CC3P LL_TIM_IC_GetPolarity\n
  2095. * CCER CC3NP LL_TIM_IC_GetPolarity\n
  2096. * CCER CC4P LL_TIM_IC_GetPolarity\n
  2097. * @param TIMx Timer instance
  2098. * @param Channel This parameter can be one of the following values:
  2099. * @arg @ref LL_TIM_CHANNEL_CH1
  2100. * @arg @ref LL_TIM_CHANNEL_CH2
  2101. * @arg @ref LL_TIM_CHANNEL_CH3
  2102. * @arg @ref LL_TIM_CHANNEL_CH4
  2103. * @retval Returned value can be one of the following values:
  2104. * @arg @ref LL_TIM_IC_POLARITY_RISING
  2105. * @arg @ref LL_TIM_IC_POLARITY_FALLING
  2106. */
  2107. __STATIC_INLINE uint32_t LL_TIM_IC_GetPolarity(TIM_TypeDef *TIMx, uint32_t Channel)
  2108. {
  2109. uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2110. return (READ_BIT(TIMx->CCER, ((TIM_CCER_CC1NP | TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel])) >>
  2111. SHIFT_TAB_CCxP[iChannel]);
  2112. }
  2113. /**
  2114. * @brief Connect the TIMx_CH1, CH2 and CH3 pins to the TI1 input (XOR combination).
  2115. * @note Macro IS_TIM_XOR_INSTANCE(TIMx) can be used to check whether or not
  2116. * a timer instance provides an XOR input.
  2117. * @rmtoll CR2 TI1S LL_TIM_IC_EnableXORCombination
  2118. * @param TIMx Timer instance
  2119. * @retval None
  2120. */
  2121. __STATIC_INLINE void LL_TIM_IC_EnableXORCombination(TIM_TypeDef *TIMx)
  2122. {
  2123. SET_BIT(TIMx->CR2, TIM_CR2_TI1S);
  2124. }
  2125. /**
  2126. * @brief Disconnect the TIMx_CH1, CH2 and CH3 pins from the TI1 input.
  2127. * @note Macro IS_TIM_XOR_INSTANCE(TIMx) can be used to check whether or not
  2128. * a timer instance provides an XOR input.
  2129. * @rmtoll CR2 TI1S LL_TIM_IC_DisableXORCombination
  2130. * @param TIMx Timer instance
  2131. * @retval None
  2132. */
  2133. __STATIC_INLINE void LL_TIM_IC_DisableXORCombination(TIM_TypeDef *TIMx)
  2134. {
  2135. CLEAR_BIT(TIMx->CR2, TIM_CR2_TI1S);
  2136. }
  2137. /**
  2138. * @brief Indicates whether the TIMx_CH1, CH2 and CH3 pins are connectected to the TI1 input.
  2139. * @note Macro IS_TIM_XOR_INSTANCE(TIMx) can be used to check whether or not
  2140. * a timer instance provides an XOR input.
  2141. * @rmtoll CR2 TI1S LL_TIM_IC_IsEnabledXORCombination
  2142. * @param TIMx Timer instance
  2143. * @retval State of bit (1 or 0).
  2144. */
  2145. __STATIC_INLINE uint32_t LL_TIM_IC_IsEnabledXORCombination(TIM_TypeDef *TIMx)
  2146. {
  2147. return ((READ_BIT(TIMx->CR2, TIM_CR2_TI1S) == (TIM_CR2_TI1S)) ? 1UL : 0UL);
  2148. }
  2149. /**
  2150. * @brief Get captured value for input channel 1.
  2151. * @note Macro IS_TIM_CC1_INSTANCE(TIMx) can be used to check whether or not
  2152. * input channel 1 is supported by a timer instance.
  2153. * @rmtoll CCR1 CCR1 LL_TIM_IC_GetCaptureCH1
  2154. * @param TIMx Timer instance
  2155. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  2156. */
  2157. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH1(TIM_TypeDef *TIMx)
  2158. {
  2159. return (uint32_t)(READ_REG(TIMx->CCR1));
  2160. }
  2161. /**
  2162. * @brief Get captured value for input channel 2.
  2163. * @note Macro IS_TIM_CC2_INSTANCE(TIMx) can be used to check whether or not
  2164. * input channel 2 is supported by a timer instance.
  2165. * @rmtoll CCR2 CCR2 LL_TIM_IC_GetCaptureCH2
  2166. * @param TIMx Timer instance
  2167. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  2168. */
  2169. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH2(TIM_TypeDef *TIMx)
  2170. {
  2171. return (uint32_t)(READ_REG(TIMx->CCR2));
  2172. }
  2173. /**
  2174. * @brief Get captured value for input channel 3.
  2175. * @note Macro IS_TIM_CC3_INSTANCE(TIMx) can be used to check whether or not
  2176. * input channel 3 is supported by a timer instance.
  2177. * @rmtoll CCR3 CCR3 LL_TIM_IC_GetCaptureCH3
  2178. * @param TIMx Timer instance
  2179. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  2180. */
  2181. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH3(TIM_TypeDef *TIMx)
  2182. {
  2183. return (uint32_t)(READ_REG(TIMx->CCR3));
  2184. }
  2185. /**
  2186. * @brief Get captured value for input channel 4.
  2187. * @note Macro IS_TIM_CC4_INSTANCE(TIMx) can be used to check whether or not
  2188. * input channel 4 is supported by a timer instance.
  2189. * @rmtoll CCR4 CCR4 LL_TIM_IC_GetCaptureCH4
  2190. * @param TIMx Timer instance
  2191. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  2192. */
  2193. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH4(TIM_TypeDef *TIMx)
  2194. {
  2195. return (uint32_t)(READ_REG(TIMx->CCR4));
  2196. }
  2197. /**
  2198. * @}
  2199. */
  2200. /** @defgroup TIM_LL_EF_Clock_Selection Counter clock selection
  2201. * @{
  2202. */
  2203. /**
  2204. * @brief Enable external clock mode 2.
  2205. * @note When external clock mode 2 is enabled the counter is clocked by any active edge on the ETRF signal.
  2206. * @note Macro IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  2207. * whether or not a timer instance supports external clock mode2.
  2208. * @rmtoll SMCR ECE LL_TIM_EnableExternalClock
  2209. * @param TIMx Timer instance
  2210. * @retval None
  2211. */
  2212. __STATIC_INLINE void LL_TIM_EnableExternalClock(TIM_TypeDef *TIMx)
  2213. {
  2214. SET_BIT(TIMx->SMCR, TIM_SMCR_ECE);
  2215. }
  2216. /**
  2217. * @brief Disable external clock mode 2.
  2218. * @note Macro IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  2219. * whether or not a timer instance supports external clock mode2.
  2220. * @rmtoll SMCR ECE LL_TIM_DisableExternalClock
  2221. * @param TIMx Timer instance
  2222. * @retval None
  2223. */
  2224. __STATIC_INLINE void LL_TIM_DisableExternalClock(TIM_TypeDef *TIMx)
  2225. {
  2226. CLEAR_BIT(TIMx->SMCR, TIM_SMCR_ECE);
  2227. }
  2228. /**
  2229. * @brief Indicate whether external clock mode 2 is enabled.
  2230. * @note Macro IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  2231. * whether or not a timer instance supports external clock mode2.
  2232. * @rmtoll SMCR ECE LL_TIM_IsEnabledExternalClock
  2233. * @param TIMx Timer instance
  2234. * @retval State of bit (1 or 0).
  2235. */
  2236. __STATIC_INLINE uint32_t LL_TIM_IsEnabledExternalClock(TIM_TypeDef *TIMx)
  2237. {
  2238. return ((READ_BIT(TIMx->SMCR, TIM_SMCR_ECE) == (TIM_SMCR_ECE)) ? 1UL : 0UL);
  2239. }
  2240. /**
  2241. * @brief Set the clock source of the counter clock.
  2242. * @note when selected clock source is external clock mode 1, the timer input
  2243. * the external clock is applied is selected by calling the @ref LL_TIM_SetTriggerInput()
  2244. * function. This timer input must be configured by calling
  2245. * the @ref LL_TIM_IC_Config() function.
  2246. * @note Macro IS_TIM_CLOCKSOURCE_ETRMODE1_INSTANCE(TIMx) can be used to check
  2247. * whether or not a timer instance supports external clock mode1.
  2248. * @note Macro IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  2249. * whether or not a timer instance supports external clock mode2.
  2250. * @rmtoll SMCR SMS LL_TIM_SetClockSource\n
  2251. * SMCR ECE LL_TIM_SetClockSource
  2252. * @param TIMx Timer instance
  2253. * @param ClockSource This parameter can be one of the following values:
  2254. * @arg @ref LL_TIM_CLOCKSOURCE_INTERNAL
  2255. * @arg @ref LL_TIM_CLOCKSOURCE_EXT_MODE1
  2256. * @arg @ref LL_TIM_CLOCKSOURCE_EXT_MODE2
  2257. * @retval None
  2258. */
  2259. __STATIC_INLINE void LL_TIM_SetClockSource(TIM_TypeDef *TIMx, uint32_t ClockSource)
  2260. {
  2261. MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMS | TIM_SMCR_ECE, ClockSource);
  2262. }
  2263. /**
  2264. * @brief Set the encoder interface mode.
  2265. * @note Macro IS_TIM_ENCODER_INTERFACE_INSTANCE(TIMx) can be used to check
  2266. * whether or not a timer instance supports the encoder mode.
  2267. * @rmtoll SMCR SMS LL_TIM_SetEncoderMode
  2268. * @param TIMx Timer instance
  2269. * @param EncoderMode This parameter can be one of the following values:
  2270. * @arg @ref LL_TIM_ENCODERMODE_X2_TI1
  2271. * @arg @ref LL_TIM_ENCODERMODE_X2_TI2
  2272. * @arg @ref LL_TIM_ENCODERMODE_X4_TI12
  2273. * @retval None
  2274. */
  2275. __STATIC_INLINE void LL_TIM_SetEncoderMode(TIM_TypeDef *TIMx, uint32_t EncoderMode)
  2276. {
  2277. MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMS, EncoderMode);
  2278. }
  2279. /**
  2280. * @}
  2281. */
  2282. /** @defgroup TIM_LL_EF_Timer_Synchronization Timer synchronisation configuration
  2283. * @{
  2284. */
  2285. /**
  2286. * @brief Set the trigger output (TRGO) used for timer synchronization .
  2287. * @note Macro IS_TIM_MASTER_INSTANCE(TIMx) can be used to check
  2288. * whether or not a timer instance can operate as a master timer.
  2289. * @rmtoll CR2 MMS LL_TIM_SetTriggerOutput
  2290. * @param TIMx Timer instance
  2291. * @param TimerSynchronization This parameter can be one of the following values:
  2292. * @arg @ref LL_TIM_TRGO_RESET
  2293. * @arg @ref LL_TIM_TRGO_ENABLE
  2294. * @arg @ref LL_TIM_TRGO_UPDATE
  2295. * @arg @ref LL_TIM_TRGO_CC1IF
  2296. * @arg @ref LL_TIM_TRGO_OC1REF
  2297. * @arg @ref LL_TIM_TRGO_OC2REF
  2298. * @arg @ref LL_TIM_TRGO_OC3REF
  2299. * @arg @ref LL_TIM_TRGO_OC4REF
  2300. * @retval None
  2301. */
  2302. __STATIC_INLINE void LL_TIM_SetTriggerOutput(TIM_TypeDef *TIMx, uint32_t TimerSynchronization)
  2303. {
  2304. MODIFY_REG(TIMx->CR2, TIM_CR2_MMS, TimerSynchronization);
  2305. }
  2306. /**
  2307. * @brief Set the synchronization mode of a slave timer.
  2308. * @note Macro IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  2309. * a timer instance can operate as a slave timer.
  2310. * @rmtoll SMCR SMS LL_TIM_SetSlaveMode
  2311. * @param TIMx Timer instance
  2312. * @param SlaveMode This parameter can be one of the following values:
  2313. * @arg @ref LL_TIM_SLAVEMODE_DISABLED
  2314. * @arg @ref LL_TIM_SLAVEMODE_RESET
  2315. * @arg @ref LL_TIM_SLAVEMODE_GATED
  2316. * @arg @ref LL_TIM_SLAVEMODE_TRIGGER
  2317. * @retval None
  2318. */
  2319. __STATIC_INLINE void LL_TIM_SetSlaveMode(TIM_TypeDef *TIMx, uint32_t SlaveMode)
  2320. {
  2321. MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMS, SlaveMode);
  2322. }
  2323. /**
  2324. * @brief Set the selects the trigger input to be used to synchronize the counter.
  2325. * @note Macro IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  2326. * a timer instance can operate as a slave timer.
  2327. * @rmtoll SMCR TS LL_TIM_SetTriggerInput
  2328. * @param TIMx Timer instance
  2329. * @param TriggerInput This parameter can be one of the following values:
  2330. * @arg @ref LL_TIM_TS_ITR0
  2331. * @arg @ref LL_TIM_TS_ITR1
  2332. * @arg @ref LL_TIM_TS_ITR2
  2333. * @arg @ref LL_TIM_TS_ITR3
  2334. * @arg @ref LL_TIM_TS_TI1F_ED
  2335. * @arg @ref LL_TIM_TS_TI1FP1
  2336. * @arg @ref LL_TIM_TS_TI2FP2
  2337. * @arg @ref LL_TIM_TS_ETRF
  2338. * @retval None
  2339. */
  2340. __STATIC_INLINE void LL_TIM_SetTriggerInput(TIM_TypeDef *TIMx, uint32_t TriggerInput)
  2341. {
  2342. MODIFY_REG(TIMx->SMCR, TIM_SMCR_TS, TriggerInput);
  2343. }
  2344. /**
  2345. * @brief Enable the Master/Slave mode.
  2346. * @note Macro IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  2347. * a timer instance can operate as a slave timer.
  2348. * @rmtoll SMCR MSM LL_TIM_EnableMasterSlaveMode
  2349. * @param TIMx Timer instance
  2350. * @retval None
  2351. */
  2352. __STATIC_INLINE void LL_TIM_EnableMasterSlaveMode(TIM_TypeDef *TIMx)
  2353. {
  2354. SET_BIT(TIMx->SMCR, TIM_SMCR_MSM);
  2355. }
  2356. /**
  2357. * @brief Disable the Master/Slave mode.
  2358. * @note Macro IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  2359. * a timer instance can operate as a slave timer.
  2360. * @rmtoll SMCR MSM LL_TIM_DisableMasterSlaveMode
  2361. * @param TIMx Timer instance
  2362. * @retval None
  2363. */
  2364. __STATIC_INLINE void LL_TIM_DisableMasterSlaveMode(TIM_TypeDef *TIMx)
  2365. {
  2366. CLEAR_BIT(TIMx->SMCR, TIM_SMCR_MSM);
  2367. }
  2368. /**
  2369. * @brief Indicates whether the Master/Slave mode is enabled.
  2370. * @note Macro IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  2371. * a timer instance can operate as a slave timer.
  2372. * @rmtoll SMCR MSM LL_TIM_IsEnabledMasterSlaveMode
  2373. * @param TIMx Timer instance
  2374. * @retval State of bit (1 or 0).
  2375. */
  2376. __STATIC_INLINE uint32_t LL_TIM_IsEnabledMasterSlaveMode(TIM_TypeDef *TIMx)
  2377. {
  2378. return ((READ_BIT(TIMx->SMCR, TIM_SMCR_MSM) == (TIM_SMCR_MSM)) ? 1UL : 0UL);
  2379. }
  2380. /**
  2381. * @brief Configure the external trigger (ETR) input.
  2382. * @note Macro IS_TIM_ETR_INSTANCE(TIMx) can be used to check whether or not
  2383. * a timer instance provides an external trigger input.
  2384. * @rmtoll SMCR ETP LL_TIM_ConfigETR\n
  2385. * SMCR ETPS LL_TIM_ConfigETR\n
  2386. * SMCR ETF LL_TIM_ConfigETR
  2387. * @param TIMx Timer instance
  2388. * @param ETRPolarity This parameter can be one of the following values:
  2389. * @arg @ref LL_TIM_ETR_POLARITY_NONINVERTED
  2390. * @arg @ref LL_TIM_ETR_POLARITY_INVERTED
  2391. * @param ETRPrescaler This parameter can be one of the following values:
  2392. * @arg @ref LL_TIM_ETR_PRESCALER_DIV1
  2393. * @arg @ref LL_TIM_ETR_PRESCALER_DIV2
  2394. * @arg @ref LL_TIM_ETR_PRESCALER_DIV4
  2395. * @arg @ref LL_TIM_ETR_PRESCALER_DIV8
  2396. * @param ETRFilter This parameter can be one of the following values:
  2397. * @arg @ref LL_TIM_ETR_FILTER_FDIV1
  2398. * @arg @ref LL_TIM_ETR_FILTER_FDIV1_N2
  2399. * @arg @ref LL_TIM_ETR_FILTER_FDIV1_N4
  2400. * @arg @ref LL_TIM_ETR_FILTER_FDIV1_N8
  2401. * @arg @ref LL_TIM_ETR_FILTER_FDIV2_N6
  2402. * @arg @ref LL_TIM_ETR_FILTER_FDIV2_N8
  2403. * @arg @ref LL_TIM_ETR_FILTER_FDIV4_N6
  2404. * @arg @ref LL_TIM_ETR_FILTER_FDIV4_N8
  2405. * @arg @ref LL_TIM_ETR_FILTER_FDIV8_N6
  2406. * @arg @ref LL_TIM_ETR_FILTER_FDIV8_N8
  2407. * @arg @ref LL_TIM_ETR_FILTER_FDIV16_N5
  2408. * @arg @ref LL_TIM_ETR_FILTER_FDIV16_N6
  2409. * @arg @ref LL_TIM_ETR_FILTER_FDIV16_N8
  2410. * @arg @ref LL_TIM_ETR_FILTER_FDIV32_N5
  2411. * @arg @ref LL_TIM_ETR_FILTER_FDIV32_N6
  2412. * @arg @ref LL_TIM_ETR_FILTER_FDIV32_N8
  2413. * @retval None
  2414. */
  2415. __STATIC_INLINE void LL_TIM_ConfigETR(TIM_TypeDef *TIMx, uint32_t ETRPolarity, uint32_t ETRPrescaler,
  2416. uint32_t ETRFilter)
  2417. {
  2418. MODIFY_REG(TIMx->SMCR, TIM_SMCR_ETP | TIM_SMCR_ETPS | TIM_SMCR_ETF, ETRPolarity | ETRPrescaler | ETRFilter);
  2419. }
  2420. /**
  2421. * @}
  2422. */
  2423. /** @defgroup TIM_LL_EF_Break_Function Break function configuration
  2424. * @{
  2425. */
  2426. /**
  2427. * @brief Enable the break function.
  2428. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2429. * a timer instance provides a break input.
  2430. * @rmtoll BDTR BKE LL_TIM_EnableBRK
  2431. * @param TIMx Timer instance
  2432. * @retval None
  2433. */
  2434. __STATIC_INLINE void LL_TIM_EnableBRK(TIM_TypeDef *TIMx)
  2435. {
  2436. __IO uint32_t tmpreg;
  2437. SET_BIT(TIMx->BDTR, TIM_BDTR_BKE);
  2438. /* Note: Any write operation to this bit takes a delay of 1 APB clock cycle to become effective. */
  2439. tmpreg = READ_REG(TIMx->BDTR);
  2440. (void)(tmpreg);
  2441. }
  2442. /**
  2443. * @brief Disable the break function.
  2444. * @rmtoll BDTR BKE LL_TIM_DisableBRK
  2445. * @param TIMx Timer instance
  2446. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2447. * a timer instance provides a break input.
  2448. * @retval None
  2449. */
  2450. __STATIC_INLINE void LL_TIM_DisableBRK(TIM_TypeDef *TIMx)
  2451. {
  2452. __IO uint32_t tmpreg;
  2453. CLEAR_BIT(TIMx->BDTR, TIM_BDTR_BKE);
  2454. /* Note: Any write operation to this bit takes a delay of 1 APB clock cycle to become effective. */
  2455. tmpreg = READ_REG(TIMx->BDTR);
  2456. (void)(tmpreg);
  2457. }
  2458. /**
  2459. * @brief Configure the break input.
  2460. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2461. * a timer instance provides a break input.
  2462. * @rmtoll BDTR BKP LL_TIM_ConfigBRK
  2463. * @param TIMx Timer instance
  2464. * @param BreakPolarity This parameter can be one of the following values:
  2465. * @arg @ref LL_TIM_BREAK_POLARITY_LOW
  2466. * @arg @ref LL_TIM_BREAK_POLARITY_HIGH
  2467. * @retval None
  2468. */
  2469. __STATIC_INLINE void LL_TIM_ConfigBRK(TIM_TypeDef *TIMx, uint32_t BreakPolarity)
  2470. {
  2471. __IO uint32_t tmpreg;
  2472. MODIFY_REG(TIMx->BDTR, TIM_BDTR_BKP, BreakPolarity);
  2473. /* Note: Any write operation to BKP bit takes a delay of 1 APB clock cycle to become effective. */
  2474. tmpreg = READ_REG(TIMx->BDTR);
  2475. (void)(tmpreg);
  2476. }
  2477. /**
  2478. * @brief Select the outputs off state (enabled v.s. disabled) in Idle and Run modes.
  2479. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2480. * a timer instance provides a break input.
  2481. * @rmtoll BDTR OSSI LL_TIM_SetOffStates\n
  2482. * BDTR OSSR LL_TIM_SetOffStates
  2483. * @param TIMx Timer instance
  2484. * @param OffStateIdle This parameter can be one of the following values:
  2485. * @arg @ref LL_TIM_OSSI_DISABLE
  2486. * @arg @ref LL_TIM_OSSI_ENABLE
  2487. * @param OffStateRun This parameter can be one of the following values:
  2488. * @arg @ref LL_TIM_OSSR_DISABLE
  2489. * @arg @ref LL_TIM_OSSR_ENABLE
  2490. * @retval None
  2491. */
  2492. __STATIC_INLINE void LL_TIM_SetOffStates(TIM_TypeDef *TIMx, uint32_t OffStateIdle, uint32_t OffStateRun)
  2493. {
  2494. MODIFY_REG(TIMx->BDTR, TIM_BDTR_OSSI | TIM_BDTR_OSSR, OffStateIdle | OffStateRun);
  2495. }
  2496. /**
  2497. * @brief Enable automatic output (MOE can be set by software or automatically when a break input is active).
  2498. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2499. * a timer instance provides a break input.
  2500. * @rmtoll BDTR AOE LL_TIM_EnableAutomaticOutput
  2501. * @param TIMx Timer instance
  2502. * @retval None
  2503. */
  2504. __STATIC_INLINE void LL_TIM_EnableAutomaticOutput(TIM_TypeDef *TIMx)
  2505. {
  2506. SET_BIT(TIMx->BDTR, TIM_BDTR_AOE);
  2507. }
  2508. /**
  2509. * @brief Disable automatic output (MOE can be set only by software).
  2510. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2511. * a timer instance provides a break input.
  2512. * @rmtoll BDTR AOE LL_TIM_DisableAutomaticOutput
  2513. * @param TIMx Timer instance
  2514. * @retval None
  2515. */
  2516. __STATIC_INLINE void LL_TIM_DisableAutomaticOutput(TIM_TypeDef *TIMx)
  2517. {
  2518. CLEAR_BIT(TIMx->BDTR, TIM_BDTR_AOE);
  2519. }
  2520. /**
  2521. * @brief Indicate whether automatic output is enabled.
  2522. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2523. * a timer instance provides a break input.
  2524. * @rmtoll BDTR AOE LL_TIM_IsEnabledAutomaticOutput
  2525. * @param TIMx Timer instance
  2526. * @retval State of bit (1 or 0).
  2527. */
  2528. __STATIC_INLINE uint32_t LL_TIM_IsEnabledAutomaticOutput(TIM_TypeDef *TIMx)
  2529. {
  2530. return ((READ_BIT(TIMx->BDTR, TIM_BDTR_AOE) == (TIM_BDTR_AOE)) ? 1UL : 0UL);
  2531. }
  2532. /**
  2533. * @brief Enable the outputs (set the MOE bit in TIMx_BDTR register).
  2534. * @note The MOE bit in TIMx_BDTR register allows to enable /disable the outputs by
  2535. * software and is reset in case of break or break2 event
  2536. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2537. * a timer instance provides a break input.
  2538. * @rmtoll BDTR MOE LL_TIM_EnableAllOutputs
  2539. * @param TIMx Timer instance
  2540. * @retval None
  2541. */
  2542. __STATIC_INLINE void LL_TIM_EnableAllOutputs(TIM_TypeDef *TIMx)
  2543. {
  2544. SET_BIT(TIMx->BDTR, TIM_BDTR_MOE);
  2545. }
  2546. /**
  2547. * @brief Disable the outputs (reset the MOE bit in TIMx_BDTR register).
  2548. * @note The MOE bit in TIMx_BDTR register allows to enable /disable the outputs by
  2549. * software and is reset in case of break or break2 event.
  2550. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2551. * a timer instance provides a break input.
  2552. * @rmtoll BDTR MOE LL_TIM_DisableAllOutputs
  2553. * @param TIMx Timer instance
  2554. * @retval None
  2555. */
  2556. __STATIC_INLINE void LL_TIM_DisableAllOutputs(TIM_TypeDef *TIMx)
  2557. {
  2558. CLEAR_BIT(TIMx->BDTR, TIM_BDTR_MOE);
  2559. }
  2560. /**
  2561. * @brief Indicates whether outputs are enabled.
  2562. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2563. * a timer instance provides a break input.
  2564. * @rmtoll BDTR MOE LL_TIM_IsEnabledAllOutputs
  2565. * @param TIMx Timer instance
  2566. * @retval State of bit (1 or 0).
  2567. */
  2568. __STATIC_INLINE uint32_t LL_TIM_IsEnabledAllOutputs(TIM_TypeDef *TIMx)
  2569. {
  2570. return ((READ_BIT(TIMx->BDTR, TIM_BDTR_MOE) == (TIM_BDTR_MOE)) ? 1UL : 0UL);
  2571. }
  2572. /**
  2573. * @}
  2574. */
  2575. /** @defgroup TIM_LL_EF_DMA_Burst_Mode DMA burst mode configuration
  2576. * @{
  2577. */
  2578. /**
  2579. * @brief Configures the timer DMA burst feature.
  2580. * @note Macro IS_TIM_DMABURST_INSTANCE(TIMx) can be used to check whether or
  2581. * not a timer instance supports the DMA burst mode.
  2582. * @rmtoll DCR DBL LL_TIM_ConfigDMABurst\n
  2583. * DCR DBA LL_TIM_ConfigDMABurst
  2584. * @param TIMx Timer instance
  2585. * @param DMABurstBaseAddress This parameter can be one of the following values:
  2586. * @arg @ref LL_TIM_DMABURST_BASEADDR_CR1
  2587. * @arg @ref LL_TIM_DMABURST_BASEADDR_CR2
  2588. * @arg @ref LL_TIM_DMABURST_BASEADDR_SMCR
  2589. * @arg @ref LL_TIM_DMABURST_BASEADDR_DIER
  2590. * @arg @ref LL_TIM_DMABURST_BASEADDR_SR
  2591. * @arg @ref LL_TIM_DMABURST_BASEADDR_EGR
  2592. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCMR1
  2593. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCMR2
  2594. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCER
  2595. * @arg @ref LL_TIM_DMABURST_BASEADDR_CNT
  2596. * @arg @ref LL_TIM_DMABURST_BASEADDR_PSC
  2597. * @arg @ref LL_TIM_DMABURST_BASEADDR_ARR
  2598. * @arg @ref LL_TIM_DMABURST_BASEADDR_RCR
  2599. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR1
  2600. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR2
  2601. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR3
  2602. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR4
  2603. * @arg @ref LL_TIM_DMABURST_BASEADDR_BDTR
  2604. * @param DMABurstLength This parameter can be one of the following values:
  2605. * @arg @ref LL_TIM_DMABURST_LENGTH_1TRANSFER
  2606. * @arg @ref LL_TIM_DMABURST_LENGTH_2TRANSFERS
  2607. * @arg @ref LL_TIM_DMABURST_LENGTH_3TRANSFERS
  2608. * @arg @ref LL_TIM_DMABURST_LENGTH_4TRANSFERS
  2609. * @arg @ref LL_TIM_DMABURST_LENGTH_5TRANSFERS
  2610. * @arg @ref LL_TIM_DMABURST_LENGTH_6TRANSFERS
  2611. * @arg @ref LL_TIM_DMABURST_LENGTH_7TRANSFERS
  2612. * @arg @ref LL_TIM_DMABURST_LENGTH_8TRANSFERS
  2613. * @arg @ref LL_TIM_DMABURST_LENGTH_9TRANSFERS
  2614. * @arg @ref LL_TIM_DMABURST_LENGTH_10TRANSFERS
  2615. * @arg @ref LL_TIM_DMABURST_LENGTH_11TRANSFERS
  2616. * @arg @ref LL_TIM_DMABURST_LENGTH_12TRANSFERS
  2617. * @arg @ref LL_TIM_DMABURST_LENGTH_13TRANSFERS
  2618. * @arg @ref LL_TIM_DMABURST_LENGTH_14TRANSFERS
  2619. * @arg @ref LL_TIM_DMABURST_LENGTH_15TRANSFERS
  2620. * @arg @ref LL_TIM_DMABURST_LENGTH_16TRANSFERS
  2621. * @arg @ref LL_TIM_DMABURST_LENGTH_17TRANSFERS
  2622. * @arg @ref LL_TIM_DMABURST_LENGTH_18TRANSFERS
  2623. * @retval None
  2624. */
  2625. __STATIC_INLINE void LL_TIM_ConfigDMABurst(TIM_TypeDef *TIMx, uint32_t DMABurstBaseAddress, uint32_t DMABurstLength)
  2626. {
  2627. MODIFY_REG(TIMx->DCR, (TIM_DCR_DBL | TIM_DCR_DBA), (DMABurstBaseAddress | DMABurstLength));
  2628. }
  2629. /**
  2630. * @}
  2631. */
  2632. /**
  2633. * @}
  2634. */
  2635. /** @defgroup TIM_LL_EF_FLAG_Management FLAG-Management
  2636. * @{
  2637. */
  2638. /**
  2639. * @brief Clear the update interrupt flag (UIF).
  2640. * @rmtoll SR UIF LL_TIM_ClearFlag_UPDATE
  2641. * @param TIMx Timer instance
  2642. * @retval None
  2643. */
  2644. __STATIC_INLINE void LL_TIM_ClearFlag_UPDATE(TIM_TypeDef *TIMx)
  2645. {
  2646. WRITE_REG(TIMx->SR, ~(TIM_SR_UIF));
  2647. }
  2648. /**
  2649. * @brief Indicate whether update interrupt flag (UIF) is set (update interrupt is pending).
  2650. * @rmtoll SR UIF LL_TIM_IsActiveFlag_UPDATE
  2651. * @param TIMx Timer instance
  2652. * @retval State of bit (1 or 0).
  2653. */
  2654. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_UPDATE(TIM_TypeDef *TIMx)
  2655. {
  2656. return ((READ_BIT(TIMx->SR, TIM_SR_UIF) == (TIM_SR_UIF)) ? 1UL : 0UL);
  2657. }
  2658. /**
  2659. * @brief Clear the Capture/Compare 1 interrupt flag (CC1F).
  2660. * @rmtoll SR CC1IF LL_TIM_ClearFlag_CC1
  2661. * @param TIMx Timer instance
  2662. * @retval None
  2663. */
  2664. __STATIC_INLINE void LL_TIM_ClearFlag_CC1(TIM_TypeDef *TIMx)
  2665. {
  2666. WRITE_REG(TIMx->SR, ~(TIM_SR_CC1IF));
  2667. }
  2668. /**
  2669. * @brief Indicate whether Capture/Compare 1 interrupt flag (CC1F) is set (Capture/Compare 1 interrupt is pending).
  2670. * @rmtoll SR CC1IF LL_TIM_IsActiveFlag_CC1
  2671. * @param TIMx Timer instance
  2672. * @retval State of bit (1 or 0).
  2673. */
  2674. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC1(TIM_TypeDef *TIMx)
  2675. {
  2676. return ((READ_BIT(TIMx->SR, TIM_SR_CC1IF) == (TIM_SR_CC1IF)) ? 1UL : 0UL);
  2677. }
  2678. /**
  2679. * @brief Clear the Capture/Compare 2 interrupt flag (CC2F).
  2680. * @rmtoll SR CC2IF LL_TIM_ClearFlag_CC2
  2681. * @param TIMx Timer instance
  2682. * @retval None
  2683. */
  2684. __STATIC_INLINE void LL_TIM_ClearFlag_CC2(TIM_TypeDef *TIMx)
  2685. {
  2686. WRITE_REG(TIMx->SR, ~(TIM_SR_CC2IF));
  2687. }
  2688. /**
  2689. * @brief Indicate whether Capture/Compare 2 interrupt flag (CC2F) is set (Capture/Compare 2 interrupt is pending).
  2690. * @rmtoll SR CC2IF LL_TIM_IsActiveFlag_CC2
  2691. * @param TIMx Timer instance
  2692. * @retval State of bit (1 or 0).
  2693. */
  2694. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC2(TIM_TypeDef *TIMx)
  2695. {
  2696. return ((READ_BIT(TIMx->SR, TIM_SR_CC2IF) == (TIM_SR_CC2IF)) ? 1UL : 0UL);
  2697. }
  2698. /**
  2699. * @brief Clear the Capture/Compare 3 interrupt flag (CC3F).
  2700. * @rmtoll SR CC3IF LL_TIM_ClearFlag_CC3
  2701. * @param TIMx Timer instance
  2702. * @retval None
  2703. */
  2704. __STATIC_INLINE void LL_TIM_ClearFlag_CC3(TIM_TypeDef *TIMx)
  2705. {
  2706. WRITE_REG(TIMx->SR, ~(TIM_SR_CC3IF));
  2707. }
  2708. /**
  2709. * @brief Indicate whether Capture/Compare 3 interrupt flag (CC3F) is set (Capture/Compare 3 interrupt is pending).
  2710. * @rmtoll SR CC3IF LL_TIM_IsActiveFlag_CC3
  2711. * @param TIMx Timer instance
  2712. * @retval State of bit (1 or 0).
  2713. */
  2714. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC3(TIM_TypeDef *TIMx)
  2715. {
  2716. return ((READ_BIT(TIMx->SR, TIM_SR_CC3IF) == (TIM_SR_CC3IF)) ? 1UL : 0UL);
  2717. }
  2718. /**
  2719. * @brief Clear the Capture/Compare 4 interrupt flag (CC4F).
  2720. * @rmtoll SR CC4IF LL_TIM_ClearFlag_CC4
  2721. * @param TIMx Timer instance
  2722. * @retval None
  2723. */
  2724. __STATIC_INLINE void LL_TIM_ClearFlag_CC4(TIM_TypeDef *TIMx)
  2725. {
  2726. WRITE_REG(TIMx->SR, ~(TIM_SR_CC4IF));
  2727. }
  2728. /**
  2729. * @brief Indicate whether Capture/Compare 4 interrupt flag (CC4F) is set (Capture/Compare 4 interrupt is pending).
  2730. * @rmtoll SR CC4IF LL_TIM_IsActiveFlag_CC4
  2731. * @param TIMx Timer instance
  2732. * @retval State of bit (1 or 0).
  2733. */
  2734. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC4(TIM_TypeDef *TIMx)
  2735. {
  2736. return ((READ_BIT(TIMx->SR, TIM_SR_CC4IF) == (TIM_SR_CC4IF)) ? 1UL : 0UL);
  2737. }
  2738. /**
  2739. * @brief Clear the commutation interrupt flag (COMIF).
  2740. * @rmtoll SR COMIF LL_TIM_ClearFlag_COM
  2741. * @param TIMx Timer instance
  2742. * @retval None
  2743. */
  2744. __STATIC_INLINE void LL_TIM_ClearFlag_COM(TIM_TypeDef *TIMx)
  2745. {
  2746. WRITE_REG(TIMx->SR, ~(TIM_SR_COMIF));
  2747. }
  2748. /**
  2749. * @brief Indicate whether commutation interrupt flag (COMIF) is set (commutation interrupt is pending).
  2750. * @rmtoll SR COMIF LL_TIM_IsActiveFlag_COM
  2751. * @param TIMx Timer instance
  2752. * @retval State of bit (1 or 0).
  2753. */
  2754. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_COM(TIM_TypeDef *TIMx)
  2755. {
  2756. return ((READ_BIT(TIMx->SR, TIM_SR_COMIF) == (TIM_SR_COMIF)) ? 1UL : 0UL);
  2757. }
  2758. /**
  2759. * @brief Clear the trigger interrupt flag (TIF).
  2760. * @rmtoll SR TIF LL_TIM_ClearFlag_TRIG
  2761. * @param TIMx Timer instance
  2762. * @retval None
  2763. */
  2764. __STATIC_INLINE void LL_TIM_ClearFlag_TRIG(TIM_TypeDef *TIMx)
  2765. {
  2766. WRITE_REG(TIMx->SR, ~(TIM_SR_TIF));
  2767. }
  2768. /**
  2769. * @brief Indicate whether trigger interrupt flag (TIF) is set (trigger interrupt is pending).
  2770. * @rmtoll SR TIF LL_TIM_IsActiveFlag_TRIG
  2771. * @param TIMx Timer instance
  2772. * @retval State of bit (1 or 0).
  2773. */
  2774. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_TRIG(TIM_TypeDef *TIMx)
  2775. {
  2776. return ((READ_BIT(TIMx->SR, TIM_SR_TIF) == (TIM_SR_TIF)) ? 1UL : 0UL);
  2777. }
  2778. /**
  2779. * @brief Clear the break interrupt flag (BIF).
  2780. * @rmtoll SR BIF LL_TIM_ClearFlag_BRK
  2781. * @param TIMx Timer instance
  2782. * @retval None
  2783. */
  2784. __STATIC_INLINE void LL_TIM_ClearFlag_BRK(TIM_TypeDef *TIMx)
  2785. {
  2786. WRITE_REG(TIMx->SR, ~(TIM_SR_BIF));
  2787. }
  2788. /**
  2789. * @brief Indicate whether break interrupt flag (BIF) is set (break interrupt is pending).
  2790. * @rmtoll SR BIF LL_TIM_IsActiveFlag_BRK
  2791. * @param TIMx Timer instance
  2792. * @retval State of bit (1 or 0).
  2793. */
  2794. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_BRK(TIM_TypeDef *TIMx)
  2795. {
  2796. return ((READ_BIT(TIMx->SR, TIM_SR_BIF) == (TIM_SR_BIF)) ? 1UL : 0UL);
  2797. }
  2798. /**
  2799. * @brief Clear the Capture/Compare 1 over-capture interrupt flag (CC1OF).
  2800. * @rmtoll SR CC1OF LL_TIM_ClearFlag_CC1OVR
  2801. * @param TIMx Timer instance
  2802. * @retval None
  2803. */
  2804. __STATIC_INLINE void LL_TIM_ClearFlag_CC1OVR(TIM_TypeDef *TIMx)
  2805. {
  2806. WRITE_REG(TIMx->SR, ~(TIM_SR_CC1OF));
  2807. }
  2808. /**
  2809. * @brief Indicate whether Capture/Compare 1 over-capture interrupt flag (CC1OF) is set (Capture/Compare 1 interrupt is pending).
  2810. * @rmtoll SR CC1OF LL_TIM_IsActiveFlag_CC1OVR
  2811. * @param TIMx Timer instance
  2812. * @retval State of bit (1 or 0).
  2813. */
  2814. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC1OVR(TIM_TypeDef *TIMx)
  2815. {
  2816. return ((READ_BIT(TIMx->SR, TIM_SR_CC1OF) == (TIM_SR_CC1OF)) ? 1UL : 0UL);
  2817. }
  2818. /**
  2819. * @brief Clear the Capture/Compare 2 over-capture interrupt flag (CC2OF).
  2820. * @rmtoll SR CC2OF LL_TIM_ClearFlag_CC2OVR
  2821. * @param TIMx Timer instance
  2822. * @retval None
  2823. */
  2824. __STATIC_INLINE void LL_TIM_ClearFlag_CC2OVR(TIM_TypeDef *TIMx)
  2825. {
  2826. WRITE_REG(TIMx->SR, ~(TIM_SR_CC2OF));
  2827. }
  2828. /**
  2829. * @brief Indicate whether Capture/Compare 2 over-capture interrupt flag (CC2OF) is set (Capture/Compare 2 over-capture interrupt is pending).
  2830. * @rmtoll SR CC2OF LL_TIM_IsActiveFlag_CC2OVR
  2831. * @param TIMx Timer instance
  2832. * @retval State of bit (1 or 0).
  2833. */
  2834. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC2OVR(TIM_TypeDef *TIMx)
  2835. {
  2836. return ((READ_BIT(TIMx->SR, TIM_SR_CC2OF) == (TIM_SR_CC2OF)) ? 1UL : 0UL);
  2837. }
  2838. /**
  2839. * @brief Clear the Capture/Compare 3 over-capture interrupt flag (CC3OF).
  2840. * @rmtoll SR CC3OF LL_TIM_ClearFlag_CC3OVR
  2841. * @param TIMx Timer instance
  2842. * @retval None
  2843. */
  2844. __STATIC_INLINE void LL_TIM_ClearFlag_CC3OVR(TIM_TypeDef *TIMx)
  2845. {
  2846. WRITE_REG(TIMx->SR, ~(TIM_SR_CC3OF));
  2847. }
  2848. /**
  2849. * @brief Indicate whether Capture/Compare 3 over-capture interrupt flag (CC3OF) is set (Capture/Compare 3 over-capture interrupt is pending).
  2850. * @rmtoll SR CC3OF LL_TIM_IsActiveFlag_CC3OVR
  2851. * @param TIMx Timer instance
  2852. * @retval State of bit (1 or 0).
  2853. */
  2854. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC3OVR(TIM_TypeDef *TIMx)
  2855. {
  2856. return ((READ_BIT(TIMx->SR, TIM_SR_CC3OF) == (TIM_SR_CC3OF)) ? 1UL : 0UL);
  2857. }
  2858. /**
  2859. * @brief Clear the Capture/Compare 4 over-capture interrupt flag (CC4OF).
  2860. * @rmtoll SR CC4OF LL_TIM_ClearFlag_CC4OVR
  2861. * @param TIMx Timer instance
  2862. * @retval None
  2863. */
  2864. __STATIC_INLINE void LL_TIM_ClearFlag_CC4OVR(TIM_TypeDef *TIMx)
  2865. {
  2866. WRITE_REG(TIMx->SR, ~(TIM_SR_CC4OF));
  2867. }
  2868. /**
  2869. * @brief Indicate whether Capture/Compare 4 over-capture interrupt flag (CC4OF) is set (Capture/Compare 4 over-capture interrupt is pending).
  2870. * @rmtoll SR CC4OF LL_TIM_IsActiveFlag_CC4OVR
  2871. * @param TIMx Timer instance
  2872. * @retval State of bit (1 or 0).
  2873. */
  2874. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC4OVR(TIM_TypeDef *TIMx)
  2875. {
  2876. return ((READ_BIT(TIMx->SR, TIM_SR_CC4OF) == (TIM_SR_CC4OF)) ? 1UL : 0UL);
  2877. }
  2878. /**
  2879. * @}
  2880. */
  2881. /** @defgroup TIM_LL_EF_IT_Management IT-Management
  2882. * @{
  2883. */
  2884. /**
  2885. * @brief Enable update interrupt (UIE).
  2886. * @rmtoll DIER UIE LL_TIM_EnableIT_UPDATE
  2887. * @param TIMx Timer instance
  2888. * @retval None
  2889. */
  2890. __STATIC_INLINE void LL_TIM_EnableIT_UPDATE(TIM_TypeDef *TIMx)
  2891. {
  2892. SET_BIT(TIMx->DIER, TIM_DIER_UIE);
  2893. }
  2894. /**
  2895. * @brief Disable update interrupt (UIE).
  2896. * @rmtoll DIER UIE LL_TIM_DisableIT_UPDATE
  2897. * @param TIMx Timer instance
  2898. * @retval None
  2899. */
  2900. __STATIC_INLINE void LL_TIM_DisableIT_UPDATE(TIM_TypeDef *TIMx)
  2901. {
  2902. CLEAR_BIT(TIMx->DIER, TIM_DIER_UIE);
  2903. }
  2904. /**
  2905. * @brief Indicates whether the update interrupt (UIE) is enabled.
  2906. * @rmtoll DIER UIE LL_TIM_IsEnabledIT_UPDATE
  2907. * @param TIMx Timer instance
  2908. * @retval State of bit (1 or 0).
  2909. */
  2910. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_UPDATE(TIM_TypeDef *TIMx)
  2911. {
  2912. return ((READ_BIT(TIMx->DIER, TIM_DIER_UIE) == (TIM_DIER_UIE)) ? 1UL : 0UL);
  2913. }
  2914. /**
  2915. * @brief Enable capture/compare 1 interrupt (CC1IE).
  2916. * @rmtoll DIER CC1IE LL_TIM_EnableIT_CC1
  2917. * @param TIMx Timer instance
  2918. * @retval None
  2919. */
  2920. __STATIC_INLINE void LL_TIM_EnableIT_CC1(TIM_TypeDef *TIMx)
  2921. {
  2922. SET_BIT(TIMx->DIER, TIM_DIER_CC1IE);
  2923. }
  2924. /**
  2925. * @brief Disable capture/compare 1 interrupt (CC1IE).
  2926. * @rmtoll DIER CC1IE LL_TIM_DisableIT_CC1
  2927. * @param TIMx Timer instance
  2928. * @retval None
  2929. */
  2930. __STATIC_INLINE void LL_TIM_DisableIT_CC1(TIM_TypeDef *TIMx)
  2931. {
  2932. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC1IE);
  2933. }
  2934. /**
  2935. * @brief Indicates whether the capture/compare 1 interrupt (CC1IE) is enabled.
  2936. * @rmtoll DIER CC1IE LL_TIM_IsEnabledIT_CC1
  2937. * @param TIMx Timer instance
  2938. * @retval State of bit (1 or 0).
  2939. */
  2940. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC1(TIM_TypeDef *TIMx)
  2941. {
  2942. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC1IE) == (TIM_DIER_CC1IE)) ? 1UL : 0UL);
  2943. }
  2944. /**
  2945. * @brief Enable capture/compare 2 interrupt (CC2IE).
  2946. * @rmtoll DIER CC2IE LL_TIM_EnableIT_CC2
  2947. * @param TIMx Timer instance
  2948. * @retval None
  2949. */
  2950. __STATIC_INLINE void LL_TIM_EnableIT_CC2(TIM_TypeDef *TIMx)
  2951. {
  2952. SET_BIT(TIMx->DIER, TIM_DIER_CC2IE);
  2953. }
  2954. /**
  2955. * @brief Disable capture/compare 2 interrupt (CC2IE).
  2956. * @rmtoll DIER CC2IE LL_TIM_DisableIT_CC2
  2957. * @param TIMx Timer instance
  2958. * @retval None
  2959. */
  2960. __STATIC_INLINE void LL_TIM_DisableIT_CC2(TIM_TypeDef *TIMx)
  2961. {
  2962. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC2IE);
  2963. }
  2964. /**
  2965. * @brief Indicates whether the capture/compare 2 interrupt (CC2IE) is enabled.
  2966. * @rmtoll DIER CC2IE LL_TIM_IsEnabledIT_CC2
  2967. * @param TIMx Timer instance
  2968. * @retval State of bit (1 or 0).
  2969. */
  2970. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC2(TIM_TypeDef *TIMx)
  2971. {
  2972. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC2IE) == (TIM_DIER_CC2IE)) ? 1UL : 0UL);
  2973. }
  2974. /**
  2975. * @brief Enable capture/compare 3 interrupt (CC3IE).
  2976. * @rmtoll DIER CC3IE LL_TIM_EnableIT_CC3
  2977. * @param TIMx Timer instance
  2978. * @retval None
  2979. */
  2980. __STATIC_INLINE void LL_TIM_EnableIT_CC3(TIM_TypeDef *TIMx)
  2981. {
  2982. SET_BIT(TIMx->DIER, TIM_DIER_CC3IE);
  2983. }
  2984. /**
  2985. * @brief Disable capture/compare 3 interrupt (CC3IE).
  2986. * @rmtoll DIER CC3IE LL_TIM_DisableIT_CC3
  2987. * @param TIMx Timer instance
  2988. * @retval None
  2989. */
  2990. __STATIC_INLINE void LL_TIM_DisableIT_CC3(TIM_TypeDef *TIMx)
  2991. {
  2992. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC3IE);
  2993. }
  2994. /**
  2995. * @brief Indicates whether the capture/compare 3 interrupt (CC3IE) is enabled.
  2996. * @rmtoll DIER CC3IE LL_TIM_IsEnabledIT_CC3
  2997. * @param TIMx Timer instance
  2998. * @retval State of bit (1 or 0).
  2999. */
  3000. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC3(TIM_TypeDef *TIMx)
  3001. {
  3002. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC3IE) == (TIM_DIER_CC3IE)) ? 1UL : 0UL);
  3003. }
  3004. /**
  3005. * @brief Enable capture/compare 4 interrupt (CC4IE).
  3006. * @rmtoll DIER CC4IE LL_TIM_EnableIT_CC4
  3007. * @param TIMx Timer instance
  3008. * @retval None
  3009. */
  3010. __STATIC_INLINE void LL_TIM_EnableIT_CC4(TIM_TypeDef *TIMx)
  3011. {
  3012. SET_BIT(TIMx->DIER, TIM_DIER_CC4IE);
  3013. }
  3014. /**
  3015. * @brief Disable capture/compare 4 interrupt (CC4IE).
  3016. * @rmtoll DIER CC4IE LL_TIM_DisableIT_CC4
  3017. * @param TIMx Timer instance
  3018. * @retval None
  3019. */
  3020. __STATIC_INLINE void LL_TIM_DisableIT_CC4(TIM_TypeDef *TIMx)
  3021. {
  3022. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC4IE);
  3023. }
  3024. /**
  3025. * @brief Indicates whether the capture/compare 4 interrupt (CC4IE) is enabled.
  3026. * @rmtoll DIER CC4IE LL_TIM_IsEnabledIT_CC4
  3027. * @param TIMx Timer instance
  3028. * @retval State of bit (1 or 0).
  3029. */
  3030. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC4(TIM_TypeDef *TIMx)
  3031. {
  3032. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC4IE) == (TIM_DIER_CC4IE)) ? 1UL : 0UL);
  3033. }
  3034. /**
  3035. * @brief Enable commutation interrupt (COMIE).
  3036. * @rmtoll DIER COMIE LL_TIM_EnableIT_COM
  3037. * @param TIMx Timer instance
  3038. * @retval None
  3039. */
  3040. __STATIC_INLINE void LL_TIM_EnableIT_COM(TIM_TypeDef *TIMx)
  3041. {
  3042. SET_BIT(TIMx->DIER, TIM_DIER_COMIE);
  3043. }
  3044. /**
  3045. * @brief Disable commutation interrupt (COMIE).
  3046. * @rmtoll DIER COMIE LL_TIM_DisableIT_COM
  3047. * @param TIMx Timer instance
  3048. * @retval None
  3049. */
  3050. __STATIC_INLINE void LL_TIM_DisableIT_COM(TIM_TypeDef *TIMx)
  3051. {
  3052. CLEAR_BIT(TIMx->DIER, TIM_DIER_COMIE);
  3053. }
  3054. /**
  3055. * @brief Indicates whether the commutation interrupt (COMIE) is enabled.
  3056. * @rmtoll DIER COMIE LL_TIM_IsEnabledIT_COM
  3057. * @param TIMx Timer instance
  3058. * @retval State of bit (1 or 0).
  3059. */
  3060. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_COM(TIM_TypeDef *TIMx)
  3061. {
  3062. return ((READ_BIT(TIMx->DIER, TIM_DIER_COMIE) == (TIM_DIER_COMIE)) ? 1UL : 0UL);
  3063. }
  3064. /**
  3065. * @brief Enable trigger interrupt (TIE).
  3066. * @rmtoll DIER TIE LL_TIM_EnableIT_TRIG
  3067. * @param TIMx Timer instance
  3068. * @retval None
  3069. */
  3070. __STATIC_INLINE void LL_TIM_EnableIT_TRIG(TIM_TypeDef *TIMx)
  3071. {
  3072. SET_BIT(TIMx->DIER, TIM_DIER_TIE);
  3073. }
  3074. /**
  3075. * @brief Disable trigger interrupt (TIE).
  3076. * @rmtoll DIER TIE LL_TIM_DisableIT_TRIG
  3077. * @param TIMx Timer instance
  3078. * @retval None
  3079. */
  3080. __STATIC_INLINE void LL_TIM_DisableIT_TRIG(TIM_TypeDef *TIMx)
  3081. {
  3082. CLEAR_BIT(TIMx->DIER, TIM_DIER_TIE);
  3083. }
  3084. /**
  3085. * @brief Indicates whether the trigger interrupt (TIE) is enabled.
  3086. * @rmtoll DIER TIE LL_TIM_IsEnabledIT_TRIG
  3087. * @param TIMx Timer instance
  3088. * @retval State of bit (1 or 0).
  3089. */
  3090. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_TRIG(TIM_TypeDef *TIMx)
  3091. {
  3092. return ((READ_BIT(TIMx->DIER, TIM_DIER_TIE) == (TIM_DIER_TIE)) ? 1UL : 0UL);
  3093. }
  3094. /**
  3095. * @brief Enable break interrupt (BIE).
  3096. * @rmtoll DIER BIE LL_TIM_EnableIT_BRK
  3097. * @param TIMx Timer instance
  3098. * @retval None
  3099. */
  3100. __STATIC_INLINE void LL_TIM_EnableIT_BRK(TIM_TypeDef *TIMx)
  3101. {
  3102. SET_BIT(TIMx->DIER, TIM_DIER_BIE);
  3103. }
  3104. /**
  3105. * @brief Disable break interrupt (BIE).
  3106. * @rmtoll DIER BIE LL_TIM_DisableIT_BRK
  3107. * @param TIMx Timer instance
  3108. * @retval None
  3109. */
  3110. __STATIC_INLINE void LL_TIM_DisableIT_BRK(TIM_TypeDef *TIMx)
  3111. {
  3112. CLEAR_BIT(TIMx->DIER, TIM_DIER_BIE);
  3113. }
  3114. /**
  3115. * @brief Indicates whether the break interrupt (BIE) is enabled.
  3116. * @rmtoll DIER BIE LL_TIM_IsEnabledIT_BRK
  3117. * @param TIMx Timer instance
  3118. * @retval State of bit (1 or 0).
  3119. */
  3120. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_BRK(TIM_TypeDef *TIMx)
  3121. {
  3122. return ((READ_BIT(TIMx->DIER, TIM_DIER_BIE) == (TIM_DIER_BIE)) ? 1UL : 0UL);
  3123. }
  3124. /**
  3125. * @}
  3126. */
  3127. /** @defgroup TIM_LL_EF_DMA_Management DMA-Management
  3128. * @{
  3129. */
  3130. /**
  3131. * @brief Enable update DMA request (UDE).
  3132. * @rmtoll DIER UDE LL_TIM_EnableDMAReq_UPDATE
  3133. * @param TIMx Timer instance
  3134. * @retval None
  3135. */
  3136. __STATIC_INLINE void LL_TIM_EnableDMAReq_UPDATE(TIM_TypeDef *TIMx)
  3137. {
  3138. SET_BIT(TIMx->DIER, TIM_DIER_UDE);
  3139. }
  3140. /**
  3141. * @brief Disable update DMA request (UDE).
  3142. * @rmtoll DIER UDE LL_TIM_DisableDMAReq_UPDATE
  3143. * @param TIMx Timer instance
  3144. * @retval None
  3145. */
  3146. __STATIC_INLINE void LL_TIM_DisableDMAReq_UPDATE(TIM_TypeDef *TIMx)
  3147. {
  3148. CLEAR_BIT(TIMx->DIER, TIM_DIER_UDE);
  3149. }
  3150. /**
  3151. * @brief Indicates whether the update DMA request (UDE) is enabled.
  3152. * @rmtoll DIER UDE LL_TIM_IsEnabledDMAReq_UPDATE
  3153. * @param TIMx Timer instance
  3154. * @retval State of bit (1 or 0).
  3155. */
  3156. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_UPDATE(TIM_TypeDef *TIMx)
  3157. {
  3158. return ((READ_BIT(TIMx->DIER, TIM_DIER_UDE) == (TIM_DIER_UDE)) ? 1UL : 0UL);
  3159. }
  3160. /**
  3161. * @brief Enable capture/compare 1 DMA request (CC1DE).
  3162. * @rmtoll DIER CC1DE LL_TIM_EnableDMAReq_CC1
  3163. * @param TIMx Timer instance
  3164. * @retval None
  3165. */
  3166. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC1(TIM_TypeDef *TIMx)
  3167. {
  3168. SET_BIT(TIMx->DIER, TIM_DIER_CC1DE);
  3169. }
  3170. /**
  3171. * @brief Disable capture/compare 1 DMA request (CC1DE).
  3172. * @rmtoll DIER CC1DE LL_TIM_DisableDMAReq_CC1
  3173. * @param TIMx Timer instance
  3174. * @retval None
  3175. */
  3176. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC1(TIM_TypeDef *TIMx)
  3177. {
  3178. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC1DE);
  3179. }
  3180. /**
  3181. * @brief Indicates whether the capture/compare 1 DMA request (CC1DE) is enabled.
  3182. * @rmtoll DIER CC1DE LL_TIM_IsEnabledDMAReq_CC1
  3183. * @param TIMx Timer instance
  3184. * @retval State of bit (1 or 0).
  3185. */
  3186. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC1(TIM_TypeDef *TIMx)
  3187. {
  3188. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC1DE) == (TIM_DIER_CC1DE)) ? 1UL : 0UL);
  3189. }
  3190. /**
  3191. * @brief Enable capture/compare 2 DMA request (CC2DE).
  3192. * @rmtoll DIER CC2DE LL_TIM_EnableDMAReq_CC2
  3193. * @param TIMx Timer instance
  3194. * @retval None
  3195. */
  3196. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC2(TIM_TypeDef *TIMx)
  3197. {
  3198. SET_BIT(TIMx->DIER, TIM_DIER_CC2DE);
  3199. }
  3200. /**
  3201. * @brief Disable capture/compare 2 DMA request (CC2DE).
  3202. * @rmtoll DIER CC2DE LL_TIM_DisableDMAReq_CC2
  3203. * @param TIMx Timer instance
  3204. * @retval None
  3205. */
  3206. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC2(TIM_TypeDef *TIMx)
  3207. {
  3208. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC2DE);
  3209. }
  3210. /**
  3211. * @brief Indicates whether the capture/compare 2 DMA request (CC2DE) is enabled.
  3212. * @rmtoll DIER CC2DE LL_TIM_IsEnabledDMAReq_CC2
  3213. * @param TIMx Timer instance
  3214. * @retval State of bit (1 or 0).
  3215. */
  3216. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC2(TIM_TypeDef *TIMx)
  3217. {
  3218. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC2DE) == (TIM_DIER_CC2DE)) ? 1UL : 0UL);
  3219. }
  3220. /**
  3221. * @brief Enable capture/compare 3 DMA request (CC3DE).
  3222. * @rmtoll DIER CC3DE LL_TIM_EnableDMAReq_CC3
  3223. * @param TIMx Timer instance
  3224. * @retval None
  3225. */
  3226. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC3(TIM_TypeDef *TIMx)
  3227. {
  3228. SET_BIT(TIMx->DIER, TIM_DIER_CC3DE);
  3229. }
  3230. /**
  3231. * @brief Disable capture/compare 3 DMA request (CC3DE).
  3232. * @rmtoll DIER CC3DE LL_TIM_DisableDMAReq_CC3
  3233. * @param TIMx Timer instance
  3234. * @retval None
  3235. */
  3236. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC3(TIM_TypeDef *TIMx)
  3237. {
  3238. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC3DE);
  3239. }
  3240. /**
  3241. * @brief Indicates whether the capture/compare 3 DMA request (CC3DE) is enabled.
  3242. * @rmtoll DIER CC3DE LL_TIM_IsEnabledDMAReq_CC3
  3243. * @param TIMx Timer instance
  3244. * @retval State of bit (1 or 0).
  3245. */
  3246. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC3(TIM_TypeDef *TIMx)
  3247. {
  3248. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC3DE) == (TIM_DIER_CC3DE)) ? 1UL : 0UL);
  3249. }
  3250. /**
  3251. * @brief Enable capture/compare 4 DMA request (CC4DE).
  3252. * @rmtoll DIER CC4DE LL_TIM_EnableDMAReq_CC4
  3253. * @param TIMx Timer instance
  3254. * @retval None
  3255. */
  3256. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC4(TIM_TypeDef *TIMx)
  3257. {
  3258. SET_BIT(TIMx->DIER, TIM_DIER_CC4DE);
  3259. }
  3260. /**
  3261. * @brief Disable capture/compare 4 DMA request (CC4DE).
  3262. * @rmtoll DIER CC4DE LL_TIM_DisableDMAReq_CC4
  3263. * @param TIMx Timer instance
  3264. * @retval None
  3265. */
  3266. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC4(TIM_TypeDef *TIMx)
  3267. {
  3268. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC4DE);
  3269. }
  3270. /**
  3271. * @brief Indicates whether the capture/compare 4 DMA request (CC4DE) is enabled.
  3272. * @rmtoll DIER CC4DE LL_TIM_IsEnabledDMAReq_CC4
  3273. * @param TIMx Timer instance
  3274. * @retval State of bit (1 or 0).
  3275. */
  3276. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC4(TIM_TypeDef *TIMx)
  3277. {
  3278. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC4DE) == (TIM_DIER_CC4DE)) ? 1UL : 0UL);
  3279. }
  3280. /**
  3281. * @brief Enable commutation DMA request (COMDE).
  3282. * @rmtoll DIER COMDE LL_TIM_EnableDMAReq_COM
  3283. * @param TIMx Timer instance
  3284. * @retval None
  3285. */
  3286. __STATIC_INLINE void LL_TIM_EnableDMAReq_COM(TIM_TypeDef *TIMx)
  3287. {
  3288. SET_BIT(TIMx->DIER, TIM_DIER_COMDE);
  3289. }
  3290. /**
  3291. * @brief Disable commutation DMA request (COMDE).
  3292. * @rmtoll DIER COMDE LL_TIM_DisableDMAReq_COM
  3293. * @param TIMx Timer instance
  3294. * @retval None
  3295. */
  3296. __STATIC_INLINE void LL_TIM_DisableDMAReq_COM(TIM_TypeDef *TIMx)
  3297. {
  3298. CLEAR_BIT(TIMx->DIER, TIM_DIER_COMDE);
  3299. }
  3300. /**
  3301. * @brief Indicates whether the commutation DMA request (COMDE) is enabled.
  3302. * @rmtoll DIER COMDE LL_TIM_IsEnabledDMAReq_COM
  3303. * @param TIMx Timer instance
  3304. * @retval State of bit (1 or 0).
  3305. */
  3306. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_COM(TIM_TypeDef *TIMx)
  3307. {
  3308. return ((READ_BIT(TIMx->DIER, TIM_DIER_COMDE) == (TIM_DIER_COMDE)) ? 1UL : 0UL);
  3309. }
  3310. /**
  3311. * @brief Enable trigger interrupt (TDE).
  3312. * @rmtoll DIER TDE LL_TIM_EnableDMAReq_TRIG
  3313. * @param TIMx Timer instance
  3314. * @retval None
  3315. */
  3316. __STATIC_INLINE void LL_TIM_EnableDMAReq_TRIG(TIM_TypeDef *TIMx)
  3317. {
  3318. SET_BIT(TIMx->DIER, TIM_DIER_TDE);
  3319. }
  3320. /**
  3321. * @brief Disable trigger interrupt (TDE).
  3322. * @rmtoll DIER TDE LL_TIM_DisableDMAReq_TRIG
  3323. * @param TIMx Timer instance
  3324. * @retval None
  3325. */
  3326. __STATIC_INLINE void LL_TIM_DisableDMAReq_TRIG(TIM_TypeDef *TIMx)
  3327. {
  3328. CLEAR_BIT(TIMx->DIER, TIM_DIER_TDE);
  3329. }
  3330. /**
  3331. * @brief Indicates whether the trigger interrupt (TDE) is enabled.
  3332. * @rmtoll DIER TDE LL_TIM_IsEnabledDMAReq_TRIG
  3333. * @param TIMx Timer instance
  3334. * @retval State of bit (1 or 0).
  3335. */
  3336. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_TRIG(TIM_TypeDef *TIMx)
  3337. {
  3338. return ((READ_BIT(TIMx->DIER, TIM_DIER_TDE) == (TIM_DIER_TDE)) ? 1UL : 0UL);
  3339. }
  3340. /**
  3341. * @}
  3342. */
  3343. /** @defgroup TIM_LL_EF_EVENT_Management EVENT-Management
  3344. * @{
  3345. */
  3346. /**
  3347. * @brief Generate an update event.
  3348. * @rmtoll EGR UG LL_TIM_GenerateEvent_UPDATE
  3349. * @param TIMx Timer instance
  3350. * @retval None
  3351. */
  3352. __STATIC_INLINE void LL_TIM_GenerateEvent_UPDATE(TIM_TypeDef *TIMx)
  3353. {
  3354. SET_BIT(TIMx->EGR, TIM_EGR_UG);
  3355. }
  3356. /**
  3357. * @brief Generate Capture/Compare 1 event.
  3358. * @rmtoll EGR CC1G LL_TIM_GenerateEvent_CC1
  3359. * @param TIMx Timer instance
  3360. * @retval None
  3361. */
  3362. __STATIC_INLINE void LL_TIM_GenerateEvent_CC1(TIM_TypeDef *TIMx)
  3363. {
  3364. SET_BIT(TIMx->EGR, TIM_EGR_CC1G);
  3365. }
  3366. /**
  3367. * @brief Generate Capture/Compare 2 event.
  3368. * @rmtoll EGR CC2G LL_TIM_GenerateEvent_CC2
  3369. * @param TIMx Timer instance
  3370. * @retval None
  3371. */
  3372. __STATIC_INLINE void LL_TIM_GenerateEvent_CC2(TIM_TypeDef *TIMx)
  3373. {
  3374. SET_BIT(TIMx->EGR, TIM_EGR_CC2G);
  3375. }
  3376. /**
  3377. * @brief Generate Capture/Compare 3 event.
  3378. * @rmtoll EGR CC3G LL_TIM_GenerateEvent_CC3
  3379. * @param TIMx Timer instance
  3380. * @retval None
  3381. */
  3382. __STATIC_INLINE void LL_TIM_GenerateEvent_CC3(TIM_TypeDef *TIMx)
  3383. {
  3384. SET_BIT(TIMx->EGR, TIM_EGR_CC3G);
  3385. }
  3386. /**
  3387. * @brief Generate Capture/Compare 4 event.
  3388. * @rmtoll EGR CC4G LL_TIM_GenerateEvent_CC4
  3389. * @param TIMx Timer instance
  3390. * @retval None
  3391. */
  3392. __STATIC_INLINE void LL_TIM_GenerateEvent_CC4(TIM_TypeDef *TIMx)
  3393. {
  3394. SET_BIT(TIMx->EGR, TIM_EGR_CC4G);
  3395. }
  3396. /**
  3397. * @brief Generate commutation event.
  3398. * @rmtoll EGR COMG LL_TIM_GenerateEvent_COM
  3399. * @param TIMx Timer instance
  3400. * @retval None
  3401. */
  3402. __STATIC_INLINE void LL_TIM_GenerateEvent_COM(TIM_TypeDef *TIMx)
  3403. {
  3404. SET_BIT(TIMx->EGR, TIM_EGR_COMG);
  3405. }
  3406. /**
  3407. * @brief Generate trigger event.
  3408. * @rmtoll EGR TG LL_TIM_GenerateEvent_TRIG
  3409. * @param TIMx Timer instance
  3410. * @retval None
  3411. */
  3412. __STATIC_INLINE void LL_TIM_GenerateEvent_TRIG(TIM_TypeDef *TIMx)
  3413. {
  3414. SET_BIT(TIMx->EGR, TIM_EGR_TG);
  3415. }
  3416. /**
  3417. * @brief Generate break event.
  3418. * @rmtoll EGR BG LL_TIM_GenerateEvent_BRK
  3419. * @param TIMx Timer instance
  3420. * @retval None
  3421. */
  3422. __STATIC_INLINE void LL_TIM_GenerateEvent_BRK(TIM_TypeDef *TIMx)
  3423. {
  3424. SET_BIT(TIMx->EGR, TIM_EGR_BG);
  3425. }
  3426. /**
  3427. * @}
  3428. */
  3429. #if defined(USE_FULL_LL_DRIVER)
  3430. /** @defgroup TIM_LL_EF_Init Initialisation and deinitialisation functions
  3431. * @{
  3432. */
  3433. ErrorStatus LL_TIM_DeInit(TIM_TypeDef *TIMx);
  3434. void LL_TIM_StructInit(LL_TIM_InitTypeDef *TIM_InitStruct);
  3435. ErrorStatus LL_TIM_Init(TIM_TypeDef *TIMx, LL_TIM_InitTypeDef *TIM_InitStruct);
  3436. void LL_TIM_OC_StructInit(LL_TIM_OC_InitTypeDef *TIM_OC_InitStruct);
  3437. ErrorStatus LL_TIM_OC_Init(TIM_TypeDef *TIMx, uint32_t Channel, LL_TIM_OC_InitTypeDef *TIM_OC_InitStruct);
  3438. void LL_TIM_IC_StructInit(LL_TIM_IC_InitTypeDef *TIM_ICInitStruct);
  3439. ErrorStatus LL_TIM_IC_Init(TIM_TypeDef *TIMx, uint32_t Channel, LL_TIM_IC_InitTypeDef *TIM_IC_InitStruct);
  3440. void LL_TIM_ENCODER_StructInit(LL_TIM_ENCODER_InitTypeDef *TIM_EncoderInitStruct);
  3441. ErrorStatus LL_TIM_ENCODER_Init(TIM_TypeDef *TIMx, LL_TIM_ENCODER_InitTypeDef *TIM_EncoderInitStruct);
  3442. void LL_TIM_HALLSENSOR_StructInit(LL_TIM_HALLSENSOR_InitTypeDef *TIM_HallSensorInitStruct);
  3443. ErrorStatus LL_TIM_HALLSENSOR_Init(TIM_TypeDef *TIMx, LL_TIM_HALLSENSOR_InitTypeDef *TIM_HallSensorInitStruct);
  3444. void LL_TIM_BDTR_StructInit(LL_TIM_BDTR_InitTypeDef *TIM_BDTRInitStruct);
  3445. ErrorStatus LL_TIM_BDTR_Init(TIM_TypeDef *TIMx, LL_TIM_BDTR_InitTypeDef *TIM_BDTRInitStruct);
  3446. /**
  3447. * @}
  3448. */
  3449. #endif /* USE_FULL_LL_DRIVER */
  3450. /**
  3451. * @}
  3452. */
  3453. /**
  3454. * @}
  3455. */
  3456. #endif /* TIM1 || TIM2 || TIM3 || TIM4 || TIM5 || TIM6 || TIM7 || TIM8 || TIM9 || TIM10 || TIM11 || TIM12 || TIM13 || TIM14 || TIM15 || TIM16 || TIM17 */
  3457. /**
  3458. * @}
  3459. */
  3460. #ifdef __cplusplus
  3461. }
  3462. #endif
  3463. #endif /* __STM32F1xx_LL_TIM_H */
  3464. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/