stm32f4xx_ll_tim.h 169 KB

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