stm32f1xx_ll_tim.h 158 KB

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