py32f002b_ll_tim.h 149 KB

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