stm32f1xx_ll_tim.h 158 KB

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