stm32f1xx_ll_tim.h 160 KB

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