stm32f7xx_hal_tim.h 142 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415
  1. /**
  2. ******************************************************************************
  3. * @file stm32f7xx_hal_tim.h
  4. * @author MCD Application Team
  5. * @brief Header file of TIM HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32F7xx_HAL_TIM_H
  20. #define STM32F7xx_HAL_TIM_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f7xx_hal_def.h"
  26. /** @addtogroup STM32F7xx_HAL_Driver
  27. * @{
  28. */
  29. /** @addtogroup TIM
  30. * @{
  31. */
  32. /* Exported types ------------------------------------------------------------*/
  33. /** @defgroup TIM_Exported_Types TIM Exported Types
  34. * @{
  35. */
  36. /**
  37. * @brief TIM Time base Configuration Structure definition
  38. */
  39. typedef struct
  40. {
  41. uint32_t Prescaler; /*!< Specifies the prescaler value used to divide the TIM clock.
  42. This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
  43. uint32_t CounterMode; /*!< Specifies the counter mode.
  44. This parameter can be a value of @ref TIM_Counter_Mode */
  45. uint32_t Period; /*!< Specifies the period value to be loaded into the active
  46. Auto-Reload Register at the next update event.
  47. This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */
  48. uint32_t ClockDivision; /*!< Specifies the clock division.
  49. This parameter can be a value of @ref TIM_ClockDivision */
  50. uint32_t RepetitionCounter; /*!< Specifies the repetition counter value. Each time the RCR downcounter
  51. reaches zero, an update event is generated and counting restarts
  52. from the RCR value (N).
  53. This means in PWM mode that (N+1) corresponds to:
  54. - the number of PWM periods in edge-aligned mode
  55. - the number of half PWM period in center-aligned mode
  56. GP timers: this parameter must be a number between Min_Data = 0x00 and
  57. Max_Data = 0xFF.
  58. Advanced timers: this parameter must be a number between Min_Data = 0x0000 and
  59. Max_Data = 0xFFFF. */
  60. uint32_t AutoReloadPreload; /*!< Specifies the auto-reload preload.
  61. This parameter can be a value of @ref TIM_AutoReloadPreload */
  62. } TIM_Base_InitTypeDef;
  63. /**
  64. * @brief TIM Output Compare Configuration Structure definition
  65. */
  66. typedef struct
  67. {
  68. uint32_t OCMode; /*!< Specifies the TIM mode.
  69. This parameter can be a value of @ref TIM_Output_Compare_and_PWM_modes */
  70. uint32_t Pulse; /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
  71. This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
  72. uint32_t OCPolarity; /*!< Specifies the output polarity.
  73. This parameter can be a value of @ref TIM_Output_Compare_Polarity */
  74. uint32_t OCNPolarity; /*!< Specifies the complementary output polarity.
  75. This parameter can be a value of @ref TIM_Output_Compare_N_Polarity
  76. @note This parameter is valid only for timer instances supporting break feature. */
  77. uint32_t OCFastMode; /*!< Specifies the Fast mode state.
  78. This parameter can be a value of @ref TIM_Output_Fast_State
  79. @note This parameter is valid only in PWM1 and PWM2 mode. */
  80. uint32_t OCIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
  81. This parameter can be a value of @ref TIM_Output_Compare_Idle_State
  82. @note This parameter is valid only for timer instances supporting break feature. */
  83. uint32_t OCNIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
  84. This parameter can be a value of @ref TIM_Output_Compare_N_Idle_State
  85. @note This parameter is valid only for timer instances supporting break feature. */
  86. } TIM_OC_InitTypeDef;
  87. /**
  88. * @brief TIM One Pulse Mode Configuration Structure definition
  89. */
  90. typedef struct
  91. {
  92. uint32_t OCMode; /*!< Specifies the TIM mode.
  93. This parameter can be a value of @ref TIM_Output_Compare_and_PWM_modes */
  94. uint32_t Pulse; /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
  95. This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
  96. uint32_t OCPolarity; /*!< Specifies the output polarity.
  97. This parameter can be a value of @ref TIM_Output_Compare_Polarity */
  98. uint32_t OCNPolarity; /*!< Specifies the complementary output polarity.
  99. This parameter can be a value of @ref TIM_Output_Compare_N_Polarity
  100. @note This parameter is valid only for timer instances supporting break feature. */
  101. uint32_t OCIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
  102. This parameter can be a value of @ref TIM_Output_Compare_Idle_State
  103. @note This parameter is valid only for timer instances supporting break feature. */
  104. uint32_t OCNIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
  105. This parameter can be a value of @ref TIM_Output_Compare_N_Idle_State
  106. @note This parameter is valid only for timer instances supporting break feature. */
  107. uint32_t ICPolarity; /*!< Specifies the active edge of the input signal.
  108. This parameter can be a value of @ref TIM_Input_Capture_Polarity */
  109. uint32_t ICSelection; /*!< Specifies the input.
  110. This parameter can be a value of @ref TIM_Input_Capture_Selection */
  111. uint32_t ICFilter; /*!< Specifies the input capture filter.
  112. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  113. } TIM_OnePulse_InitTypeDef;
  114. /**
  115. * @brief TIM Input Capture Configuration Structure definition
  116. */
  117. typedef struct
  118. {
  119. uint32_t ICPolarity; /*!< Specifies the active edge of the input signal.
  120. This parameter can be a value of @ref TIM_Input_Capture_Polarity */
  121. uint32_t ICSelection; /*!< Specifies the input.
  122. This parameter can be a value of @ref TIM_Input_Capture_Selection */
  123. uint32_t ICPrescaler; /*!< Specifies the Input Capture Prescaler.
  124. This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
  125. uint32_t ICFilter; /*!< Specifies the input capture filter.
  126. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  127. } TIM_IC_InitTypeDef;
  128. /**
  129. * @brief TIM Encoder Configuration Structure definition
  130. */
  131. typedef struct
  132. {
  133. uint32_t EncoderMode; /*!< Specifies the active edge of the input signal.
  134. This parameter can be a value of @ref TIM_Encoder_Mode */
  135. uint32_t IC1Polarity; /*!< Specifies the active edge of the input signal.
  136. This parameter can be a value of @ref TIM_Encoder_Input_Polarity */
  137. uint32_t IC1Selection; /*!< Specifies the input.
  138. This parameter can be a value of @ref TIM_Input_Capture_Selection */
  139. uint32_t IC1Prescaler; /*!< Specifies the Input Capture Prescaler.
  140. This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
  141. uint32_t IC1Filter; /*!< Specifies the input capture filter.
  142. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  143. uint32_t IC2Polarity; /*!< Specifies the active edge of the input signal.
  144. This parameter can be a value of @ref TIM_Encoder_Input_Polarity */
  145. uint32_t IC2Selection; /*!< Specifies the input.
  146. This parameter can be a value of @ref TIM_Input_Capture_Selection */
  147. uint32_t IC2Prescaler; /*!< Specifies the Input Capture Prescaler.
  148. This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
  149. uint32_t IC2Filter; /*!< Specifies the input capture filter.
  150. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  151. } TIM_Encoder_InitTypeDef;
  152. /**
  153. * @brief Clock Configuration Handle Structure definition
  154. */
  155. typedef struct
  156. {
  157. uint32_t ClockSource; /*!< TIM clock sources
  158. This parameter can be a value of @ref TIM_Clock_Source */
  159. uint32_t ClockPolarity; /*!< TIM clock polarity
  160. This parameter can be a value of @ref TIM_Clock_Polarity */
  161. uint32_t ClockPrescaler; /*!< TIM clock prescaler
  162. This parameter can be a value of @ref TIM_Clock_Prescaler */
  163. uint32_t ClockFilter; /*!< TIM clock filter
  164. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  165. } TIM_ClockConfigTypeDef;
  166. /**
  167. * @brief TIM Clear Input Configuration Handle Structure definition
  168. */
  169. typedef struct
  170. {
  171. uint32_t ClearInputState; /*!< TIM clear Input state
  172. This parameter can be ENABLE or DISABLE */
  173. uint32_t ClearInputSource; /*!< TIM clear Input sources
  174. This parameter can be a value of @ref TIM_ClearInput_Source */
  175. uint32_t ClearInputPolarity; /*!< TIM Clear Input polarity
  176. This parameter can be a value of @ref TIM_ClearInput_Polarity */
  177. uint32_t ClearInputPrescaler; /*!< TIM Clear Input prescaler
  178. This parameter must be 0: When OCRef clear feature is used with ETR source,
  179. ETR prescaler must be off */
  180. uint32_t ClearInputFilter; /*!< TIM Clear Input filter
  181. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  182. } TIM_ClearInputConfigTypeDef;
  183. /**
  184. * @brief TIM Master configuration Structure definition
  185. * @note Advanced timers provide TRGO2 internal line which is redirected
  186. * to the ADC
  187. */
  188. typedef struct
  189. {
  190. uint32_t MasterOutputTrigger; /*!< Trigger output (TRGO) selection
  191. This parameter can be a value of @ref TIM_Master_Mode_Selection */
  192. uint32_t MasterOutputTrigger2; /*!< Trigger output2 (TRGO2) selection
  193. This parameter can be a value of @ref TIM_Master_Mode_Selection_2 */
  194. uint32_t MasterSlaveMode; /*!< Master/slave mode selection
  195. This parameter can be a value of @ref TIM_Master_Slave_Mode
  196. @note When the Master/slave mode is enabled, the effect of
  197. an event on the trigger input (TRGI) is delayed to allow a
  198. perfect synchronization between the current timer and its
  199. slaves (through TRGO). It is not mandatory in case of timer
  200. synchronization mode. */
  201. } TIM_MasterConfigTypeDef;
  202. /**
  203. * @brief TIM Slave configuration Structure definition
  204. */
  205. typedef struct
  206. {
  207. uint32_t SlaveMode; /*!< Slave mode selection
  208. This parameter can be a value of @ref TIM_Slave_Mode */
  209. uint32_t InputTrigger; /*!< Input Trigger source
  210. This parameter can be a value of @ref TIM_Trigger_Selection */
  211. uint32_t TriggerPolarity; /*!< Input Trigger polarity
  212. This parameter can be a value of @ref TIM_Trigger_Polarity */
  213. uint32_t TriggerPrescaler; /*!< Input trigger prescaler
  214. This parameter can be a value of @ref TIM_Trigger_Prescaler */
  215. uint32_t TriggerFilter; /*!< Input trigger filter
  216. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  217. } TIM_SlaveConfigTypeDef;
  218. /**
  219. * @brief TIM Break input(s) and Dead time configuration Structure definition
  220. * @note 2 break inputs can be configured (BKIN and BKIN2) with configurable
  221. * filter and polarity.
  222. */
  223. typedef struct
  224. {
  225. uint32_t OffStateRunMode; /*!< TIM off state in run mode, This parameter can be a value of @ref TIM_OSSR_Off_State_Selection_for_Run_mode_state */
  226. uint32_t OffStateIDLEMode; /*!< TIM off state in IDLE mode, This parameter can be a value of @ref TIM_OSSI_Off_State_Selection_for_Idle_mode_state */
  227. uint32_t LockLevel; /*!< TIM Lock level, This parameter can be a value of @ref TIM_Lock_level */
  228. uint32_t DeadTime; /*!< TIM dead Time, This parameter can be a number between Min_Data = 0x00 and Max_Data = 0xFF */
  229. uint32_t BreakState; /*!< TIM Break State, This parameter can be a value of @ref TIM_Break_Input_enable_disable */
  230. uint32_t BreakPolarity; /*!< TIM Break input polarity, This parameter can be a value of @ref TIM_Break_Polarity */
  231. uint32_t BreakFilter; /*!< Specifies the break input filter.This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  232. uint32_t Break2State; /*!< TIM Break2 State, This parameter can be a value of @ref TIM_Break2_Input_enable_disable */
  233. uint32_t Break2Polarity; /*!< TIM Break2 input polarity, This parameter can be a value of @ref TIM_Break2_Polarity */
  234. uint32_t Break2Filter; /*!< TIM break2 input filter.This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  235. uint32_t AutomaticOutput; /*!< TIM Automatic Output Enable state, This parameter can be a value of @ref TIM_AOE_Bit_Set_Reset */
  236. } TIM_BreakDeadTimeConfigTypeDef;
  237. /**
  238. * @brief HAL State structures definition
  239. */
  240. typedef enum
  241. {
  242. HAL_TIM_STATE_RESET = 0x00U, /*!< Peripheral not yet initialized or disabled */
  243. HAL_TIM_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
  244. HAL_TIM_STATE_BUSY = 0x02U, /*!< An internal process is ongoing */
  245. HAL_TIM_STATE_TIMEOUT = 0x03U, /*!< Timeout state */
  246. HAL_TIM_STATE_ERROR = 0x04U /*!< Reception process is ongoing */
  247. } HAL_TIM_StateTypeDef;
  248. /**
  249. * @brief TIM Channel States definition
  250. */
  251. typedef enum
  252. {
  253. HAL_TIM_CHANNEL_STATE_RESET = 0x00U, /*!< TIM Channel initial state */
  254. HAL_TIM_CHANNEL_STATE_READY = 0x01U, /*!< TIM Channel ready for use */
  255. HAL_TIM_CHANNEL_STATE_BUSY = 0x02U, /*!< An internal process is ongoing on the TIM channel */
  256. } HAL_TIM_ChannelStateTypeDef;
  257. /**
  258. * @brief DMA Burst States definition
  259. */
  260. typedef enum
  261. {
  262. HAL_DMA_BURST_STATE_RESET = 0x00U, /*!< DMA Burst initial state */
  263. HAL_DMA_BURST_STATE_READY = 0x01U, /*!< DMA Burst ready for use */
  264. HAL_DMA_BURST_STATE_BUSY = 0x02U, /*!< Ongoing DMA Burst */
  265. } HAL_TIM_DMABurstStateTypeDef;
  266. /**
  267. * @brief HAL Active channel structures definition
  268. */
  269. typedef enum
  270. {
  271. HAL_TIM_ACTIVE_CHANNEL_1 = 0x01U, /*!< The active channel is 1 */
  272. HAL_TIM_ACTIVE_CHANNEL_2 = 0x02U, /*!< The active channel is 2 */
  273. HAL_TIM_ACTIVE_CHANNEL_3 = 0x04U, /*!< The active channel is 3 */
  274. HAL_TIM_ACTIVE_CHANNEL_4 = 0x08U, /*!< The active channel is 4 */
  275. HAL_TIM_ACTIVE_CHANNEL_5 = 0x10U, /*!< The active channel is 5 */
  276. HAL_TIM_ACTIVE_CHANNEL_6 = 0x20U, /*!< The active channel is 6 */
  277. HAL_TIM_ACTIVE_CHANNEL_CLEARED = 0x00U /*!< All active channels cleared */
  278. } HAL_TIM_ActiveChannel;
  279. /**
  280. * @brief TIM Time Base Handle Structure definition
  281. */
  282. #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
  283. typedef struct __TIM_HandleTypeDef
  284. #else
  285. typedef struct
  286. #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
  287. {
  288. TIM_TypeDef *Instance; /*!< Register base address */
  289. TIM_Base_InitTypeDef Init; /*!< TIM Time Base required parameters */
  290. HAL_TIM_ActiveChannel Channel; /*!< Active channel */
  291. DMA_HandleTypeDef *hdma[7]; /*!< DMA Handlers array
  292. This array is accessed by a @ref DMA_Handle_index */
  293. HAL_LockTypeDef Lock; /*!< Locking object */
  294. __IO HAL_TIM_StateTypeDef State; /*!< TIM operation state */
  295. __IO HAL_TIM_ChannelStateTypeDef ChannelState[6]; /*!< TIM channel operation state */
  296. __IO HAL_TIM_ChannelStateTypeDef ChannelNState[4]; /*!< TIM complementary channel operation state */
  297. __IO HAL_TIM_DMABurstStateTypeDef DMABurstState; /*!< DMA burst operation state */
  298. #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
  299. void (* Base_MspInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Base Msp Init Callback */
  300. void (* Base_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Base Msp DeInit Callback */
  301. void (* IC_MspInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM IC Msp Init Callback */
  302. void (* IC_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM IC Msp DeInit Callback */
  303. void (* OC_MspInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM OC Msp Init Callback */
  304. void (* OC_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM OC Msp DeInit Callback */
  305. void (* PWM_MspInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM PWM Msp Init Callback */
  306. void (* PWM_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM PWM Msp DeInit Callback */
  307. void (* OnePulse_MspInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM One Pulse Msp Init Callback */
  308. void (* OnePulse_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM One Pulse Msp DeInit Callback */
  309. void (* Encoder_MspInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Encoder Msp Init Callback */
  310. void (* Encoder_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Encoder Msp DeInit Callback */
  311. void (* HallSensor_MspInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Hall Sensor Msp Init Callback */
  312. void (* HallSensor_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Hall Sensor Msp DeInit Callback */
  313. void (* PeriodElapsedCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Period Elapsed Callback */
  314. void (* PeriodElapsedHalfCpltCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Period Elapsed half complete Callback */
  315. void (* TriggerCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Trigger Callback */
  316. void (* TriggerHalfCpltCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Trigger half complete Callback */
  317. void (* IC_CaptureCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Input Capture Callback */
  318. void (* IC_CaptureHalfCpltCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Input Capture half complete Callback */
  319. void (* OC_DelayElapsedCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Output Compare Delay Elapsed Callback */
  320. void (* PWM_PulseFinishedCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM PWM Pulse Finished Callback */
  321. void (* PWM_PulseFinishedHalfCpltCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM PWM Pulse Finished half complete Callback */
  322. void (* ErrorCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Error Callback */
  323. void (* CommutationCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Commutation Callback */
  324. void (* CommutationHalfCpltCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Commutation half complete Callback */
  325. void (* BreakCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Break Callback */
  326. void (* Break2Callback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Break2 Callback */
  327. #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
  328. } TIM_HandleTypeDef;
  329. #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
  330. /**
  331. * @brief HAL TIM Callback ID enumeration definition
  332. */
  333. typedef enum
  334. {
  335. HAL_TIM_BASE_MSPINIT_CB_ID = 0x00U /*!< TIM Base MspInit Callback ID */
  336. , HAL_TIM_BASE_MSPDEINIT_CB_ID = 0x01U /*!< TIM Base MspDeInit Callback ID */
  337. , HAL_TIM_IC_MSPINIT_CB_ID = 0x02U /*!< TIM IC MspInit Callback ID */
  338. , HAL_TIM_IC_MSPDEINIT_CB_ID = 0x03U /*!< TIM IC MspDeInit Callback ID */
  339. , HAL_TIM_OC_MSPINIT_CB_ID = 0x04U /*!< TIM OC MspInit Callback ID */
  340. , HAL_TIM_OC_MSPDEINIT_CB_ID = 0x05U /*!< TIM OC MspDeInit Callback ID */
  341. , HAL_TIM_PWM_MSPINIT_CB_ID = 0x06U /*!< TIM PWM MspInit Callback ID */
  342. , HAL_TIM_PWM_MSPDEINIT_CB_ID = 0x07U /*!< TIM PWM MspDeInit Callback ID */
  343. , HAL_TIM_ONE_PULSE_MSPINIT_CB_ID = 0x08U /*!< TIM One Pulse MspInit Callback ID */
  344. , HAL_TIM_ONE_PULSE_MSPDEINIT_CB_ID = 0x09U /*!< TIM One Pulse MspDeInit Callback ID */
  345. , HAL_TIM_ENCODER_MSPINIT_CB_ID = 0x0AU /*!< TIM Encoder MspInit Callback ID */
  346. , HAL_TIM_ENCODER_MSPDEINIT_CB_ID = 0x0BU /*!< TIM Encoder MspDeInit Callback ID */
  347. , HAL_TIM_HALL_SENSOR_MSPINIT_CB_ID = 0x0CU /*!< TIM Hall Sensor MspDeInit Callback ID */
  348. , HAL_TIM_HALL_SENSOR_MSPDEINIT_CB_ID = 0x0DU /*!< TIM Hall Sensor MspDeInit Callback ID */
  349. , HAL_TIM_PERIOD_ELAPSED_CB_ID = 0x0EU /*!< TIM Period Elapsed Callback ID */
  350. , HAL_TIM_PERIOD_ELAPSED_HALF_CB_ID = 0x0FU /*!< TIM Period Elapsed half complete Callback ID */
  351. , HAL_TIM_TRIGGER_CB_ID = 0x10U /*!< TIM Trigger Callback ID */
  352. , HAL_TIM_TRIGGER_HALF_CB_ID = 0x11U /*!< TIM Trigger half complete Callback ID */
  353. , HAL_TIM_IC_CAPTURE_CB_ID = 0x12U /*!< TIM Input Capture Callback ID */
  354. , HAL_TIM_IC_CAPTURE_HALF_CB_ID = 0x13U /*!< TIM Input Capture half complete Callback ID */
  355. , HAL_TIM_OC_DELAY_ELAPSED_CB_ID = 0x14U /*!< TIM Output Compare Delay Elapsed Callback ID */
  356. , HAL_TIM_PWM_PULSE_FINISHED_CB_ID = 0x15U /*!< TIM PWM Pulse Finished Callback ID */
  357. , HAL_TIM_PWM_PULSE_FINISHED_HALF_CB_ID = 0x16U /*!< TIM PWM Pulse Finished half complete Callback ID */
  358. , HAL_TIM_ERROR_CB_ID = 0x17U /*!< TIM Error Callback ID */
  359. , HAL_TIM_COMMUTATION_CB_ID = 0x18U /*!< TIM Commutation Callback ID */
  360. , HAL_TIM_COMMUTATION_HALF_CB_ID = 0x19U /*!< TIM Commutation half complete Callback ID */
  361. , HAL_TIM_BREAK_CB_ID = 0x1AU /*!< TIM Break Callback ID */
  362. , HAL_TIM_BREAK2_CB_ID = 0x1BU /*!< TIM Break2 Callback ID */
  363. } HAL_TIM_CallbackIDTypeDef;
  364. /**
  365. * @brief HAL TIM Callback pointer definition
  366. */
  367. typedef void (*pTIM_CallbackTypeDef)(TIM_HandleTypeDef *htim); /*!< pointer to the TIM callback function */
  368. #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
  369. /**
  370. * @}
  371. */
  372. /* End of exported types -----------------------------------------------------*/
  373. /* Exported constants --------------------------------------------------------*/
  374. /** @defgroup TIM_Exported_Constants TIM Exported Constants
  375. * @{
  376. */
  377. /** @defgroup TIM_ClearInput_Source TIM Clear Input Source
  378. * @{
  379. */
  380. #define TIM_CLEARINPUTSOURCE_NONE 0x00000000U /*!< OCREF_CLR is disabled */
  381. #define TIM_CLEARINPUTSOURCE_ETR 0x00000001U /*!< OCREF_CLR is connected to ETRF input */
  382. /**
  383. * @}
  384. */
  385. /** @defgroup TIM_DMA_Base_address TIM DMA Base Address
  386. * @{
  387. */
  388. #define TIM_DMABASE_CR1 0x00000000U
  389. #define TIM_DMABASE_CR2 0x00000001U
  390. #define TIM_DMABASE_SMCR 0x00000002U
  391. #define TIM_DMABASE_DIER 0x00000003U
  392. #define TIM_DMABASE_SR 0x00000004U
  393. #define TIM_DMABASE_EGR 0x00000005U
  394. #define TIM_DMABASE_CCMR1 0x00000006U
  395. #define TIM_DMABASE_CCMR2 0x00000007U
  396. #define TIM_DMABASE_CCER 0x00000008U
  397. #define TIM_DMABASE_CNT 0x00000009U
  398. #define TIM_DMABASE_PSC 0x0000000AU
  399. #define TIM_DMABASE_ARR 0x0000000BU
  400. #define TIM_DMABASE_RCR 0x0000000CU
  401. #define TIM_DMABASE_CCR1 0x0000000DU
  402. #define TIM_DMABASE_CCR2 0x0000000EU
  403. #define TIM_DMABASE_CCR3 0x0000000FU
  404. #define TIM_DMABASE_CCR4 0x00000010U
  405. #define TIM_DMABASE_BDTR 0x00000011U
  406. #define TIM_DMABASE_DCR 0x00000012U
  407. #define TIM_DMABASE_DMAR 0x00000013U
  408. #define TIM_DMABASE_OR 0x00000014U
  409. #define TIM_DMABASE_CCMR3 0x00000015U
  410. #define TIM_DMABASE_CCR5 0x00000016U
  411. #define TIM_DMABASE_CCR6 0x00000017U
  412. #if defined(TIM_BREAK_INPUT_SUPPORT)
  413. #define TIM_DMABASE_AF1 0x00000018U
  414. #define TIM_DMABASE_AF2 0x00000019U
  415. #endif /* TIM_BREAK_INPUT_SUPPORT */
  416. /**
  417. * @}
  418. */
  419. /** @defgroup TIM_Event_Source TIM Event Source
  420. * @{
  421. */
  422. #define TIM_EVENTSOURCE_UPDATE TIM_EGR_UG /*!< Reinitialize the counter and generates an update of the registers */
  423. #define TIM_EVENTSOURCE_CC1 TIM_EGR_CC1G /*!< A capture/compare event is generated on channel 1 */
  424. #define TIM_EVENTSOURCE_CC2 TIM_EGR_CC2G /*!< A capture/compare event is generated on channel 2 */
  425. #define TIM_EVENTSOURCE_CC3 TIM_EGR_CC3G /*!< A capture/compare event is generated on channel 3 */
  426. #define TIM_EVENTSOURCE_CC4 TIM_EGR_CC4G /*!< A capture/compare event is generated on channel 4 */
  427. #define TIM_EVENTSOURCE_COM TIM_EGR_COMG /*!< A commutation event is generated */
  428. #define TIM_EVENTSOURCE_TRIGGER TIM_EGR_TG /*!< A trigger event is generated */
  429. #define TIM_EVENTSOURCE_BREAK TIM_EGR_BG /*!< A break event is generated */
  430. #define TIM_EVENTSOURCE_BREAK2 TIM_EGR_B2G /*!< A break 2 event is generated */
  431. /**
  432. * @}
  433. */
  434. /** @defgroup TIM_Input_Channel_Polarity TIM Input Channel polarity
  435. * @{
  436. */
  437. #define TIM_INPUTCHANNELPOLARITY_RISING 0x00000000U /*!< Polarity for TIx source */
  438. #define TIM_INPUTCHANNELPOLARITY_FALLING TIM_CCER_CC1P /*!< Polarity for TIx source */
  439. #define TIM_INPUTCHANNELPOLARITY_BOTHEDGE (TIM_CCER_CC1P | TIM_CCER_CC1NP) /*!< Polarity for TIx source */
  440. /**
  441. * @}
  442. */
  443. /** @defgroup TIM_ETR_Polarity TIM ETR Polarity
  444. * @{
  445. */
  446. #define TIM_ETRPOLARITY_INVERTED TIM_SMCR_ETP /*!< Polarity for ETR source */
  447. #define TIM_ETRPOLARITY_NONINVERTED 0x00000000U /*!< Polarity for ETR source */
  448. /**
  449. * @}
  450. */
  451. /** @defgroup TIM_ETR_Prescaler TIM ETR Prescaler
  452. * @{
  453. */
  454. #define TIM_ETRPRESCALER_DIV1 0x00000000U /*!< No prescaler is used */
  455. #define TIM_ETRPRESCALER_DIV2 TIM_SMCR_ETPS_0 /*!< ETR input source is divided by 2 */
  456. #define TIM_ETRPRESCALER_DIV4 TIM_SMCR_ETPS_1 /*!< ETR input source is divided by 4 */
  457. #define TIM_ETRPRESCALER_DIV8 TIM_SMCR_ETPS /*!< ETR input source is divided by 8 */
  458. /**
  459. * @}
  460. */
  461. /** @defgroup TIM_Counter_Mode TIM Counter Mode
  462. * @{
  463. */
  464. #define TIM_COUNTERMODE_UP 0x00000000U /*!< Counter used as up-counter */
  465. #define TIM_COUNTERMODE_DOWN TIM_CR1_DIR /*!< Counter used as down-counter */
  466. #define TIM_COUNTERMODE_CENTERALIGNED1 TIM_CR1_CMS_0 /*!< Center-aligned mode 1 */
  467. #define TIM_COUNTERMODE_CENTERALIGNED2 TIM_CR1_CMS_1 /*!< Center-aligned mode 2 */
  468. #define TIM_COUNTERMODE_CENTERALIGNED3 TIM_CR1_CMS /*!< Center-aligned mode 3 */
  469. /**
  470. * @}
  471. */
  472. /** @defgroup TIM_Update_Interrupt_Flag_Remap TIM Update Interrupt Flag Remap
  473. * @{
  474. */
  475. #define TIM_UIFREMAP_DISABLE 0x00000000U /*!< Update interrupt flag remap disabled */
  476. #define TIM_UIFREMAP_ENABLE TIM_CR1_UIFREMAP /*!< Update interrupt flag remap enabled */
  477. /**
  478. * @}
  479. */
  480. /** @defgroup TIM_ClockDivision TIM Clock Division
  481. * @{
  482. */
  483. #define TIM_CLOCKDIVISION_DIV1 0x00000000U /*!< Clock division: tDTS=tCK_INT */
  484. #define TIM_CLOCKDIVISION_DIV2 TIM_CR1_CKD_0 /*!< Clock division: tDTS=2*tCK_INT */
  485. #define TIM_CLOCKDIVISION_DIV4 TIM_CR1_CKD_1 /*!< Clock division: tDTS=4*tCK_INT */
  486. /**
  487. * @}
  488. */
  489. /** @defgroup TIM_Output_Compare_State TIM Output Compare State
  490. * @{
  491. */
  492. #define TIM_OUTPUTSTATE_DISABLE 0x00000000U /*!< Capture/Compare 1 output disabled */
  493. #define TIM_OUTPUTSTATE_ENABLE TIM_CCER_CC1E /*!< Capture/Compare 1 output enabled */
  494. /**
  495. * @}
  496. */
  497. /** @defgroup TIM_AutoReloadPreload TIM Auto-Reload Preload
  498. * @{
  499. */
  500. #define TIM_AUTORELOAD_PRELOAD_DISABLE 0x00000000U /*!< TIMx_ARR register is not buffered */
  501. #define TIM_AUTORELOAD_PRELOAD_ENABLE TIM_CR1_ARPE /*!< TIMx_ARR register is buffered */
  502. /**
  503. * @}
  504. */
  505. /** @defgroup TIM_Output_Fast_State TIM Output Fast State
  506. * @{
  507. */
  508. #define TIM_OCFAST_DISABLE 0x00000000U /*!< Output Compare fast disable */
  509. #define TIM_OCFAST_ENABLE TIM_CCMR1_OC1FE /*!< Output Compare fast enable */
  510. /**
  511. * @}
  512. */
  513. /** @defgroup TIM_Output_Compare_N_State TIM Complementary Output Compare State
  514. * @{
  515. */
  516. #define TIM_OUTPUTNSTATE_DISABLE 0x00000000U /*!< OCxN is disabled */
  517. #define TIM_OUTPUTNSTATE_ENABLE TIM_CCER_CC1NE /*!< OCxN is enabled */
  518. /**
  519. * @}
  520. */
  521. /** @defgroup TIM_Output_Compare_Polarity TIM Output Compare Polarity
  522. * @{
  523. */
  524. #define TIM_OCPOLARITY_HIGH 0x00000000U /*!< Capture/Compare output polarity */
  525. #define TIM_OCPOLARITY_LOW TIM_CCER_CC1P /*!< Capture/Compare output polarity */
  526. /**
  527. * @}
  528. */
  529. /** @defgroup TIM_Output_Compare_N_Polarity TIM Complementary Output Compare Polarity
  530. * @{
  531. */
  532. #define TIM_OCNPOLARITY_HIGH 0x00000000U /*!< Capture/Compare complementary output polarity */
  533. #define TIM_OCNPOLARITY_LOW TIM_CCER_CC1NP /*!< Capture/Compare complementary output polarity */
  534. /**
  535. * @}
  536. */
  537. /** @defgroup TIM_Output_Compare_Idle_State TIM Output Compare Idle State
  538. * @{
  539. */
  540. #define TIM_OCIDLESTATE_SET TIM_CR2_OIS1 /*!< Output Idle state: OCx=1 when MOE=0 */
  541. #define TIM_OCIDLESTATE_RESET 0x00000000U /*!< Output Idle state: OCx=0 when MOE=0 */
  542. /**
  543. * @}
  544. */
  545. /** @defgroup TIM_Output_Compare_N_Idle_State TIM Complementary Output Compare Idle State
  546. * @{
  547. */
  548. #define TIM_OCNIDLESTATE_SET TIM_CR2_OIS1N /*!< Complementary output Idle state: OCxN=1 when MOE=0 */
  549. #define TIM_OCNIDLESTATE_RESET 0x00000000U /*!< Complementary output Idle state: OCxN=0 when MOE=0 */
  550. /**
  551. * @}
  552. */
  553. /** @defgroup TIM_Input_Capture_Polarity TIM Input Capture Polarity
  554. * @{
  555. */
  556. #define TIM_ICPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING /*!< Capture triggered by rising edge on timer input */
  557. #define TIM_ICPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING /*!< Capture triggered by falling edge on timer input */
  558. #define TIM_ICPOLARITY_BOTHEDGE TIM_INPUTCHANNELPOLARITY_BOTHEDGE /*!< Capture triggered by both rising and falling edges on timer input*/
  559. /**
  560. * @}
  561. */
  562. /** @defgroup TIM_Encoder_Input_Polarity TIM Encoder Input Polarity
  563. * @{
  564. */
  565. #define TIM_ENCODERINPUTPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING /*!< Encoder input with rising edge polarity */
  566. #define TIM_ENCODERINPUTPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING /*!< Encoder input with falling edge polarity */
  567. /**
  568. * @}
  569. */
  570. /** @defgroup TIM_Input_Capture_Selection TIM Input Capture Selection
  571. * @{
  572. */
  573. #define TIM_ICSELECTION_DIRECTTI TIM_CCMR1_CC1S_0 /*!< TIM Input 1, 2, 3 or 4 is selected to be connected to IC1, IC2, IC3 or IC4, respectively */
  574. #define TIM_ICSELECTION_INDIRECTTI TIM_CCMR1_CC1S_1 /*!< TIM Input 1, 2, 3 or 4 is selected to be connected to IC2, IC1, IC4 or IC3, respectively */
  575. #define TIM_ICSELECTION_TRC TIM_CCMR1_CC1S /*!< TIM Input 1, 2, 3 or 4 is selected to be connected to TRC */
  576. /**
  577. * @}
  578. */
  579. /** @defgroup TIM_Input_Capture_Prescaler TIM Input Capture Prescaler
  580. * @{
  581. */
  582. #define TIM_ICPSC_DIV1 0x00000000U /*!< Capture performed each time an edge is detected on the capture input */
  583. #define TIM_ICPSC_DIV2 TIM_CCMR1_IC1PSC_0 /*!< Capture performed once every 2 events */
  584. #define TIM_ICPSC_DIV4 TIM_CCMR1_IC1PSC_1 /*!< Capture performed once every 4 events */
  585. #define TIM_ICPSC_DIV8 TIM_CCMR1_IC1PSC /*!< Capture performed once every 8 events */
  586. /**
  587. * @}
  588. */
  589. /** @defgroup TIM_One_Pulse_Mode TIM One Pulse Mode
  590. * @{
  591. */
  592. #define TIM_OPMODE_SINGLE TIM_CR1_OPM /*!< Counter stops counting at the next update event */
  593. #define TIM_OPMODE_REPETITIVE 0x00000000U /*!< Counter is not stopped at update event */
  594. /**
  595. * @}
  596. */
  597. /** @defgroup TIM_Encoder_Mode TIM Encoder Mode
  598. * @{
  599. */
  600. #define TIM_ENCODERMODE_TI1 TIM_SMCR_SMS_0 /*!< Quadrature encoder mode 1, x2 mode, counts up/down on TI1FP1 edge depending on TI2FP2 level */
  601. #define TIM_ENCODERMODE_TI2 TIM_SMCR_SMS_1 /*!< Quadrature encoder mode 2, x2 mode, counts up/down on TI2FP2 edge depending on TI1FP1 level. */
  602. #define TIM_ENCODERMODE_TI12 (TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0) /*!< Quadrature encoder mode 3, x4 mode, counts up/down on both TI1FP1 and TI2FP2 edges depending on the level of the other input. */
  603. /**
  604. * @}
  605. */
  606. /** @defgroup TIM_Interrupt_definition TIM interrupt Definition
  607. * @{
  608. */
  609. #define TIM_IT_UPDATE TIM_DIER_UIE /*!< Update interrupt */
  610. #define TIM_IT_CC1 TIM_DIER_CC1IE /*!< Capture/Compare 1 interrupt */
  611. #define TIM_IT_CC2 TIM_DIER_CC2IE /*!< Capture/Compare 2 interrupt */
  612. #define TIM_IT_CC3 TIM_DIER_CC3IE /*!< Capture/Compare 3 interrupt */
  613. #define TIM_IT_CC4 TIM_DIER_CC4IE /*!< Capture/Compare 4 interrupt */
  614. #define TIM_IT_COM TIM_DIER_COMIE /*!< Commutation interrupt */
  615. #define TIM_IT_TRIGGER TIM_DIER_TIE /*!< Trigger interrupt */
  616. #define TIM_IT_BREAK TIM_DIER_BIE /*!< Break interrupt */
  617. /**
  618. * @}
  619. */
  620. /** @defgroup TIM_Commutation_Source TIM Commutation Source
  621. * @{
  622. */
  623. #define TIM_COMMUTATION_TRGI TIM_CR2_CCUS /*!< When Capture/compare control bits are preloaded, they are updated by setting the COMG bit or when an rising edge occurs on trigger input */
  624. #define TIM_COMMUTATION_SOFTWARE 0x00000000U /*!< When Capture/compare control bits are preloaded, they are updated by setting the COMG bit */
  625. /**
  626. * @}
  627. */
  628. /** @defgroup TIM_DMA_sources TIM DMA Sources
  629. * @{
  630. */
  631. #define TIM_DMA_UPDATE TIM_DIER_UDE /*!< DMA request is triggered by the update event */
  632. #define TIM_DMA_CC1 TIM_DIER_CC1DE /*!< DMA request is triggered by the capture/compare macth 1 event */
  633. #define TIM_DMA_CC2 TIM_DIER_CC2DE /*!< DMA request is triggered by the capture/compare macth 2 event event */
  634. #define TIM_DMA_CC3 TIM_DIER_CC3DE /*!< DMA request is triggered by the capture/compare macth 3 event event */
  635. #define TIM_DMA_CC4 TIM_DIER_CC4DE /*!< DMA request is triggered by the capture/compare macth 4 event event */
  636. #define TIM_DMA_COM TIM_DIER_COMDE /*!< DMA request is triggered by the commutation event */
  637. #define TIM_DMA_TRIGGER TIM_DIER_TDE /*!< DMA request is triggered by the trigger event */
  638. /**
  639. * @}
  640. */
  641. /** @defgroup TIM_CC_DMA_Request CCx DMA request selection
  642. * @{
  643. */
  644. #define TIM_CCDMAREQUEST_CC 0x00000000U /*!< CCx DMA request sent when capture or compare match event occurs */
  645. #define TIM_CCDMAREQUEST_UPDATE TIM_CR2_CCDS /*!< CCx DMA requests sent when update event occurs */
  646. /**
  647. * @}
  648. */
  649. /** @defgroup TIM_Flag_definition TIM Flag Definition
  650. * @{
  651. */
  652. #define TIM_FLAG_UPDATE TIM_SR_UIF /*!< Update interrupt flag */
  653. #define TIM_FLAG_CC1 TIM_SR_CC1IF /*!< Capture/Compare 1 interrupt flag */
  654. #define TIM_FLAG_CC2 TIM_SR_CC2IF /*!< Capture/Compare 2 interrupt flag */
  655. #define TIM_FLAG_CC3 TIM_SR_CC3IF /*!< Capture/Compare 3 interrupt flag */
  656. #define TIM_FLAG_CC4 TIM_SR_CC4IF /*!< Capture/Compare 4 interrupt flag */
  657. #define TIM_FLAG_CC5 TIM_SR_CC5IF /*!< Capture/Compare 5 interrupt flag */
  658. #define TIM_FLAG_CC6 TIM_SR_CC6IF /*!< Capture/Compare 6 interrupt flag */
  659. #define TIM_FLAG_COM TIM_SR_COMIF /*!< Commutation interrupt flag */
  660. #define TIM_FLAG_TRIGGER TIM_SR_TIF /*!< Trigger interrupt flag */
  661. #define TIM_FLAG_BREAK TIM_SR_BIF /*!< Break interrupt flag */
  662. #define TIM_FLAG_BREAK2 TIM_SR_B2IF /*!< Break 2 interrupt flag */
  663. #define TIM_FLAG_SYSTEM_BREAK TIM_SR_SBIF /*!< System Break interrupt flag */
  664. #define TIM_FLAG_CC1OF TIM_SR_CC1OF /*!< Capture 1 overcapture flag */
  665. #define TIM_FLAG_CC2OF TIM_SR_CC2OF /*!< Capture 2 overcapture flag */
  666. #define TIM_FLAG_CC3OF TIM_SR_CC3OF /*!< Capture 3 overcapture flag */
  667. #define TIM_FLAG_CC4OF TIM_SR_CC4OF /*!< Capture 4 overcapture flag */
  668. /**
  669. * @}
  670. */
  671. /** @defgroup TIM_Channel TIM Channel
  672. * @{
  673. */
  674. #define TIM_CHANNEL_1 0x00000000U /*!< Capture/compare channel 1 identifier */
  675. #define TIM_CHANNEL_2 0x00000004U /*!< Capture/compare channel 2 identifier */
  676. #define TIM_CHANNEL_3 0x00000008U /*!< Capture/compare channel 3 identifier */
  677. #define TIM_CHANNEL_4 0x0000000CU /*!< Capture/compare channel 4 identifier */
  678. #define TIM_CHANNEL_5 0x00000010U /*!< Compare channel 5 identifier */
  679. #define TIM_CHANNEL_6 0x00000014U /*!< Compare channel 6 identifier */
  680. #define TIM_CHANNEL_ALL 0x0000003CU /*!< Global Capture/compare channel identifier */
  681. /**
  682. * @}
  683. */
  684. /** @defgroup TIM_Clock_Source TIM Clock Source
  685. * @{
  686. */
  687. #define TIM_CLOCKSOURCE_INTERNAL TIM_SMCR_ETPS_0 /*!< Internal clock source */
  688. #define TIM_CLOCKSOURCE_ETRMODE1 TIM_TS_ETRF /*!< External clock source mode 1 (ETRF) */
  689. #define TIM_CLOCKSOURCE_ETRMODE2 TIM_SMCR_ETPS_1 /*!< External clock source mode 2 */
  690. #define TIM_CLOCKSOURCE_TI1ED TIM_TS_TI1F_ED /*!< External clock source mode 1 (TTI1FP1 + edge detect.) */
  691. #define TIM_CLOCKSOURCE_TI1 TIM_TS_TI1FP1 /*!< External clock source mode 1 (TTI1FP1) */
  692. #define TIM_CLOCKSOURCE_TI2 TIM_TS_TI2FP2 /*!< External clock source mode 1 (TTI2FP2) */
  693. #define TIM_CLOCKSOURCE_ITR0 TIM_TS_ITR0 /*!< External clock source mode 1 (ITR0) */
  694. #define TIM_CLOCKSOURCE_ITR1 TIM_TS_ITR1 /*!< External clock source mode 1 (ITR1) */
  695. #define TIM_CLOCKSOURCE_ITR2 TIM_TS_ITR2 /*!< External clock source mode 1 (ITR2) */
  696. #define TIM_CLOCKSOURCE_ITR3 TIM_TS_ITR3 /*!< External clock source mode 1 (ITR3) */
  697. /**
  698. * @}
  699. */
  700. /** @defgroup TIM_Clock_Polarity TIM Clock Polarity
  701. * @{
  702. */
  703. #define TIM_CLOCKPOLARITY_INVERTED TIM_ETRPOLARITY_INVERTED /*!< Polarity for ETRx clock sources */
  704. #define TIM_CLOCKPOLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED /*!< Polarity for ETRx clock sources */
  705. #define TIM_CLOCKPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING /*!< Polarity for TIx clock sources */
  706. #define TIM_CLOCKPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING /*!< Polarity for TIx clock sources */
  707. #define TIM_CLOCKPOLARITY_BOTHEDGE TIM_INPUTCHANNELPOLARITY_BOTHEDGE /*!< Polarity for TIx clock sources */
  708. /**
  709. * @}
  710. */
  711. /** @defgroup TIM_Clock_Prescaler TIM Clock Prescaler
  712. * @{
  713. */
  714. #define TIM_CLOCKPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1 /*!< No prescaler is used */
  715. #define TIM_CLOCKPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2 /*!< Prescaler for External ETR Clock: Capture performed once every 2 events. */
  716. #define TIM_CLOCKPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4 /*!< Prescaler for External ETR Clock: Capture performed once every 4 events. */
  717. #define TIM_CLOCKPRESCALER_DIV8 TIM_ETRPRESCALER_DIV8 /*!< Prescaler for External ETR Clock: Capture performed once every 8 events. */
  718. /**
  719. * @}
  720. */
  721. /** @defgroup TIM_ClearInput_Polarity TIM Clear Input Polarity
  722. * @{
  723. */
  724. #define TIM_CLEARINPUTPOLARITY_INVERTED TIM_ETRPOLARITY_INVERTED /*!< Polarity for ETRx pin */
  725. #define TIM_CLEARINPUTPOLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED /*!< Polarity for ETRx pin */
  726. /**
  727. * @}
  728. */
  729. /** @defgroup TIM_ClearInput_Prescaler TIM Clear Input Prescaler
  730. * @{
  731. */
  732. #define TIM_CLEARINPUTPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1 /*!< No prescaler is used */
  733. #define TIM_CLEARINPUTPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2 /*!< Prescaler for External ETR pin: Capture performed once every 2 events. */
  734. #define TIM_CLEARINPUTPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4 /*!< Prescaler for External ETR pin: Capture performed once every 4 events. */
  735. #define TIM_CLEARINPUTPRESCALER_DIV8 TIM_ETRPRESCALER_DIV8 /*!< Prescaler for External ETR pin: Capture performed once every 8 events. */
  736. /**
  737. * @}
  738. */
  739. /** @defgroup TIM_OSSR_Off_State_Selection_for_Run_mode_state TIM OSSR OffState Selection for Run mode state
  740. * @{
  741. */
  742. #define TIM_OSSR_ENABLE TIM_BDTR_OSSR /*!< When inactive, OC/OCN outputs are enabled (still controlled by the timer) */
  743. #define TIM_OSSR_DISABLE 0x00000000U /*!< When inactive, OC/OCN outputs are disabled (not controlled any longer by the timer) */
  744. /**
  745. * @}
  746. */
  747. /** @defgroup TIM_OSSI_Off_State_Selection_for_Idle_mode_state TIM OSSI OffState Selection for Idle mode state
  748. * @{
  749. */
  750. #define TIM_OSSI_ENABLE TIM_BDTR_OSSI /*!< When inactive, OC/OCN outputs are enabled (still controlled by the timer) */
  751. #define TIM_OSSI_DISABLE 0x00000000U /*!< When inactive, OC/OCN outputs are disabled (not controlled any longer by the timer) */
  752. /**
  753. * @}
  754. */
  755. /** @defgroup TIM_Lock_level TIM Lock level
  756. * @{
  757. */
  758. #define TIM_LOCKLEVEL_OFF 0x00000000U /*!< LOCK OFF */
  759. #define TIM_LOCKLEVEL_1 TIM_BDTR_LOCK_0 /*!< LOCK Level 1 */
  760. #define TIM_LOCKLEVEL_2 TIM_BDTR_LOCK_1 /*!< LOCK Level 2 */
  761. #define TIM_LOCKLEVEL_3 TIM_BDTR_LOCK /*!< LOCK Level 3 */
  762. /**
  763. * @}
  764. */
  765. /** @defgroup TIM_Break_Input_enable_disable TIM Break Input Enable
  766. * @{
  767. */
  768. #define TIM_BREAK_ENABLE TIM_BDTR_BKE /*!< Break input BRK is enabled */
  769. #define TIM_BREAK_DISABLE 0x00000000U /*!< Break input BRK is disabled */
  770. /**
  771. * @}
  772. */
  773. /** @defgroup TIM_Break_Polarity TIM Break Input Polarity
  774. * @{
  775. */
  776. #define TIM_BREAKPOLARITY_LOW 0x00000000U /*!< Break input BRK is active low */
  777. #define TIM_BREAKPOLARITY_HIGH TIM_BDTR_BKP /*!< Break input BRK is active high */
  778. /**
  779. * @}
  780. */
  781. /** @defgroup TIM_Break2_Input_enable_disable TIM Break input 2 Enable
  782. * @{
  783. */
  784. #define TIM_BREAK2_DISABLE 0x00000000U /*!< Break input BRK2 is disabled */
  785. #define TIM_BREAK2_ENABLE TIM_BDTR_BK2E /*!< Break input BRK2 is enabled */
  786. /**
  787. * @}
  788. */
  789. /** @defgroup TIM_Break2_Polarity TIM Break Input 2 Polarity
  790. * @{
  791. */
  792. #define TIM_BREAK2POLARITY_LOW 0x00000000U /*!< Break input BRK2 is active low */
  793. #define TIM_BREAK2POLARITY_HIGH TIM_BDTR_BK2P /*!< Break input BRK2 is active high */
  794. /**
  795. * @}
  796. */
  797. /** @defgroup TIM_AOE_Bit_Set_Reset TIM Automatic Output Enable
  798. * @{
  799. */
  800. #define TIM_AUTOMATICOUTPUT_DISABLE 0x00000000U /*!< MOE can be set only by software */
  801. #define TIM_AUTOMATICOUTPUT_ENABLE TIM_BDTR_AOE /*!< MOE can be set by software or automatically at the next update event (if none of the break inputs BRK and BRK2 is active) */
  802. /**
  803. * @}
  804. */
  805. /** @defgroup TIM_Group_Channel5 TIM Group Channel 5 and Channel 1, 2 or 3
  806. * @{
  807. */
  808. #define TIM_GROUPCH5_NONE 0x00000000U /*!< No effect of OC5REF on OC1REFC, OC2REFC and OC3REFC */
  809. #define TIM_GROUPCH5_OC1REFC TIM_CCR5_GC5C1 /*!< OC1REFC is the logical AND of OC1REFC and OC5REF */
  810. #define TIM_GROUPCH5_OC2REFC TIM_CCR5_GC5C2 /*!< OC2REFC is the logical AND of OC2REFC and OC5REF */
  811. #define TIM_GROUPCH5_OC3REFC TIM_CCR5_GC5C3 /*!< OC3REFC is the logical AND of OC3REFC and OC5REF */
  812. /**
  813. * @}
  814. */
  815. /** @defgroup TIM_Master_Mode_Selection TIM Master Mode Selection
  816. * @{
  817. */
  818. #define TIM_TRGO_RESET 0x00000000U /*!< TIMx_EGR.UG bit is used as trigger output (TRGO) */
  819. #define TIM_TRGO_ENABLE TIM_CR2_MMS_0 /*!< TIMx_CR1.CEN bit is used as trigger output (TRGO) */
  820. #define TIM_TRGO_UPDATE TIM_CR2_MMS_1 /*!< Update event is used as trigger output (TRGO) */
  821. #define TIM_TRGO_OC1 (TIM_CR2_MMS_1 | TIM_CR2_MMS_0) /*!< Capture or a compare match 1 is used as trigger output (TRGO) */
  822. #define TIM_TRGO_OC1REF TIM_CR2_MMS_2 /*!< OC1REF signal is used as trigger output (TRGO) */
  823. #define TIM_TRGO_OC2REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_0) /*!< OC2REF signal is used as trigger output(TRGO) */
  824. #define TIM_TRGO_OC3REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_1) /*!< OC3REF signal is used as trigger output(TRGO) */
  825. #define TIM_TRGO_OC4REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_1 | TIM_CR2_MMS_0) /*!< OC4REF signal is used as trigger output(TRGO) */
  826. /**
  827. * @}
  828. */
  829. /** @defgroup TIM_Master_Mode_Selection_2 TIM Master Mode Selection 2 (TRGO2)
  830. * @{
  831. */
  832. #define TIM_TRGO2_RESET 0x00000000U /*!< TIMx_EGR.UG bit is used as trigger output (TRGO2) */
  833. #define TIM_TRGO2_ENABLE TIM_CR2_MMS2_0 /*!< TIMx_CR1.CEN bit is used as trigger output (TRGO2) */
  834. #define TIM_TRGO2_UPDATE TIM_CR2_MMS2_1 /*!< Update event is used as trigger output (TRGO2) */
  835. #define TIM_TRGO2_OC1 (TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< Capture or a compare match 1 is used as trigger output (TRGO2) */
  836. #define TIM_TRGO2_OC1REF TIM_CR2_MMS2_2 /*!< OC1REF signal is used as trigger output (TRGO2) */
  837. #define TIM_TRGO2_OC2REF (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_0) /*!< OC2REF signal is used as trigger output (TRGO2) */
  838. #define TIM_TRGO2_OC3REF (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1) /*!< OC3REF signal is used as trigger output (TRGO2) */
  839. #define TIM_TRGO2_OC4REF (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< OC4REF signal is used as trigger output (TRGO2) */
  840. #define TIM_TRGO2_OC5REF TIM_CR2_MMS2_3 /*!< OC5REF signal is used as trigger output (TRGO2) */
  841. #define TIM_TRGO2_OC6REF (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_0) /*!< OC6REF signal is used as trigger output (TRGO2) */
  842. #define TIM_TRGO2_OC4REF_RISINGFALLING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_1) /*!< OC4REF rising or falling edges generate pulses on TRGO2 */
  843. #define TIM_TRGO2_OC6REF_RISINGFALLING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< OC6REF rising or falling edges generate pulses on TRGO2 */
  844. #define TIM_TRGO2_OC4REF_RISING_OC6REF_RISING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2) /*!< OC4REF or OC6REF rising edges generate pulses on TRGO2 */
  845. #define TIM_TRGO2_OC4REF_RISING_OC6REF_FALLING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2 | TIM_CR2_MMS2_0) /*!< OC4REF rising or OC6REF falling edges generate pulses on TRGO2 */
  846. #define TIM_TRGO2_OC5REF_RISING_OC6REF_RISING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2 |TIM_CR2_MMS2_1) /*!< OC5REF or OC6REF rising edges generate pulses on TRGO2 */
  847. #define TIM_TRGO2_OC5REF_RISING_OC6REF_FALLING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< OC5REF or OC6REF rising edges generate pulses on TRGO2 */
  848. /**
  849. * @}
  850. */
  851. /** @defgroup TIM_Master_Slave_Mode TIM Master/Slave Mode
  852. * @{
  853. */
  854. #define TIM_MASTERSLAVEMODE_ENABLE TIM_SMCR_MSM /*!< No action */
  855. #define TIM_MASTERSLAVEMODE_DISABLE 0x00000000U /*!< Master/slave mode is selected */
  856. /**
  857. * @}
  858. */
  859. /** @defgroup TIM_Slave_Mode TIM Slave mode
  860. * @{
  861. */
  862. #define TIM_SLAVEMODE_DISABLE 0x00000000U /*!< Slave mode disabled */
  863. #define TIM_SLAVEMODE_RESET TIM_SMCR_SMS_2 /*!< Reset Mode */
  864. #define TIM_SLAVEMODE_GATED (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_0) /*!< Gated Mode */
  865. #define TIM_SLAVEMODE_TRIGGER (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1) /*!< Trigger Mode */
  866. #define TIM_SLAVEMODE_EXTERNAL1 (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0) /*!< External Clock Mode 1 */
  867. #define TIM_SLAVEMODE_COMBINED_RESETTRIGGER TIM_SMCR_SMS_3 /*!< Combined reset + trigger mode */
  868. /**
  869. * @}
  870. */
  871. /** @defgroup TIM_Output_Compare_and_PWM_modes TIM Output Compare and PWM Modes
  872. * @{
  873. */
  874. #define TIM_OCMODE_TIMING 0x00000000U /*!< Frozen */
  875. #define TIM_OCMODE_ACTIVE TIM_CCMR1_OC1M_0 /*!< Set channel to active level on match */
  876. #define TIM_OCMODE_INACTIVE TIM_CCMR1_OC1M_1 /*!< Set channel to inactive level on match */
  877. #define TIM_OCMODE_TOGGLE (TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0) /*!< Toggle */
  878. #define TIM_OCMODE_PWM1 (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1) /*!< PWM mode 1 */
  879. #define TIM_OCMODE_PWM2 (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0) /*!< PWM mode 2 */
  880. #define TIM_OCMODE_FORCED_ACTIVE (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_0) /*!< Force active level */
  881. #define TIM_OCMODE_FORCED_INACTIVE TIM_CCMR1_OC1M_2 /*!< Force inactive level */
  882. #define TIM_OCMODE_RETRIGERRABLE_OPM1 TIM_CCMR1_OC1M_3 /*!< Retrigerrable OPM mode 1 */
  883. #define TIM_OCMODE_RETRIGERRABLE_OPM2 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_0) /*!< Retrigerrable OPM mode 2 */
  884. #define TIM_OCMODE_COMBINED_PWM1 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_2) /*!< Combined PWM mode 1 */
  885. #define TIM_OCMODE_COMBINED_PWM2 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_0 | TIM_CCMR1_OC1M_2) /*!< Combined PWM mode 2 */
  886. #define TIM_OCMODE_ASSYMETRIC_PWM1 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2) /*!< Asymmetric PWM mode 1 */
  887. #define TIM_OCMODE_ASSYMETRIC_PWM2 TIM_CCMR1_OC1M /*!< Asymmetric PWM mode 2 */
  888. /**
  889. * @}
  890. */
  891. /** @defgroup TIM_Trigger_Selection TIM Trigger Selection
  892. * @{
  893. */
  894. #define TIM_TS_ITR0 0x00000000U /*!< Internal Trigger 0 (ITR0) */
  895. #define TIM_TS_ITR1 TIM_SMCR_TS_0 /*!< Internal Trigger 1 (ITR1) */
  896. #define TIM_TS_ITR2 TIM_SMCR_TS_1 /*!< Internal Trigger 2 (ITR2) */
  897. #define TIM_TS_ITR3 (TIM_SMCR_TS_0 | TIM_SMCR_TS_1) /*!< Internal Trigger 3 (ITR3) */
  898. #define TIM_TS_TI1F_ED TIM_SMCR_TS_2 /*!< TI1 Edge Detector (TI1F_ED) */
  899. #define TIM_TS_TI1FP1 (TIM_SMCR_TS_0 | TIM_SMCR_TS_2) /*!< Filtered Timer Input 1 (TI1FP1) */
  900. #define TIM_TS_TI2FP2 (TIM_SMCR_TS_1 | TIM_SMCR_TS_2) /*!< Filtered Timer Input 2 (TI2FP2) */
  901. #define TIM_TS_ETRF (TIM_SMCR_TS_0 | TIM_SMCR_TS_1 | TIM_SMCR_TS_2) /*!< Filtered External Trigger input (ETRF) */
  902. #define TIM_TS_NONE 0x0000FFFFU /*!< No trigger selected */
  903. /**
  904. * @}
  905. */
  906. /** @defgroup TIM_Trigger_Polarity TIM Trigger Polarity
  907. * @{
  908. */
  909. #define TIM_TRIGGERPOLARITY_INVERTED TIM_ETRPOLARITY_INVERTED /*!< Polarity for ETRx trigger sources */
  910. #define TIM_TRIGGERPOLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED /*!< Polarity for ETRx trigger sources */
  911. #define TIM_TRIGGERPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING /*!< Polarity for TIxFPx or TI1_ED trigger sources */
  912. #define TIM_TRIGGERPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING /*!< Polarity for TIxFPx or TI1_ED trigger sources */
  913. #define TIM_TRIGGERPOLARITY_BOTHEDGE TIM_INPUTCHANNELPOLARITY_BOTHEDGE /*!< Polarity for TIxFPx or TI1_ED trigger sources */
  914. /**
  915. * @}
  916. */
  917. /** @defgroup TIM_Trigger_Prescaler TIM Trigger Prescaler
  918. * @{
  919. */
  920. #define TIM_TRIGGERPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1 /*!< No prescaler is used */
  921. #define TIM_TRIGGERPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2 /*!< Prescaler for External ETR Trigger: Capture performed once every 2 events. */
  922. #define TIM_TRIGGERPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4 /*!< Prescaler for External ETR Trigger: Capture performed once every 4 events. */
  923. #define TIM_TRIGGERPRESCALER_DIV8 TIM_ETRPRESCALER_DIV8 /*!< Prescaler for External ETR Trigger: Capture performed once every 8 events. */
  924. /**
  925. * @}
  926. */
  927. /** @defgroup TIM_TI1_Selection TIM TI1 Input Selection
  928. * @{
  929. */
  930. #define TIM_TI1SELECTION_CH1 0x00000000U /*!< The TIMx_CH1 pin is connected to TI1 input */
  931. #define TIM_TI1SELECTION_XORCOMBINATION TIM_CR2_TI1S /*!< The TIMx_CH1, CH2 and CH3 pins are connected to the TI1 input (XOR combination) */
  932. /**
  933. * @}
  934. */
  935. /** @defgroup TIM_DMA_Burst_Length TIM DMA Burst Length
  936. * @{
  937. */
  938. #define TIM_DMABURSTLENGTH_1TRANSFER 0x00000000U /*!< The transfer is done to 1 register starting from TIMx_CR1 + TIMx_DCR.DBA */
  939. #define TIM_DMABURSTLENGTH_2TRANSFERS 0x00000100U /*!< The transfer is done to 2 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  940. #define TIM_DMABURSTLENGTH_3TRANSFERS 0x00000200U /*!< The transfer is done to 3 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  941. #define TIM_DMABURSTLENGTH_4TRANSFERS 0x00000300U /*!< The transfer is done to 4 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  942. #define TIM_DMABURSTLENGTH_5TRANSFERS 0x00000400U /*!< The transfer is done to 5 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  943. #define TIM_DMABURSTLENGTH_6TRANSFERS 0x00000500U /*!< The transfer is done to 6 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  944. #define TIM_DMABURSTLENGTH_7TRANSFERS 0x00000600U /*!< The transfer is done to 7 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  945. #define TIM_DMABURSTLENGTH_8TRANSFERS 0x00000700U /*!< The transfer is done to 8 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  946. #define TIM_DMABURSTLENGTH_9TRANSFERS 0x00000800U /*!< The transfer is done to 9 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  947. #define TIM_DMABURSTLENGTH_10TRANSFERS 0x00000900U /*!< The transfer is done to 10 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  948. #define TIM_DMABURSTLENGTH_11TRANSFERS 0x00000A00U /*!< The transfer is done to 11 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  949. #define TIM_DMABURSTLENGTH_12TRANSFERS 0x00000B00U /*!< The transfer is done to 12 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  950. #define TIM_DMABURSTLENGTH_13TRANSFERS 0x00000C00U /*!< The transfer is done to 13 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  951. #define TIM_DMABURSTLENGTH_14TRANSFERS 0x00000D00U /*!< The transfer is done to 14 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  952. #define TIM_DMABURSTLENGTH_15TRANSFERS 0x00000E00U /*!< The transfer is done to 15 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  953. #define TIM_DMABURSTLENGTH_16TRANSFERS 0x00000F00U /*!< The transfer is done to 16 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  954. #define TIM_DMABURSTLENGTH_17TRANSFERS 0x00001000U /*!< The transfer is done to 17 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  955. #define TIM_DMABURSTLENGTH_18TRANSFERS 0x00001100U /*!< The transfer is done to 18 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  956. /**
  957. * @}
  958. */
  959. /** @defgroup DMA_Handle_index TIM DMA Handle Index
  960. * @{
  961. */
  962. #define TIM_DMA_ID_UPDATE ((uint16_t) 0x0000) /*!< Index of the DMA handle used for Update DMA requests */
  963. #define TIM_DMA_ID_CC1 ((uint16_t) 0x0001) /*!< Index of the DMA handle used for Capture/Compare 1 DMA requests */
  964. #define TIM_DMA_ID_CC2 ((uint16_t) 0x0002) /*!< Index of the DMA handle used for Capture/Compare 2 DMA requests */
  965. #define TIM_DMA_ID_CC3 ((uint16_t) 0x0003) /*!< Index of the DMA handle used for Capture/Compare 3 DMA requests */
  966. #define TIM_DMA_ID_CC4 ((uint16_t) 0x0004) /*!< Index of the DMA handle used for Capture/Compare 4 DMA requests */
  967. #define TIM_DMA_ID_COMMUTATION ((uint16_t) 0x0005) /*!< Index of the DMA handle used for Commutation DMA requests */
  968. #define TIM_DMA_ID_TRIGGER ((uint16_t) 0x0006) /*!< Index of the DMA handle used for Trigger DMA requests */
  969. /**
  970. * @}
  971. */
  972. /** @defgroup Channel_CC_State TIM Capture/Compare Channel State
  973. * @{
  974. */
  975. #define TIM_CCx_ENABLE 0x00000001U /*!< Input or output channel is enabled */
  976. #define TIM_CCx_DISABLE 0x00000000U /*!< Input or output channel is disabled */
  977. #define TIM_CCxN_ENABLE 0x00000004U /*!< Complementary output channel is enabled */
  978. #define TIM_CCxN_DISABLE 0x00000000U /*!< Complementary output channel is enabled */
  979. /**
  980. * @}
  981. */
  982. /** @defgroup TIM_Break_System TIM Break System
  983. * @{
  984. */
  985. #define TIM_BREAK_SYSTEM_ECC SYSCFG_CFGR2_ECCL /*!< Enables and locks the ECC error signal with Break Input of TIM1/8/15/16/17 */
  986. #define TIM_BREAK_SYSTEM_PVD SYSCFG_CFGR2_PVDL /*!< Enables and locks the PVD connection with TIM1/8/15/16/17 Break Input and also the PVDE and PLS bits of the Power Control Interface */
  987. #define TIM_BREAK_SYSTEM_SRAM_PARITY_ERROR SYSCFG_CFGR2_SPL /*!< Enables and locks the SRAM_PARITY error signal with Break Input of TIM1/8/15/16/17 */
  988. #define TIM_BREAK_SYSTEM_LOCKUP SYSCFG_CFGR2_CLL /*!< Enables and locks the LOCKUP output of CortexM4 with Break Input of TIM1/8/15/16/17 */
  989. /**
  990. * @}
  991. */
  992. /**
  993. * @}
  994. */
  995. /* End of exported constants -------------------------------------------------*/
  996. /* Exported macros -----------------------------------------------------------*/
  997. /** @defgroup TIM_Exported_Macros TIM Exported Macros
  998. * @{
  999. */
  1000. /** @brief Reset TIM handle state.
  1001. * @param __HANDLE__ TIM handle.
  1002. * @retval None
  1003. */
  1004. #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
  1005. #define __HAL_TIM_RESET_HANDLE_STATE(__HANDLE__) do { \
  1006. (__HANDLE__)->State = HAL_TIM_STATE_RESET; \
  1007. (__HANDLE__)->ChannelState[0] = HAL_TIM_CHANNEL_STATE_RESET; \
  1008. (__HANDLE__)->ChannelState[1] = HAL_TIM_CHANNEL_STATE_RESET; \
  1009. (__HANDLE__)->ChannelState[2] = HAL_TIM_CHANNEL_STATE_RESET; \
  1010. (__HANDLE__)->ChannelState[3] = HAL_TIM_CHANNEL_STATE_RESET; \
  1011. (__HANDLE__)->ChannelState[4] = HAL_TIM_CHANNEL_STATE_RESET; \
  1012. (__HANDLE__)->ChannelState[5] = HAL_TIM_CHANNEL_STATE_RESET; \
  1013. (__HANDLE__)->ChannelNState[0] = HAL_TIM_CHANNEL_STATE_RESET; \
  1014. (__HANDLE__)->ChannelNState[1] = HAL_TIM_CHANNEL_STATE_RESET; \
  1015. (__HANDLE__)->ChannelNState[2] = HAL_TIM_CHANNEL_STATE_RESET; \
  1016. (__HANDLE__)->ChannelNState[3] = HAL_TIM_CHANNEL_STATE_RESET; \
  1017. (__HANDLE__)->DMABurstState = HAL_DMA_BURST_STATE_RESET; \
  1018. (__HANDLE__)->Base_MspInitCallback = NULL; \
  1019. (__HANDLE__)->Base_MspDeInitCallback = NULL; \
  1020. (__HANDLE__)->IC_MspInitCallback = NULL; \
  1021. (__HANDLE__)->IC_MspDeInitCallback = NULL; \
  1022. (__HANDLE__)->OC_MspInitCallback = NULL; \
  1023. (__HANDLE__)->OC_MspDeInitCallback = NULL; \
  1024. (__HANDLE__)->PWM_MspInitCallback = NULL; \
  1025. (__HANDLE__)->PWM_MspDeInitCallback = NULL; \
  1026. (__HANDLE__)->OnePulse_MspInitCallback = NULL; \
  1027. (__HANDLE__)->OnePulse_MspDeInitCallback = NULL; \
  1028. (__HANDLE__)->Encoder_MspInitCallback = NULL; \
  1029. (__HANDLE__)->Encoder_MspDeInitCallback = NULL; \
  1030. (__HANDLE__)->HallSensor_MspInitCallback = NULL; \
  1031. (__HANDLE__)->HallSensor_MspDeInitCallback = NULL; \
  1032. } while(0)
  1033. #else
  1034. #define __HAL_TIM_RESET_HANDLE_STATE(__HANDLE__) do { \
  1035. (__HANDLE__)->State = HAL_TIM_STATE_RESET; \
  1036. (__HANDLE__)->ChannelState[0] = HAL_TIM_CHANNEL_STATE_RESET; \
  1037. (__HANDLE__)->ChannelState[1] = HAL_TIM_CHANNEL_STATE_RESET; \
  1038. (__HANDLE__)->ChannelState[2] = HAL_TIM_CHANNEL_STATE_RESET; \
  1039. (__HANDLE__)->ChannelState[3] = HAL_TIM_CHANNEL_STATE_RESET; \
  1040. (__HANDLE__)->ChannelState[4] = HAL_TIM_CHANNEL_STATE_RESET; \
  1041. (__HANDLE__)->ChannelState[5] = HAL_TIM_CHANNEL_STATE_RESET; \
  1042. (__HANDLE__)->ChannelNState[0] = HAL_TIM_CHANNEL_STATE_RESET; \
  1043. (__HANDLE__)->ChannelNState[1] = HAL_TIM_CHANNEL_STATE_RESET; \
  1044. (__HANDLE__)->ChannelNState[2] = HAL_TIM_CHANNEL_STATE_RESET; \
  1045. (__HANDLE__)->ChannelNState[3] = HAL_TIM_CHANNEL_STATE_RESET; \
  1046. (__HANDLE__)->DMABurstState = HAL_DMA_BURST_STATE_RESET; \
  1047. } while(0)
  1048. #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
  1049. /**
  1050. * @brief Enable the TIM peripheral.
  1051. * @param __HANDLE__ TIM handle
  1052. * @retval None
  1053. */
  1054. #define __HAL_TIM_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1|=(TIM_CR1_CEN))
  1055. /**
  1056. * @brief Enable the TIM main Output.
  1057. * @param __HANDLE__ TIM handle
  1058. * @retval None
  1059. */
  1060. #define __HAL_TIM_MOE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->BDTR|=(TIM_BDTR_MOE))
  1061. /**
  1062. * @brief Disable the TIM peripheral.
  1063. * @param __HANDLE__ TIM handle
  1064. * @retval None
  1065. */
  1066. #define __HAL_TIM_DISABLE(__HANDLE__) \
  1067. do { \
  1068. if (((__HANDLE__)->Instance->CCER & TIM_CCER_CCxE_MASK) == 0UL) \
  1069. { \
  1070. if(((__HANDLE__)->Instance->CCER & TIM_CCER_CCxNE_MASK) == 0UL) \
  1071. { \
  1072. (__HANDLE__)->Instance->CR1 &= ~(TIM_CR1_CEN); \
  1073. } \
  1074. } \
  1075. } while(0)
  1076. /**
  1077. * @brief Disable the TIM main Output.
  1078. * @param __HANDLE__ TIM handle
  1079. * @retval None
  1080. * @note The Main Output Enable of a timer instance is disabled only if all the CCx and CCxN channels have been
  1081. * disabled
  1082. */
  1083. #define __HAL_TIM_MOE_DISABLE(__HANDLE__) \
  1084. do { \
  1085. if (((__HANDLE__)->Instance->CCER & TIM_CCER_CCxE_MASK) == 0UL) \
  1086. { \
  1087. if(((__HANDLE__)->Instance->CCER & TIM_CCER_CCxNE_MASK) == 0UL) \
  1088. { \
  1089. (__HANDLE__)->Instance->BDTR &= ~(TIM_BDTR_MOE); \
  1090. } \
  1091. } \
  1092. } while(0)
  1093. /**
  1094. * @brief Disable the TIM main Output.
  1095. * @param __HANDLE__ TIM handle
  1096. * @retval None
  1097. * @note The Main Output Enable of a timer instance is disabled unconditionally
  1098. */
  1099. #define __HAL_TIM_MOE_DISABLE_UNCONDITIONALLY(__HANDLE__) (__HANDLE__)->Instance->BDTR &= ~(TIM_BDTR_MOE)
  1100. /** @brief Enable the specified TIM interrupt.
  1101. * @param __HANDLE__ specifies the TIM Handle.
  1102. * @param __INTERRUPT__ specifies the TIM interrupt source to enable.
  1103. * This parameter can be one of the following values:
  1104. * @arg TIM_IT_UPDATE: Update interrupt
  1105. * @arg TIM_IT_CC1: Capture/Compare 1 interrupt
  1106. * @arg TIM_IT_CC2: Capture/Compare 2 interrupt
  1107. * @arg TIM_IT_CC3: Capture/Compare 3 interrupt
  1108. * @arg TIM_IT_CC4: Capture/Compare 4 interrupt
  1109. * @arg TIM_IT_COM: Commutation interrupt
  1110. * @arg TIM_IT_TRIGGER: Trigger interrupt
  1111. * @arg TIM_IT_BREAK: Break interrupt
  1112. * @retval None
  1113. */
  1114. #define __HAL_TIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DIER |= (__INTERRUPT__))
  1115. /** @brief Disable the specified TIM interrupt.
  1116. * @param __HANDLE__ specifies the TIM Handle.
  1117. * @param __INTERRUPT__ specifies the TIM interrupt source to disable.
  1118. * This parameter can be one of the following values:
  1119. * @arg TIM_IT_UPDATE: Update interrupt
  1120. * @arg TIM_IT_CC1: Capture/Compare 1 interrupt
  1121. * @arg TIM_IT_CC2: Capture/Compare 2 interrupt
  1122. * @arg TIM_IT_CC3: Capture/Compare 3 interrupt
  1123. * @arg TIM_IT_CC4: Capture/Compare 4 interrupt
  1124. * @arg TIM_IT_COM: Commutation interrupt
  1125. * @arg TIM_IT_TRIGGER: Trigger interrupt
  1126. * @arg TIM_IT_BREAK: Break interrupt
  1127. * @retval None
  1128. */
  1129. #define __HAL_TIM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DIER &= ~(__INTERRUPT__))
  1130. /** @brief Enable the specified DMA request.
  1131. * @param __HANDLE__ specifies the TIM Handle.
  1132. * @param __DMA__ specifies the TIM DMA request to enable.
  1133. * This parameter can be one of the following values:
  1134. * @arg TIM_DMA_UPDATE: Update DMA request
  1135. * @arg TIM_DMA_CC1: Capture/Compare 1 DMA request
  1136. * @arg TIM_DMA_CC2: Capture/Compare 2 DMA request
  1137. * @arg TIM_DMA_CC3: Capture/Compare 3 DMA request
  1138. * @arg TIM_DMA_CC4: Capture/Compare 4 DMA request
  1139. * @arg TIM_DMA_COM: Commutation DMA request
  1140. * @arg TIM_DMA_TRIGGER: Trigger DMA request
  1141. * @retval None
  1142. */
  1143. #define __HAL_TIM_ENABLE_DMA(__HANDLE__, __DMA__) ((__HANDLE__)->Instance->DIER |= (__DMA__))
  1144. /** @brief Disable the specified DMA request.
  1145. * @param __HANDLE__ specifies the TIM Handle.
  1146. * @param __DMA__ specifies the TIM DMA request to disable.
  1147. * This parameter can be one of the following values:
  1148. * @arg TIM_DMA_UPDATE: Update DMA request
  1149. * @arg TIM_DMA_CC1: Capture/Compare 1 DMA request
  1150. * @arg TIM_DMA_CC2: Capture/Compare 2 DMA request
  1151. * @arg TIM_DMA_CC3: Capture/Compare 3 DMA request
  1152. * @arg TIM_DMA_CC4: Capture/Compare 4 DMA request
  1153. * @arg TIM_DMA_COM: Commutation DMA request
  1154. * @arg TIM_DMA_TRIGGER: Trigger DMA request
  1155. * @retval None
  1156. */
  1157. #define __HAL_TIM_DISABLE_DMA(__HANDLE__, __DMA__) ((__HANDLE__)->Instance->DIER &= ~(__DMA__))
  1158. /** @brief Check whether the specified TIM interrupt flag is set or not.
  1159. * @param __HANDLE__ specifies the TIM Handle.
  1160. * @param __FLAG__ specifies the TIM interrupt flag to check.
  1161. * This parameter can be one of the following values:
  1162. * @arg TIM_FLAG_UPDATE: Update interrupt flag
  1163. * @arg TIM_FLAG_CC1: Capture/Compare 1 interrupt flag
  1164. * @arg TIM_FLAG_CC2: Capture/Compare 2 interrupt flag
  1165. * @arg TIM_FLAG_CC3: Capture/Compare 3 interrupt flag
  1166. * @arg TIM_FLAG_CC4: Capture/Compare 4 interrupt flag
  1167. * @arg TIM_FLAG_CC5: Compare 5 interrupt flag
  1168. * @arg TIM_FLAG_CC6: Compare 6 interrupt flag
  1169. * @arg TIM_FLAG_COM: Commutation interrupt flag
  1170. * @arg TIM_FLAG_TRIGGER: Trigger interrupt flag
  1171. * @arg TIM_FLAG_BREAK: Break interrupt flag
  1172. * @arg TIM_FLAG_BREAK2: Break 2 interrupt flag
  1173. * @arg TIM_FLAG_SYSTEM_BREAK: System Break interrupt flag
  1174. * @arg TIM_FLAG_CC1OF: Capture/Compare 1 overcapture flag
  1175. * @arg TIM_FLAG_CC2OF: Capture/Compare 2 overcapture flag
  1176. * @arg TIM_FLAG_CC3OF: Capture/Compare 3 overcapture flag
  1177. * @arg TIM_FLAG_CC4OF: Capture/Compare 4 overcapture flag
  1178. * @retval The new state of __FLAG__ (TRUE or FALSE).
  1179. */
  1180. #define __HAL_TIM_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR &(__FLAG__)) == (__FLAG__))
  1181. /** @brief Clear the specified TIM interrupt flag.
  1182. * @param __HANDLE__ specifies the TIM Handle.
  1183. * @param __FLAG__ specifies the TIM interrupt flag to clear.
  1184. * This parameter can be one of the following values:
  1185. * @arg TIM_FLAG_UPDATE: Update interrupt flag
  1186. * @arg TIM_FLAG_CC1: Capture/Compare 1 interrupt flag
  1187. * @arg TIM_FLAG_CC2: Capture/Compare 2 interrupt flag
  1188. * @arg TIM_FLAG_CC3: Capture/Compare 3 interrupt flag
  1189. * @arg TIM_FLAG_CC4: Capture/Compare 4 interrupt flag
  1190. * @arg TIM_FLAG_CC5: Compare 5 interrupt flag
  1191. * @arg TIM_FLAG_CC6: Compare 6 interrupt flag
  1192. * @arg TIM_FLAG_COM: Commutation interrupt flag
  1193. * @arg TIM_FLAG_TRIGGER: Trigger interrupt flag
  1194. * @arg TIM_FLAG_BREAK: Break interrupt flag
  1195. * @arg TIM_FLAG_BREAK2: Break 2 interrupt flag
  1196. * @arg TIM_FLAG_SYSTEM_BREAK: System Break interrupt flag
  1197. * @arg TIM_FLAG_CC1OF: Capture/Compare 1 overcapture flag
  1198. * @arg TIM_FLAG_CC2OF: Capture/Compare 2 overcapture flag
  1199. * @arg TIM_FLAG_CC3OF: Capture/Compare 3 overcapture flag
  1200. * @arg TIM_FLAG_CC4OF: Capture/Compare 4 overcapture flag
  1201. * @retval The new state of __FLAG__ (TRUE or FALSE).
  1202. */
  1203. #define __HAL_TIM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
  1204. /**
  1205. * @brief Check whether the specified TIM interrupt source is enabled or not.
  1206. * @param __HANDLE__ TIM handle
  1207. * @param __INTERRUPT__ specifies the TIM interrupt source to check.
  1208. * This parameter can be one of the following values:
  1209. * @arg TIM_IT_UPDATE: Update interrupt
  1210. * @arg TIM_IT_CC1: Capture/Compare 1 interrupt
  1211. * @arg TIM_IT_CC2: Capture/Compare 2 interrupt
  1212. * @arg TIM_IT_CC3: Capture/Compare 3 interrupt
  1213. * @arg TIM_IT_CC4: Capture/Compare 4 interrupt
  1214. * @arg TIM_IT_COM: Commutation interrupt
  1215. * @arg TIM_IT_TRIGGER: Trigger interrupt
  1216. * @arg TIM_IT_BREAK: Break interrupt
  1217. * @retval The state of TIM_IT (SET or RESET).
  1218. */
  1219. #define __HAL_TIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->DIER & (__INTERRUPT__)) \
  1220. == (__INTERRUPT__)) ? SET : RESET)
  1221. /** @brief Clear the TIM interrupt pending bits.
  1222. * @param __HANDLE__ TIM handle
  1223. * @param __INTERRUPT__ specifies the interrupt pending bit to clear.
  1224. * This parameter can be one of the following values:
  1225. * @arg TIM_IT_UPDATE: Update interrupt
  1226. * @arg TIM_IT_CC1: Capture/Compare 1 interrupt
  1227. * @arg TIM_IT_CC2: Capture/Compare 2 interrupt
  1228. * @arg TIM_IT_CC3: Capture/Compare 3 interrupt
  1229. * @arg TIM_IT_CC4: Capture/Compare 4 interrupt
  1230. * @arg TIM_IT_COM: Commutation interrupt
  1231. * @arg TIM_IT_TRIGGER: Trigger interrupt
  1232. * @arg TIM_IT_BREAK: Break interrupt
  1233. * @retval None
  1234. */
  1235. #define __HAL_TIM_CLEAR_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->SR = ~(__INTERRUPT__))
  1236. /**
  1237. * @brief Force a continuous copy of the update interrupt flag (UIF) into the timer counter register (bit 31).
  1238. * @note This allows both the counter value and a potential roll-over condition signalled by the UIFCPY flag to be read
  1239. * in an atomic way.
  1240. * @param __HANDLE__ TIM handle.
  1241. * @retval None
  1242. mode.
  1243. */
  1244. #define __HAL_TIM_UIFREMAP_ENABLE(__HANDLE__) (((__HANDLE__)->Instance->CR1 |= TIM_CR1_UIFREMAP))
  1245. /**
  1246. * @brief Disable update interrupt flag (UIF) remapping.
  1247. * @param __HANDLE__ TIM handle.
  1248. * @retval None
  1249. mode.
  1250. */
  1251. #define __HAL_TIM_UIFREMAP_DISABLE(__HANDLE__) (((__HANDLE__)->Instance->CR1 &= ~TIM_CR1_UIFREMAP))
  1252. /**
  1253. * @brief Get update interrupt flag (UIF) copy status.
  1254. * @param __COUNTER__ Counter value.
  1255. * @retval The state of UIFCPY (TRUE or FALSE).
  1256. mode.
  1257. */
  1258. #define __HAL_TIM_GET_UIFCPY(__COUNTER__) (((__COUNTER__) & (TIM_CNT_UIFCPY)) == (TIM_CNT_UIFCPY))
  1259. /**
  1260. * @brief Indicates whether or not the TIM Counter is used as downcounter.
  1261. * @param __HANDLE__ TIM handle.
  1262. * @retval False (Counter used as upcounter) or True (Counter used as downcounter)
  1263. * @note This macro is particularly useful to get the counting mode when the timer operates in Center-aligned mode
  1264. * or Encoder mode.
  1265. */
  1266. #define __HAL_TIM_IS_TIM_COUNTING_DOWN(__HANDLE__) (((__HANDLE__)->Instance->CR1 &(TIM_CR1_DIR)) == (TIM_CR1_DIR))
  1267. /**
  1268. * @brief Set the TIM Prescaler on runtime.
  1269. * @param __HANDLE__ TIM handle.
  1270. * @param __PRESC__ specifies the Prescaler new value.
  1271. * @retval None
  1272. */
  1273. #define __HAL_TIM_SET_PRESCALER(__HANDLE__, __PRESC__) ((__HANDLE__)->Instance->PSC = (__PRESC__))
  1274. /**
  1275. * @brief Set the TIM Counter Register value on runtime.
  1276. * Note Please check if the bit 31 of CNT register is used as UIF copy or not, this may affect the counter range in
  1277. * case of 32 bits counter TIM instance.
  1278. * Bit 31 of CNT can be enabled/disabled using __HAL_TIM_UIFREMAP_ENABLE()/__HAL_TIM_UIFREMAP_DISABLE() macros.
  1279. * @param __HANDLE__ TIM handle.
  1280. * @param __COUNTER__ specifies the Counter register new value.
  1281. * @retval None
  1282. */
  1283. #define __HAL_TIM_SET_COUNTER(__HANDLE__, __COUNTER__) ((__HANDLE__)->Instance->CNT = (__COUNTER__))
  1284. /**
  1285. * @brief Get the TIM Counter Register value on runtime.
  1286. * @param __HANDLE__ TIM handle.
  1287. * @retval 16-bit or 32-bit value of the timer counter register (TIMx_CNT)
  1288. */
  1289. #define __HAL_TIM_GET_COUNTER(__HANDLE__) ((__HANDLE__)->Instance->CNT)
  1290. /**
  1291. * @brief Set the TIM Autoreload Register value on runtime without calling another time any Init function.
  1292. * @param __HANDLE__ TIM handle.
  1293. * @param __AUTORELOAD__ specifies the Counter register new value.
  1294. * @retval None
  1295. */
  1296. #define __HAL_TIM_SET_AUTORELOAD(__HANDLE__, __AUTORELOAD__) \
  1297. do{ \
  1298. (__HANDLE__)->Instance->ARR = (__AUTORELOAD__); \
  1299. (__HANDLE__)->Init.Period = (__AUTORELOAD__); \
  1300. } while(0)
  1301. /**
  1302. * @brief Get the TIM Autoreload Register value on runtime.
  1303. * @param __HANDLE__ TIM handle.
  1304. * @retval 16-bit or 32-bit value of the timer auto-reload register(TIMx_ARR)
  1305. */
  1306. #define __HAL_TIM_GET_AUTORELOAD(__HANDLE__) ((__HANDLE__)->Instance->ARR)
  1307. /**
  1308. * @brief Set the TIM Clock Division value on runtime without calling another time any Init function.
  1309. * @param __HANDLE__ TIM handle.
  1310. * @param __CKD__ specifies the clock division value.
  1311. * This parameter can be one of the following value:
  1312. * @arg TIM_CLOCKDIVISION_DIV1: tDTS=tCK_INT
  1313. * @arg TIM_CLOCKDIVISION_DIV2: tDTS=2*tCK_INT
  1314. * @arg TIM_CLOCKDIVISION_DIV4: tDTS=4*tCK_INT
  1315. * @retval None
  1316. */
  1317. #define __HAL_TIM_SET_CLOCKDIVISION(__HANDLE__, __CKD__) \
  1318. do{ \
  1319. (__HANDLE__)->Instance->CR1 &= (~TIM_CR1_CKD); \
  1320. (__HANDLE__)->Instance->CR1 |= (__CKD__); \
  1321. (__HANDLE__)->Init.ClockDivision = (__CKD__); \
  1322. } while(0)
  1323. /**
  1324. * @brief Get the TIM Clock Division value on runtime.
  1325. * @param __HANDLE__ TIM handle.
  1326. * @retval The clock division can be one of the following values:
  1327. * @arg TIM_CLOCKDIVISION_DIV1: tDTS=tCK_INT
  1328. * @arg TIM_CLOCKDIVISION_DIV2: tDTS=2*tCK_INT
  1329. * @arg TIM_CLOCKDIVISION_DIV4: tDTS=4*tCK_INT
  1330. */
  1331. #define __HAL_TIM_GET_CLOCKDIVISION(__HANDLE__) ((__HANDLE__)->Instance->CR1 & TIM_CR1_CKD)
  1332. /**
  1333. * @brief Set the TIM Input Capture prescaler on runtime without calling another time HAL_TIM_IC_ConfigChannel()
  1334. * function.
  1335. * @param __HANDLE__ TIM handle.
  1336. * @param __CHANNEL__ TIM Channels to be configured.
  1337. * This parameter can be one of the following values:
  1338. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  1339. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  1340. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  1341. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  1342. * @param __ICPSC__ specifies the Input Capture4 prescaler new value.
  1343. * This parameter can be one of the following values:
  1344. * @arg TIM_ICPSC_DIV1: no prescaler
  1345. * @arg TIM_ICPSC_DIV2: capture is done once every 2 events
  1346. * @arg TIM_ICPSC_DIV4: capture is done once every 4 events
  1347. * @arg TIM_ICPSC_DIV8: capture is done once every 8 events
  1348. * @retval None
  1349. */
  1350. #define __HAL_TIM_SET_ICPRESCALER(__HANDLE__, __CHANNEL__, __ICPSC__) \
  1351. do{ \
  1352. TIM_RESET_ICPRESCALERVALUE((__HANDLE__), (__CHANNEL__)); \
  1353. TIM_SET_ICPRESCALERVALUE((__HANDLE__), (__CHANNEL__), (__ICPSC__)); \
  1354. } while(0)
  1355. /**
  1356. * @brief Get the TIM Input Capture prescaler on runtime.
  1357. * @param __HANDLE__ TIM handle.
  1358. * @param __CHANNEL__ TIM Channels to be configured.
  1359. * This parameter can be one of the following values:
  1360. * @arg TIM_CHANNEL_1: get input capture 1 prescaler value
  1361. * @arg TIM_CHANNEL_2: get input capture 2 prescaler value
  1362. * @arg TIM_CHANNEL_3: get input capture 3 prescaler value
  1363. * @arg TIM_CHANNEL_4: get input capture 4 prescaler value
  1364. * @retval The input capture prescaler can be one of the following values:
  1365. * @arg TIM_ICPSC_DIV1: no prescaler
  1366. * @arg TIM_ICPSC_DIV2: capture is done once every 2 events
  1367. * @arg TIM_ICPSC_DIV4: capture is done once every 4 events
  1368. * @arg TIM_ICPSC_DIV8: capture is done once every 8 events
  1369. */
  1370. #define __HAL_TIM_GET_ICPRESCALER(__HANDLE__, __CHANNEL__) \
  1371. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 & TIM_CCMR1_IC1PSC) :\
  1372. ((__CHANNEL__) == TIM_CHANNEL_2) ? (((__HANDLE__)->Instance->CCMR1 & TIM_CCMR1_IC2PSC) >> 8U) :\
  1373. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 & TIM_CCMR2_IC3PSC) :\
  1374. (((__HANDLE__)->Instance->CCMR2 & TIM_CCMR2_IC4PSC)) >> 8U)
  1375. /**
  1376. * @brief Set the TIM Capture Compare Register value on runtime without calling another time ConfigChannel function.
  1377. * @param __HANDLE__ TIM handle.
  1378. * @param __CHANNEL__ TIM Channels to be configured.
  1379. * This parameter can be one of the following values:
  1380. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  1381. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  1382. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  1383. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  1384. * @arg TIM_CHANNEL_5: TIM Channel 5 selected
  1385. * @arg TIM_CHANNEL_6: TIM Channel 6 selected
  1386. * @param __COMPARE__ specifies the Capture Compare register new value.
  1387. * @retval None
  1388. */
  1389. #define __HAL_TIM_SET_COMPARE(__HANDLE__, __CHANNEL__, __COMPARE__) \
  1390. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCR1 = (__COMPARE__)) :\
  1391. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCR2 = (__COMPARE__)) :\
  1392. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCR3 = (__COMPARE__)) :\
  1393. ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCR4 = (__COMPARE__)) :\
  1394. ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCR5 = (__COMPARE__)) :\
  1395. ((__HANDLE__)->Instance->CCR6 = (__COMPARE__)))
  1396. /**
  1397. * @brief Get the TIM Capture Compare Register value on runtime.
  1398. * @param __HANDLE__ TIM handle.
  1399. * @param __CHANNEL__ TIM Channel associated with the capture compare register
  1400. * This parameter can be one of the following values:
  1401. * @arg TIM_CHANNEL_1: get capture/compare 1 register value
  1402. * @arg TIM_CHANNEL_2: get capture/compare 2 register value
  1403. * @arg TIM_CHANNEL_3: get capture/compare 3 register value
  1404. * @arg TIM_CHANNEL_4: get capture/compare 4 register value
  1405. * @arg TIM_CHANNEL_5: get capture/compare 5 register value
  1406. * @arg TIM_CHANNEL_6: get capture/compare 6 register value
  1407. * @retval 16-bit or 32-bit value of the capture/compare register (TIMx_CCRy)
  1408. */
  1409. #define __HAL_TIM_GET_COMPARE(__HANDLE__, __CHANNEL__) \
  1410. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCR1) :\
  1411. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCR2) :\
  1412. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCR3) :\
  1413. ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCR4) :\
  1414. ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCR5) :\
  1415. ((__HANDLE__)->Instance->CCR6))
  1416. /**
  1417. * @brief Set the TIM Output compare preload.
  1418. * @param __HANDLE__ TIM handle.
  1419. * @param __CHANNEL__ TIM Channels to be configured.
  1420. * This parameter can be one of the following values:
  1421. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  1422. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  1423. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  1424. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  1425. * @arg TIM_CHANNEL_5: TIM Channel 5 selected
  1426. * @arg TIM_CHANNEL_6: TIM Channel 6 selected
  1427. * @retval None
  1428. */
  1429. #define __HAL_TIM_ENABLE_OCxPRELOAD(__HANDLE__, __CHANNEL__) \
  1430. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 |= TIM_CCMR1_OC1PE) :\
  1431. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 |= TIM_CCMR1_OC2PE) :\
  1432. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 |= TIM_CCMR2_OC3PE) :\
  1433. ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCMR2 |= TIM_CCMR2_OC4PE) :\
  1434. ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCMR3 |= TIM_CCMR3_OC5PE) :\
  1435. ((__HANDLE__)->Instance->CCMR3 |= TIM_CCMR3_OC6PE))
  1436. /**
  1437. * @brief Reset the TIM Output compare preload.
  1438. * @param __HANDLE__ TIM handle.
  1439. * @param __CHANNEL__ TIM Channels to be configured.
  1440. * This parameter can be one of the following values:
  1441. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  1442. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  1443. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  1444. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  1445. * @arg TIM_CHANNEL_5: TIM Channel 5 selected
  1446. * @arg TIM_CHANNEL_6: TIM Channel 6 selected
  1447. * @retval None
  1448. */
  1449. #define __HAL_TIM_DISABLE_OCxPRELOAD(__HANDLE__, __CHANNEL__) \
  1450. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_OC1PE) :\
  1451. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_OC2PE) :\
  1452. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_OC3PE) :\
  1453. ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_OC4PE) :\
  1454. ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCMR3 &= ~TIM_CCMR3_OC5PE) :\
  1455. ((__HANDLE__)->Instance->CCMR3 &= ~TIM_CCMR3_OC6PE))
  1456. /**
  1457. * @brief Enable fast mode for a given channel.
  1458. * @param __HANDLE__ TIM handle.
  1459. * @param __CHANNEL__ TIM Channels to be configured.
  1460. * This parameter can be one of the following values:
  1461. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  1462. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  1463. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  1464. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  1465. * @arg TIM_CHANNEL_5: TIM Channel 5 selected
  1466. * @arg TIM_CHANNEL_6: TIM Channel 6 selected
  1467. * @note When fast mode is enabled an active edge on the trigger input acts
  1468. * like a compare match on CCx output. Delay to sample the trigger
  1469. * input and to activate CCx output is reduced to 3 clock cycles.
  1470. * @note Fast mode acts only if the channel is configured in PWM1 or PWM2 mode.
  1471. * @retval None
  1472. */
  1473. #define __HAL_TIM_ENABLE_OCxFAST(__HANDLE__, __CHANNEL__) \
  1474. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 |= TIM_CCMR1_OC1FE) :\
  1475. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 |= TIM_CCMR1_OC2FE) :\
  1476. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 |= TIM_CCMR2_OC3FE) :\
  1477. ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCMR2 |= TIM_CCMR2_OC4FE) :\
  1478. ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCMR3 |= TIM_CCMR3_OC5FE) :\
  1479. ((__HANDLE__)->Instance->CCMR3 |= TIM_CCMR3_OC6FE))
  1480. /**
  1481. * @brief Disable fast mode for a given channel.
  1482. * @param __HANDLE__ TIM handle.
  1483. * @param __CHANNEL__ TIM Channels to be configured.
  1484. * This parameter can be one of the following values:
  1485. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  1486. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  1487. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  1488. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  1489. * @arg TIM_CHANNEL_5: TIM Channel 5 selected
  1490. * @arg TIM_CHANNEL_6: TIM Channel 6 selected
  1491. * @note When fast mode is disabled CCx output behaves normally depending
  1492. * on counter and CCRx values even when the trigger is ON. The minimum
  1493. * delay to activate CCx output when an active edge occurs on the
  1494. * trigger input is 5 clock cycles.
  1495. * @retval None
  1496. */
  1497. #define __HAL_TIM_DISABLE_OCxFAST(__HANDLE__, __CHANNEL__) \
  1498. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_OC1FE) :\
  1499. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_OC2FE) :\
  1500. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_OC3FE) :\
  1501. ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_OC4FE) :\
  1502. ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCMR3 &= ~TIM_CCMR3_OC5FE) :\
  1503. ((__HANDLE__)->Instance->CCMR3 &= ~TIM_CCMR3_OC6FE))
  1504. /**
  1505. * @brief Set the Update Request Source (URS) bit of the TIMx_CR1 register.
  1506. * @param __HANDLE__ TIM handle.
  1507. * @note When the URS bit of the TIMx_CR1 register is set, only counter
  1508. * overflow/underflow generates an update interrupt or DMA request (if
  1509. * enabled)
  1510. * @retval None
  1511. */
  1512. #define __HAL_TIM_URS_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1|= TIM_CR1_URS)
  1513. /**
  1514. * @brief Reset the Update Request Source (URS) bit of the TIMx_CR1 register.
  1515. * @param __HANDLE__ TIM handle.
  1516. * @note When the URS bit of the TIMx_CR1 register is reset, any of the
  1517. * following events generate an update interrupt or DMA request (if
  1518. * enabled):
  1519. * _ Counter overflow underflow
  1520. * _ Setting the UG bit
  1521. * _ Update generation through the slave mode controller
  1522. * @retval None
  1523. */
  1524. #define __HAL_TIM_URS_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1&=~TIM_CR1_URS)
  1525. /**
  1526. * @brief Set the TIM Capture x input polarity on runtime.
  1527. * @param __HANDLE__ TIM handle.
  1528. * @param __CHANNEL__ TIM Channels to be configured.
  1529. * This parameter can be one of the following values:
  1530. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  1531. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  1532. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  1533. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  1534. * @param __POLARITY__ Polarity for TIx source
  1535. * @arg TIM_INPUTCHANNELPOLARITY_RISING: Rising Edge
  1536. * @arg TIM_INPUTCHANNELPOLARITY_FALLING: Falling Edge
  1537. * @arg TIM_INPUTCHANNELPOLARITY_BOTHEDGE: Rising and Falling Edge
  1538. * @retval None
  1539. */
  1540. #define __HAL_TIM_SET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__, __POLARITY__) \
  1541. do{ \
  1542. TIM_RESET_CAPTUREPOLARITY((__HANDLE__), (__CHANNEL__)); \
  1543. TIM_SET_CAPTUREPOLARITY((__HANDLE__), (__CHANNEL__), (__POLARITY__)); \
  1544. }while(0)
  1545. /** @brief Select the Capture/compare DMA request source.
  1546. * @param __HANDLE__ specifies the TIM Handle.
  1547. * @param __CCDMA__ specifies Capture/compare DMA request source
  1548. * This parameter can be one of the following values:
  1549. * @arg TIM_CCDMAREQUEST_CC: CCx DMA request generated on Capture/Compare event
  1550. * @arg TIM_CCDMAREQUEST_UPDATE: CCx DMA request generated on Update event
  1551. * @retval None
  1552. */
  1553. #define __HAL_TIM_SELECT_CCDMAREQUEST(__HANDLE__, __CCDMA__) \
  1554. MODIFY_REG((__HANDLE__)->Instance->CR2, TIM_CR2_CCDS, (__CCDMA__))
  1555. /**
  1556. * @}
  1557. */
  1558. /* End of exported macros ----------------------------------------------------*/
  1559. /* Private constants ---------------------------------------------------------*/
  1560. /** @defgroup TIM_Private_Constants TIM Private Constants
  1561. * @{
  1562. */
  1563. /* The counter of a timer instance is disabled only if all the CCx and CCxN
  1564. channels have been disabled */
  1565. #define TIM_CCER_CCxE_MASK ((uint32_t)(TIM_CCER_CC1E | TIM_CCER_CC2E | TIM_CCER_CC3E | TIM_CCER_CC4E))
  1566. #define TIM_CCER_CCxNE_MASK ((uint32_t)(TIM_CCER_CC1NE | TIM_CCER_CC2NE | TIM_CCER_CC3NE))
  1567. /**
  1568. * @}
  1569. */
  1570. /* End of private constants --------------------------------------------------*/
  1571. /* Private macros ------------------------------------------------------------*/
  1572. /** @defgroup TIM_Private_Macros TIM Private Macros
  1573. * @{
  1574. */
  1575. #define IS_TIM_CLEARINPUT_SOURCE(__MODE__) (((__MODE__) == TIM_CLEARINPUTSOURCE_NONE) || \
  1576. ((__MODE__) == TIM_CLEARINPUTSOURCE_ETR))
  1577. #if defined(TIM_AF1_BKINE)&&defined(TIM_AF2_BKINE)
  1578. #define IS_TIM_DMA_BASE(__BASE__) (((__BASE__) == TIM_DMABASE_CR1) || \
  1579. ((__BASE__) == TIM_DMABASE_CR2) || \
  1580. ((__BASE__) == TIM_DMABASE_SMCR) || \
  1581. ((__BASE__) == TIM_DMABASE_DIER) || \
  1582. ((__BASE__) == TIM_DMABASE_SR) || \
  1583. ((__BASE__) == TIM_DMABASE_EGR) || \
  1584. ((__BASE__) == TIM_DMABASE_CCMR1) || \
  1585. ((__BASE__) == TIM_DMABASE_CCMR2) || \
  1586. ((__BASE__) == TIM_DMABASE_CCER) || \
  1587. ((__BASE__) == TIM_DMABASE_CNT) || \
  1588. ((__BASE__) == TIM_DMABASE_PSC) || \
  1589. ((__BASE__) == TIM_DMABASE_ARR) || \
  1590. ((__BASE__) == TIM_DMABASE_RCR) || \
  1591. ((__BASE__) == TIM_DMABASE_CCR1) || \
  1592. ((__BASE__) == TIM_DMABASE_CCR2) || \
  1593. ((__BASE__) == TIM_DMABASE_CCR3) || \
  1594. ((__BASE__) == TIM_DMABASE_CCR4) || \
  1595. ((__BASE__) == TIM_DMABASE_BDTR) || \
  1596. ((__BASE__) == TIM_DMABASE_OR) || \
  1597. ((__BASE__) == TIM_DMABASE_CCMR3) || \
  1598. ((__BASE__) == TIM_DMABASE_CCR5) || \
  1599. ((__BASE__) == TIM_DMABASE_CCR6) || \
  1600. ((__BASE__) == TIM_DMABASE_AF1) || \
  1601. ((__BASE__) == TIM_DMABASE_AF2))
  1602. #else
  1603. #define IS_TIM_DMA_BASE(__BASE__) (((__BASE__) == TIM_DMABASE_CR1) || \
  1604. ((__BASE__) == TIM_DMABASE_CR2) || \
  1605. ((__BASE__) == TIM_DMABASE_SMCR) || \
  1606. ((__BASE__) == TIM_DMABASE_DIER) || \
  1607. ((__BASE__) == TIM_DMABASE_SR) || \
  1608. ((__BASE__) == TIM_DMABASE_EGR) || \
  1609. ((__BASE__) == TIM_DMABASE_CCMR1) || \
  1610. ((__BASE__) == TIM_DMABASE_CCMR2) || \
  1611. ((__BASE__) == TIM_DMABASE_CCER) || \
  1612. ((__BASE__) == TIM_DMABASE_CNT) || \
  1613. ((__BASE__) == TIM_DMABASE_PSC) || \
  1614. ((__BASE__) == TIM_DMABASE_ARR) || \
  1615. ((__BASE__) == TIM_DMABASE_RCR) || \
  1616. ((__BASE__) == TIM_DMABASE_CCR1) || \
  1617. ((__BASE__) == TIM_DMABASE_CCR2) || \
  1618. ((__BASE__) == TIM_DMABASE_CCR3) || \
  1619. ((__BASE__) == TIM_DMABASE_CCR4) || \
  1620. ((__BASE__) == TIM_DMABASE_BDTR) || \
  1621. ((__BASE__) == TIM_DMABASE_OR) || \
  1622. ((__BASE__) == TIM_DMABASE_CCMR3) || \
  1623. ((__BASE__) == TIM_DMABASE_CCR5) || \
  1624. ((__BASE__) == TIM_DMABASE_CCR6))
  1625. #endif /* TIM_AF1_BKINE && TIM_AF1_BKINE */
  1626. #define IS_TIM_EVENT_SOURCE(__SOURCE__) ((((__SOURCE__) & 0xFFFFFE00U) == 0x00000000U) && ((__SOURCE__) != 0x00000000U))
  1627. #define IS_TIM_COUNTER_MODE(__MODE__) (((__MODE__) == TIM_COUNTERMODE_UP) || \
  1628. ((__MODE__) == TIM_COUNTERMODE_DOWN) || \
  1629. ((__MODE__) == TIM_COUNTERMODE_CENTERALIGNED1) || \
  1630. ((__MODE__) == TIM_COUNTERMODE_CENTERALIGNED2) || \
  1631. ((__MODE__) == TIM_COUNTERMODE_CENTERALIGNED3))
  1632. #define IS_TIM_UIFREMAP_MODE(__MODE__) (((__MODE__) == TIM_UIFREMAP_DISABLE) || \
  1633. ((__MODE__) == TIM_UIFREMAP_ENABLE))
  1634. #define IS_TIM_CLOCKDIVISION_DIV(__DIV__) (((__DIV__) == TIM_CLOCKDIVISION_DIV1) || \
  1635. ((__DIV__) == TIM_CLOCKDIVISION_DIV2) || \
  1636. ((__DIV__) == TIM_CLOCKDIVISION_DIV4))
  1637. #define IS_TIM_AUTORELOAD_PRELOAD(PRELOAD) (((PRELOAD) == TIM_AUTORELOAD_PRELOAD_DISABLE) || \
  1638. ((PRELOAD) == TIM_AUTORELOAD_PRELOAD_ENABLE))
  1639. #define IS_TIM_FAST_STATE(__STATE__) (((__STATE__) == TIM_OCFAST_DISABLE) || \
  1640. ((__STATE__) == TIM_OCFAST_ENABLE))
  1641. #define IS_TIM_OC_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_OCPOLARITY_HIGH) || \
  1642. ((__POLARITY__) == TIM_OCPOLARITY_LOW))
  1643. #define IS_TIM_OCN_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_OCNPOLARITY_HIGH) || \
  1644. ((__POLARITY__) == TIM_OCNPOLARITY_LOW))
  1645. #define IS_TIM_OCIDLE_STATE(__STATE__) (((__STATE__) == TIM_OCIDLESTATE_SET) || \
  1646. ((__STATE__) == TIM_OCIDLESTATE_RESET))
  1647. #define IS_TIM_OCNIDLE_STATE(__STATE__) (((__STATE__) == TIM_OCNIDLESTATE_SET) || \
  1648. ((__STATE__) == TIM_OCNIDLESTATE_RESET))
  1649. #define IS_TIM_ENCODERINPUT_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_ENCODERINPUTPOLARITY_RISING) || \
  1650. ((__POLARITY__) == TIM_ENCODERINPUTPOLARITY_FALLING))
  1651. #define IS_TIM_IC_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_ICPOLARITY_RISING) || \
  1652. ((__POLARITY__) == TIM_ICPOLARITY_FALLING) || \
  1653. ((__POLARITY__) == TIM_ICPOLARITY_BOTHEDGE))
  1654. #define IS_TIM_IC_SELECTION(__SELECTION__) (((__SELECTION__) == TIM_ICSELECTION_DIRECTTI) || \
  1655. ((__SELECTION__) == TIM_ICSELECTION_INDIRECTTI) || \
  1656. ((__SELECTION__) == TIM_ICSELECTION_TRC))
  1657. #define IS_TIM_IC_PRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_ICPSC_DIV1) || \
  1658. ((__PRESCALER__) == TIM_ICPSC_DIV2) || \
  1659. ((__PRESCALER__) == TIM_ICPSC_DIV4) || \
  1660. ((__PRESCALER__) == TIM_ICPSC_DIV8))
  1661. #define IS_TIM_OPM_MODE(__MODE__) (((__MODE__) == TIM_OPMODE_SINGLE) || \
  1662. ((__MODE__) == TIM_OPMODE_REPETITIVE))
  1663. #define IS_TIM_ENCODER_MODE(__MODE__) (((__MODE__) == TIM_ENCODERMODE_TI1) || \
  1664. ((__MODE__) == TIM_ENCODERMODE_TI2) || \
  1665. ((__MODE__) == TIM_ENCODERMODE_TI12))
  1666. #define IS_TIM_DMA_SOURCE(__SOURCE__) ((((__SOURCE__) & 0xFFFF80FFU) == 0x00000000U) && ((__SOURCE__) != 0x00000000U))
  1667. #define IS_TIM_CHANNELS(__CHANNEL__) (((__CHANNEL__) == TIM_CHANNEL_1) || \
  1668. ((__CHANNEL__) == TIM_CHANNEL_2) || \
  1669. ((__CHANNEL__) == TIM_CHANNEL_3) || \
  1670. ((__CHANNEL__) == TIM_CHANNEL_4) || \
  1671. ((__CHANNEL__) == TIM_CHANNEL_5) || \
  1672. ((__CHANNEL__) == TIM_CHANNEL_6) || \
  1673. ((__CHANNEL__) == TIM_CHANNEL_ALL))
  1674. #define IS_TIM_OPM_CHANNELS(__CHANNEL__) (((__CHANNEL__) == TIM_CHANNEL_1) || \
  1675. ((__CHANNEL__) == TIM_CHANNEL_2))
  1676. #define IS_TIM_PERIOD(__HANDLE__, __PERIOD__) \
  1677. ((IS_TIM_32B_COUNTER_INSTANCE(((__HANDLE__)->Instance)) == 0U) ? (((__PERIOD__) > 0U) && ((__PERIOD__) <= 0x0000FFFFU)) : ((__PERIOD__) > 0U))
  1678. #define IS_TIM_COMPLEMENTARY_CHANNELS(__CHANNEL__) (((__CHANNEL__) == TIM_CHANNEL_1) || \
  1679. ((__CHANNEL__) == TIM_CHANNEL_2) || \
  1680. ((__CHANNEL__) == TIM_CHANNEL_3))
  1681. #define IS_TIM_CLOCKSOURCE(__CLOCK__) (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL) || \
  1682. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE1) || \
  1683. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE2) || \
  1684. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1ED) || \
  1685. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1) || \
  1686. ((__CLOCK__) == TIM_CLOCKSOURCE_TI2) || \
  1687. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR0) || \
  1688. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR1) || \
  1689. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR2) || \
  1690. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR3))
  1691. #define IS_TIM_CLOCKPOLARITY(__POLARITY__) (((__POLARITY__) == TIM_CLOCKPOLARITY_INVERTED) || \
  1692. ((__POLARITY__) == TIM_CLOCKPOLARITY_NONINVERTED) || \
  1693. ((__POLARITY__) == TIM_CLOCKPOLARITY_RISING) || \
  1694. ((__POLARITY__) == TIM_CLOCKPOLARITY_FALLING) || \
  1695. ((__POLARITY__) == TIM_CLOCKPOLARITY_BOTHEDGE))
  1696. #define IS_TIM_CLOCKPRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV1) || \
  1697. ((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV2) || \
  1698. ((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV4) || \
  1699. ((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV8))
  1700. #define IS_TIM_CLOCKFILTER(__ICFILTER__) ((__ICFILTER__) <= 0xFU)
  1701. #define IS_TIM_CLEARINPUT_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_CLEARINPUTPOLARITY_INVERTED) || \
  1702. ((__POLARITY__) == TIM_CLEARINPUTPOLARITY_NONINVERTED))
  1703. #define IS_TIM_CLEARINPUT_PRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV1) || \
  1704. ((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV2) || \
  1705. ((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV4) || \
  1706. ((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV8))
  1707. #define IS_TIM_CLEARINPUT_FILTER(__ICFILTER__) ((__ICFILTER__) <= 0xFU)
  1708. #define IS_TIM_OSSR_STATE(__STATE__) (((__STATE__) == TIM_OSSR_ENABLE) || \
  1709. ((__STATE__) == TIM_OSSR_DISABLE))
  1710. #define IS_TIM_OSSI_STATE(__STATE__) (((__STATE__) == TIM_OSSI_ENABLE) || \
  1711. ((__STATE__) == TIM_OSSI_DISABLE))
  1712. #define IS_TIM_LOCK_LEVEL(__LEVEL__) (((__LEVEL__) == TIM_LOCKLEVEL_OFF) || \
  1713. ((__LEVEL__) == TIM_LOCKLEVEL_1) || \
  1714. ((__LEVEL__) == TIM_LOCKLEVEL_2) || \
  1715. ((__LEVEL__) == TIM_LOCKLEVEL_3))
  1716. #define IS_TIM_BREAK_FILTER(__BRKFILTER__) ((__BRKFILTER__) <= 0xFUL)
  1717. #define IS_TIM_BREAK_STATE(__STATE__) (((__STATE__) == TIM_BREAK_ENABLE) || \
  1718. ((__STATE__) == TIM_BREAK_DISABLE))
  1719. #define IS_TIM_BREAK_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_BREAKPOLARITY_LOW) || \
  1720. ((__POLARITY__) == TIM_BREAKPOLARITY_HIGH))
  1721. #define IS_TIM_BREAK2_STATE(__STATE__) (((__STATE__) == TIM_BREAK2_ENABLE) || \
  1722. ((__STATE__) == TIM_BREAK2_DISABLE))
  1723. #define IS_TIM_BREAK2_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_BREAK2POLARITY_LOW) || \
  1724. ((__POLARITY__) == TIM_BREAK2POLARITY_HIGH))
  1725. #define IS_TIM_AUTOMATIC_OUTPUT_STATE(__STATE__) (((__STATE__) == TIM_AUTOMATICOUTPUT_ENABLE) || \
  1726. ((__STATE__) == TIM_AUTOMATICOUTPUT_DISABLE))
  1727. #define IS_TIM_GROUPCH5(__OCREF__) ((((__OCREF__) & 0x1FFFFFFFU) == 0x00000000U))
  1728. #define IS_TIM_TRGO_SOURCE(__SOURCE__) (((__SOURCE__) == TIM_TRGO_RESET) || \
  1729. ((__SOURCE__) == TIM_TRGO_ENABLE) || \
  1730. ((__SOURCE__) == TIM_TRGO_UPDATE) || \
  1731. ((__SOURCE__) == TIM_TRGO_OC1) || \
  1732. ((__SOURCE__) == TIM_TRGO_OC1REF) || \
  1733. ((__SOURCE__) == TIM_TRGO_OC2REF) || \
  1734. ((__SOURCE__) == TIM_TRGO_OC3REF) || \
  1735. ((__SOURCE__) == TIM_TRGO_OC4REF))
  1736. #define IS_TIM_TRGO2_SOURCE(__SOURCE__) (((__SOURCE__) == TIM_TRGO2_RESET) || \
  1737. ((__SOURCE__) == TIM_TRGO2_ENABLE) || \
  1738. ((__SOURCE__) == TIM_TRGO2_UPDATE) || \
  1739. ((__SOURCE__) == TIM_TRGO2_OC1) || \
  1740. ((__SOURCE__) == TIM_TRGO2_OC1REF) || \
  1741. ((__SOURCE__) == TIM_TRGO2_OC2REF) || \
  1742. ((__SOURCE__) == TIM_TRGO2_OC3REF) || \
  1743. ((__SOURCE__) == TIM_TRGO2_OC3REF) || \
  1744. ((__SOURCE__) == TIM_TRGO2_OC4REF) || \
  1745. ((__SOURCE__) == TIM_TRGO2_OC5REF) || \
  1746. ((__SOURCE__) == TIM_TRGO2_OC6REF) || \
  1747. ((__SOURCE__) == TIM_TRGO2_OC4REF_RISINGFALLING) || \
  1748. ((__SOURCE__) == TIM_TRGO2_OC6REF_RISINGFALLING) || \
  1749. ((__SOURCE__) == TIM_TRGO2_OC4REF_RISING_OC6REF_RISING) || \
  1750. ((__SOURCE__) == TIM_TRGO2_OC4REF_RISING_OC6REF_FALLING) || \
  1751. ((__SOURCE__) == TIM_TRGO2_OC5REF_RISING_OC6REF_RISING) || \
  1752. ((__SOURCE__) == TIM_TRGO2_OC5REF_RISING_OC6REF_FALLING))
  1753. #define IS_TIM_MSM_STATE(__STATE__) (((__STATE__) == TIM_MASTERSLAVEMODE_ENABLE) || \
  1754. ((__STATE__) == TIM_MASTERSLAVEMODE_DISABLE))
  1755. #define IS_TIM_SLAVE_MODE(__MODE__) (((__MODE__) == TIM_SLAVEMODE_DISABLE) || \
  1756. ((__MODE__) == TIM_SLAVEMODE_RESET) || \
  1757. ((__MODE__) == TIM_SLAVEMODE_GATED) || \
  1758. ((__MODE__) == TIM_SLAVEMODE_TRIGGER) || \
  1759. ((__MODE__) == TIM_SLAVEMODE_EXTERNAL1) || \
  1760. ((__MODE__) == TIM_SLAVEMODE_COMBINED_RESETTRIGGER))
  1761. #define IS_TIM_PWM_MODE(__MODE__) (((__MODE__) == TIM_OCMODE_PWM1) || \
  1762. ((__MODE__) == TIM_OCMODE_PWM2) || \
  1763. ((__MODE__) == TIM_OCMODE_COMBINED_PWM1) || \
  1764. ((__MODE__) == TIM_OCMODE_COMBINED_PWM2) || \
  1765. ((__MODE__) == TIM_OCMODE_ASSYMETRIC_PWM1) || \
  1766. ((__MODE__) == TIM_OCMODE_ASSYMETRIC_PWM2))
  1767. #define IS_TIM_OC_MODE(__MODE__) (((__MODE__) == TIM_OCMODE_TIMING) || \
  1768. ((__MODE__) == TIM_OCMODE_ACTIVE) || \
  1769. ((__MODE__) == TIM_OCMODE_INACTIVE) || \
  1770. ((__MODE__) == TIM_OCMODE_TOGGLE) || \
  1771. ((__MODE__) == TIM_OCMODE_FORCED_ACTIVE) || \
  1772. ((__MODE__) == TIM_OCMODE_FORCED_INACTIVE) || \
  1773. ((__MODE__) == TIM_OCMODE_RETRIGERRABLE_OPM1) || \
  1774. ((__MODE__) == TIM_OCMODE_RETRIGERRABLE_OPM2))
  1775. #define IS_TIM_TRIGGER_SELECTION(__SELECTION__) (((__SELECTION__) == TIM_TS_ITR0) || \
  1776. ((__SELECTION__) == TIM_TS_ITR1) || \
  1777. ((__SELECTION__) == TIM_TS_ITR2) || \
  1778. ((__SELECTION__) == TIM_TS_ITR3) || \
  1779. ((__SELECTION__) == TIM_TS_TI1F_ED) || \
  1780. ((__SELECTION__) == TIM_TS_TI1FP1) || \
  1781. ((__SELECTION__) == TIM_TS_TI2FP2) || \
  1782. ((__SELECTION__) == TIM_TS_ETRF))
  1783. #define IS_TIM_INTERNAL_TRIGGEREVENT_SELECTION(__SELECTION__) (((__SELECTION__) == TIM_TS_ITR0) || \
  1784. ((__SELECTION__) == TIM_TS_ITR1) || \
  1785. ((__SELECTION__) == TIM_TS_ITR2) || \
  1786. ((__SELECTION__) == TIM_TS_ITR3) || \
  1787. ((__SELECTION__) == TIM_TS_NONE))
  1788. #define IS_TIM_TRIGGERPOLARITY(__POLARITY__) (((__POLARITY__) == TIM_TRIGGERPOLARITY_INVERTED ) || \
  1789. ((__POLARITY__) == TIM_TRIGGERPOLARITY_NONINVERTED) || \
  1790. ((__POLARITY__) == TIM_TRIGGERPOLARITY_RISING ) || \
  1791. ((__POLARITY__) == TIM_TRIGGERPOLARITY_FALLING ) || \
  1792. ((__POLARITY__) == TIM_TRIGGERPOLARITY_BOTHEDGE ))
  1793. #define IS_TIM_TRIGGERPRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV1) || \
  1794. ((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV2) || \
  1795. ((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV4) || \
  1796. ((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV8))
  1797. #define IS_TIM_TRIGGERFILTER(__ICFILTER__) ((__ICFILTER__) <= 0xFU)
  1798. #define IS_TIM_TI1SELECTION(__TI1SELECTION__) (((__TI1SELECTION__) == TIM_TI1SELECTION_CH1) || \
  1799. ((__TI1SELECTION__) == TIM_TI1SELECTION_XORCOMBINATION))
  1800. #define IS_TIM_DMA_LENGTH(__LENGTH__) (((__LENGTH__) == TIM_DMABURSTLENGTH_1TRANSFER) || \
  1801. ((__LENGTH__) == TIM_DMABURSTLENGTH_2TRANSFERS) || \
  1802. ((__LENGTH__) == TIM_DMABURSTLENGTH_3TRANSFERS) || \
  1803. ((__LENGTH__) == TIM_DMABURSTLENGTH_4TRANSFERS) || \
  1804. ((__LENGTH__) == TIM_DMABURSTLENGTH_5TRANSFERS) || \
  1805. ((__LENGTH__) == TIM_DMABURSTLENGTH_6TRANSFERS) || \
  1806. ((__LENGTH__) == TIM_DMABURSTLENGTH_7TRANSFERS) || \
  1807. ((__LENGTH__) == TIM_DMABURSTLENGTH_8TRANSFERS) || \
  1808. ((__LENGTH__) == TIM_DMABURSTLENGTH_9TRANSFERS) || \
  1809. ((__LENGTH__) == TIM_DMABURSTLENGTH_10TRANSFERS) || \
  1810. ((__LENGTH__) == TIM_DMABURSTLENGTH_11TRANSFERS) || \
  1811. ((__LENGTH__) == TIM_DMABURSTLENGTH_12TRANSFERS) || \
  1812. ((__LENGTH__) == TIM_DMABURSTLENGTH_13TRANSFERS) || \
  1813. ((__LENGTH__) == TIM_DMABURSTLENGTH_14TRANSFERS) || \
  1814. ((__LENGTH__) == TIM_DMABURSTLENGTH_15TRANSFERS) || \
  1815. ((__LENGTH__) == TIM_DMABURSTLENGTH_16TRANSFERS) || \
  1816. ((__LENGTH__) == TIM_DMABURSTLENGTH_17TRANSFERS) || \
  1817. ((__LENGTH__) == TIM_DMABURSTLENGTH_18TRANSFERS))
  1818. #define IS_TIM_DMA_DATA_LENGTH(LENGTH) (((LENGTH) >= 0x1U) && ((LENGTH) < 0x10000U))
  1819. #define IS_TIM_IC_FILTER(__ICFILTER__) ((__ICFILTER__) <= 0xFU)
  1820. #define IS_TIM_DEADTIME(__DEADTIME__) ((__DEADTIME__) <= 0xFFU)
  1821. #define IS_TIM_BREAK_SYSTEM(__CONFIG__) (((__CONFIG__) == TIM_BREAK_SYSTEM_ECC) || \
  1822. ((__CONFIG__) == TIM_BREAK_SYSTEM_PVD) || \
  1823. ((__CONFIG__) == TIM_BREAK_SYSTEM_SRAM_PARITY_ERROR) || \
  1824. ((__CONFIG__) == TIM_BREAK_SYSTEM_LOCKUP))
  1825. #define IS_TIM_SLAVEMODE_TRIGGER_ENABLED(__TRIGGER__) (((__TRIGGER__) == TIM_SLAVEMODE_TRIGGER) || \
  1826. ((__TRIGGER__) == TIM_SLAVEMODE_COMBINED_RESETTRIGGER))
  1827. #define TIM_SET_ICPRESCALERVALUE(__HANDLE__, __CHANNEL__, __ICPSC__) \
  1828. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 |= (__ICPSC__)) :\
  1829. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 |= ((__ICPSC__) << 8U)) :\
  1830. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 |= (__ICPSC__)) :\
  1831. ((__HANDLE__)->Instance->CCMR2 |= ((__ICPSC__) << 8U)))
  1832. #define TIM_RESET_ICPRESCALERVALUE(__HANDLE__, __CHANNEL__) \
  1833. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_IC1PSC) :\
  1834. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_IC2PSC) :\
  1835. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_IC3PSC) :\
  1836. ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_IC4PSC))
  1837. #define TIM_SET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__, __POLARITY__) \
  1838. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCER |= (__POLARITY__)) :\
  1839. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCER |= ((__POLARITY__) << 4U)) :\
  1840. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCER |= ((__POLARITY__) << 8U)) :\
  1841. ((__HANDLE__)->Instance->CCER |= (((__POLARITY__) << 12U))))
  1842. #define TIM_RESET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__) \
  1843. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP)) :\
  1844. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC2P | TIM_CCER_CC2NP)) :\
  1845. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC3P | TIM_CCER_CC3NP)) :\
  1846. ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC4P | TIM_CCER_CC4NP)))
  1847. #define TIM_CHANNEL_STATE_GET(__HANDLE__, __CHANNEL__)\
  1848. (((__CHANNEL__) == TIM_CHANNEL_1) ? (__HANDLE__)->ChannelState[0] :\
  1849. ((__CHANNEL__) == TIM_CHANNEL_2) ? (__HANDLE__)->ChannelState[1] :\
  1850. ((__CHANNEL__) == TIM_CHANNEL_3) ? (__HANDLE__)->ChannelState[2] :\
  1851. ((__CHANNEL__) == TIM_CHANNEL_4) ? (__HANDLE__)->ChannelState[3] :\
  1852. ((__CHANNEL__) == TIM_CHANNEL_5) ? (__HANDLE__)->ChannelState[4] :\
  1853. (__HANDLE__)->ChannelState[5])
  1854. #define TIM_CHANNEL_STATE_SET(__HANDLE__, __CHANNEL__, __CHANNEL_STATE__) \
  1855. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->ChannelState[0] = (__CHANNEL_STATE__)) :\
  1856. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->ChannelState[1] = (__CHANNEL_STATE__)) :\
  1857. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->ChannelState[2] = (__CHANNEL_STATE__)) :\
  1858. ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->ChannelState[3] = (__CHANNEL_STATE__)) :\
  1859. ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->ChannelState[4] = (__CHANNEL_STATE__)) :\
  1860. ((__HANDLE__)->ChannelState[5] = (__CHANNEL_STATE__)))
  1861. #define TIM_CHANNEL_STATE_SET_ALL(__HANDLE__, __CHANNEL_STATE__) do { \
  1862. (__HANDLE__)->ChannelState[0] = \
  1863. (__CHANNEL_STATE__); \
  1864. (__HANDLE__)->ChannelState[1] = \
  1865. (__CHANNEL_STATE__); \
  1866. (__HANDLE__)->ChannelState[2] = \
  1867. (__CHANNEL_STATE__); \
  1868. (__HANDLE__)->ChannelState[3] = \
  1869. (__CHANNEL_STATE__); \
  1870. (__HANDLE__)->ChannelState[4] = \
  1871. (__CHANNEL_STATE__); \
  1872. (__HANDLE__)->ChannelState[5] = \
  1873. (__CHANNEL_STATE__); \
  1874. } while(0)
  1875. #define TIM_CHANNEL_N_STATE_GET(__HANDLE__, __CHANNEL__)\
  1876. (((__CHANNEL__) == TIM_CHANNEL_1) ? (__HANDLE__)->ChannelNState[0] :\
  1877. ((__CHANNEL__) == TIM_CHANNEL_2) ? (__HANDLE__)->ChannelNState[1] :\
  1878. ((__CHANNEL__) == TIM_CHANNEL_3) ? (__HANDLE__)->ChannelNState[2] :\
  1879. (__HANDLE__)->ChannelNState[3])
  1880. #define TIM_CHANNEL_N_STATE_SET(__HANDLE__, __CHANNEL__, __CHANNEL_STATE__) \
  1881. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->ChannelNState[0] = (__CHANNEL_STATE__)) :\
  1882. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->ChannelNState[1] = (__CHANNEL_STATE__)) :\
  1883. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->ChannelNState[2] = (__CHANNEL_STATE__)) :\
  1884. ((__HANDLE__)->ChannelNState[3] = (__CHANNEL_STATE__)))
  1885. #define TIM_CHANNEL_N_STATE_SET_ALL(__HANDLE__, __CHANNEL_STATE__) do { \
  1886. (__HANDLE__)->ChannelNState[0] = \
  1887. (__CHANNEL_STATE__); \
  1888. (__HANDLE__)->ChannelNState[1] = \
  1889. (__CHANNEL_STATE__); \
  1890. (__HANDLE__)->ChannelNState[2] = \
  1891. (__CHANNEL_STATE__); \
  1892. (__HANDLE__)->ChannelNState[3] = \
  1893. (__CHANNEL_STATE__); \
  1894. } while(0)
  1895. /**
  1896. * @}
  1897. */
  1898. /* End of private macros -----------------------------------------------------*/
  1899. /* Include TIM HAL Extended module */
  1900. #include "stm32f7xx_hal_tim_ex.h"
  1901. /* Exported functions --------------------------------------------------------*/
  1902. /** @addtogroup TIM_Exported_Functions TIM Exported Functions
  1903. * @{
  1904. */
  1905. /** @addtogroup TIM_Exported_Functions_Group1 TIM Time Base functions
  1906. * @brief Time Base functions
  1907. * @{
  1908. */
  1909. /* Time Base functions ********************************************************/
  1910. HAL_StatusTypeDef HAL_TIM_Base_Init(TIM_HandleTypeDef *htim);
  1911. HAL_StatusTypeDef HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim);
  1912. void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim);
  1913. void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim);
  1914. /* Blocking mode: Polling */
  1915. HAL_StatusTypeDef HAL_TIM_Base_Start(TIM_HandleTypeDef *htim);
  1916. HAL_StatusTypeDef HAL_TIM_Base_Stop(TIM_HandleTypeDef *htim);
  1917. /* Non-Blocking mode: Interrupt */
  1918. HAL_StatusTypeDef HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim);
  1919. HAL_StatusTypeDef HAL_TIM_Base_Stop_IT(TIM_HandleTypeDef *htim);
  1920. /* Non-Blocking mode: DMA */
  1921. HAL_StatusTypeDef HAL_TIM_Base_Start_DMA(TIM_HandleTypeDef *htim, const uint32_t *pData, uint16_t Length);
  1922. HAL_StatusTypeDef HAL_TIM_Base_Stop_DMA(TIM_HandleTypeDef *htim);
  1923. /**
  1924. * @}
  1925. */
  1926. /** @addtogroup TIM_Exported_Functions_Group2 TIM Output Compare functions
  1927. * @brief TIM Output Compare functions
  1928. * @{
  1929. */
  1930. /* Timer Output Compare functions *********************************************/
  1931. HAL_StatusTypeDef HAL_TIM_OC_Init(TIM_HandleTypeDef *htim);
  1932. HAL_StatusTypeDef HAL_TIM_OC_DeInit(TIM_HandleTypeDef *htim);
  1933. void HAL_TIM_OC_MspInit(TIM_HandleTypeDef *htim);
  1934. void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef *htim);
  1935. /* Blocking mode: Polling */
  1936. HAL_StatusTypeDef HAL_TIM_OC_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  1937. HAL_StatusTypeDef HAL_TIM_OC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  1938. /* Non-Blocking mode: Interrupt */
  1939. HAL_StatusTypeDef HAL_TIM_OC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1940. HAL_StatusTypeDef HAL_TIM_OC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1941. /* Non-Blocking mode: DMA */
  1942. HAL_StatusTypeDef HAL_TIM_OC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData,
  1943. uint16_t Length);
  1944. HAL_StatusTypeDef HAL_TIM_OC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  1945. /**
  1946. * @}
  1947. */
  1948. /** @addtogroup TIM_Exported_Functions_Group3 TIM PWM functions
  1949. * @brief TIM PWM functions
  1950. * @{
  1951. */
  1952. /* Timer PWM functions ********************************************************/
  1953. HAL_StatusTypeDef HAL_TIM_PWM_Init(TIM_HandleTypeDef *htim);
  1954. HAL_StatusTypeDef HAL_TIM_PWM_DeInit(TIM_HandleTypeDef *htim);
  1955. void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim);
  1956. void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef *htim);
  1957. /* Blocking mode: Polling */
  1958. HAL_StatusTypeDef HAL_TIM_PWM_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  1959. HAL_StatusTypeDef HAL_TIM_PWM_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  1960. /* Non-Blocking mode: Interrupt */
  1961. HAL_StatusTypeDef HAL_TIM_PWM_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1962. HAL_StatusTypeDef HAL_TIM_PWM_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1963. /* Non-Blocking mode: DMA */
  1964. HAL_StatusTypeDef HAL_TIM_PWM_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData,
  1965. uint16_t Length);
  1966. HAL_StatusTypeDef HAL_TIM_PWM_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  1967. /**
  1968. * @}
  1969. */
  1970. /** @addtogroup TIM_Exported_Functions_Group4 TIM Input Capture functions
  1971. * @brief TIM Input Capture functions
  1972. * @{
  1973. */
  1974. /* Timer Input Capture functions **********************************************/
  1975. HAL_StatusTypeDef HAL_TIM_IC_Init(TIM_HandleTypeDef *htim);
  1976. HAL_StatusTypeDef HAL_TIM_IC_DeInit(TIM_HandleTypeDef *htim);
  1977. void HAL_TIM_IC_MspInit(TIM_HandleTypeDef *htim);
  1978. void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef *htim);
  1979. /* Blocking mode: Polling */
  1980. HAL_StatusTypeDef HAL_TIM_IC_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  1981. HAL_StatusTypeDef HAL_TIM_IC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  1982. /* Non-Blocking mode: Interrupt */
  1983. HAL_StatusTypeDef HAL_TIM_IC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1984. HAL_StatusTypeDef HAL_TIM_IC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1985. /* Non-Blocking mode: DMA */
  1986. HAL_StatusTypeDef HAL_TIM_IC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  1987. HAL_StatusTypeDef HAL_TIM_IC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  1988. /**
  1989. * @}
  1990. */
  1991. /** @addtogroup TIM_Exported_Functions_Group5 TIM One Pulse functions
  1992. * @brief TIM One Pulse functions
  1993. * @{
  1994. */
  1995. /* Timer One Pulse functions **************************************************/
  1996. HAL_StatusTypeDef HAL_TIM_OnePulse_Init(TIM_HandleTypeDef *htim, uint32_t OnePulseMode);
  1997. HAL_StatusTypeDef HAL_TIM_OnePulse_DeInit(TIM_HandleTypeDef *htim);
  1998. void HAL_TIM_OnePulse_MspInit(TIM_HandleTypeDef *htim);
  1999. void HAL_TIM_OnePulse_MspDeInit(TIM_HandleTypeDef *htim);
  2000. /* Blocking mode: Polling */
  2001. HAL_StatusTypeDef HAL_TIM_OnePulse_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  2002. HAL_StatusTypeDef HAL_TIM_OnePulse_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  2003. /* Non-Blocking mode: Interrupt */
  2004. HAL_StatusTypeDef HAL_TIM_OnePulse_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  2005. HAL_StatusTypeDef HAL_TIM_OnePulse_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  2006. /**
  2007. * @}
  2008. */
  2009. /** @addtogroup TIM_Exported_Functions_Group6 TIM Encoder functions
  2010. * @brief TIM Encoder functions
  2011. * @{
  2012. */
  2013. /* Timer Encoder functions ****************************************************/
  2014. HAL_StatusTypeDef HAL_TIM_Encoder_Init(TIM_HandleTypeDef *htim, TIM_Encoder_InitTypeDef *sConfig);
  2015. HAL_StatusTypeDef HAL_TIM_Encoder_DeInit(TIM_HandleTypeDef *htim);
  2016. void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim);
  2017. void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef *htim);
  2018. /* Blocking mode: Polling */
  2019. HAL_StatusTypeDef HAL_TIM_Encoder_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  2020. HAL_StatusTypeDef HAL_TIM_Encoder_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  2021. /* Non-Blocking mode: Interrupt */
  2022. HAL_StatusTypeDef HAL_TIM_Encoder_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  2023. HAL_StatusTypeDef HAL_TIM_Encoder_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  2024. /* Non-Blocking mode: DMA */
  2025. HAL_StatusTypeDef HAL_TIM_Encoder_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData1,
  2026. uint32_t *pData2, uint16_t Length);
  2027. HAL_StatusTypeDef HAL_TIM_Encoder_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  2028. /**
  2029. * @}
  2030. */
  2031. /** @addtogroup TIM_Exported_Functions_Group7 TIM IRQ handler management
  2032. * @brief IRQ handler management
  2033. * @{
  2034. */
  2035. /* Interrupt Handler functions ***********************************************/
  2036. void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim);
  2037. /**
  2038. * @}
  2039. */
  2040. /** @defgroup TIM_Exported_Functions_Group8 TIM Peripheral Control functions
  2041. * @brief Peripheral Control functions
  2042. * @{
  2043. */
  2044. /* Control functions *********************************************************/
  2045. HAL_StatusTypeDef HAL_TIM_OC_ConfigChannel(TIM_HandleTypeDef *htim, const TIM_OC_InitTypeDef *sConfig,
  2046. uint32_t Channel);
  2047. HAL_StatusTypeDef HAL_TIM_PWM_ConfigChannel(TIM_HandleTypeDef *htim, const TIM_OC_InitTypeDef *sConfig,
  2048. uint32_t Channel);
  2049. HAL_StatusTypeDef HAL_TIM_IC_ConfigChannel(TIM_HandleTypeDef *htim, const TIM_IC_InitTypeDef *sConfig,
  2050. uint32_t Channel);
  2051. HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OnePulse_InitTypeDef *sConfig,
  2052. uint32_t OutputChannel, uint32_t InputChannel);
  2053. HAL_StatusTypeDef HAL_TIM_ConfigOCrefClear(TIM_HandleTypeDef *htim,
  2054. const TIM_ClearInputConfigTypeDef *sClearInputConfig,
  2055. uint32_t Channel);
  2056. HAL_StatusTypeDef HAL_TIM_ConfigClockSource(TIM_HandleTypeDef *htim, const TIM_ClockConfigTypeDef *sClockSourceConfig);
  2057. HAL_StatusTypeDef HAL_TIM_ConfigTI1Input(TIM_HandleTypeDef *htim, uint32_t TI1_Selection);
  2058. HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchro(TIM_HandleTypeDef *htim, const TIM_SlaveConfigTypeDef *sSlaveConfig);
  2059. HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchro_IT(TIM_HandleTypeDef *htim, const TIM_SlaveConfigTypeDef *sSlaveConfig);
  2060. HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
  2061. uint32_t BurstRequestSrc, const uint32_t *BurstBuffer, uint32_t BurstLength);
  2062. HAL_StatusTypeDef HAL_TIM_DMABurst_MultiWriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
  2063. uint32_t BurstRequestSrc, const uint32_t *BurstBuffer,
  2064. uint32_t BurstLength, uint32_t DataLength);
  2065. HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc);
  2066. HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
  2067. uint32_t BurstRequestSrc, uint32_t *BurstBuffer, uint32_t BurstLength);
  2068. HAL_StatusTypeDef HAL_TIM_DMABurst_MultiReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
  2069. uint32_t BurstRequestSrc, uint32_t *BurstBuffer,
  2070. uint32_t BurstLength, uint32_t DataLength);
  2071. HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc);
  2072. HAL_StatusTypeDef HAL_TIM_GenerateEvent(TIM_HandleTypeDef *htim, uint32_t EventSource);
  2073. uint32_t HAL_TIM_ReadCapturedValue(const TIM_HandleTypeDef *htim, uint32_t Channel);
  2074. /**
  2075. * @}
  2076. */
  2077. /** @defgroup TIM_Exported_Functions_Group9 TIM Callbacks functions
  2078. * @brief TIM Callbacks functions
  2079. * @{
  2080. */
  2081. /* Callback in non blocking modes (Interrupt and DMA) *************************/
  2082. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim);
  2083. void HAL_TIM_PeriodElapsedHalfCpltCallback(TIM_HandleTypeDef *htim);
  2084. void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim);
  2085. void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim);
  2086. void HAL_TIM_IC_CaptureHalfCpltCallback(TIM_HandleTypeDef *htim);
  2087. void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim);
  2088. void HAL_TIM_PWM_PulseFinishedHalfCpltCallback(TIM_HandleTypeDef *htim);
  2089. void HAL_TIM_TriggerCallback(TIM_HandleTypeDef *htim);
  2090. void HAL_TIM_TriggerHalfCpltCallback(TIM_HandleTypeDef *htim);
  2091. void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim);
  2092. /* Callbacks Register/UnRegister functions ***********************************/
  2093. #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
  2094. HAL_StatusTypeDef HAL_TIM_RegisterCallback(TIM_HandleTypeDef *htim, HAL_TIM_CallbackIDTypeDef CallbackID,
  2095. pTIM_CallbackTypeDef pCallback);
  2096. HAL_StatusTypeDef HAL_TIM_UnRegisterCallback(TIM_HandleTypeDef *htim, HAL_TIM_CallbackIDTypeDef CallbackID);
  2097. #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
  2098. /**
  2099. * @}
  2100. */
  2101. /** @defgroup TIM_Exported_Functions_Group10 TIM Peripheral State functions
  2102. * @brief Peripheral State functions
  2103. * @{
  2104. */
  2105. /* Peripheral State functions ************************************************/
  2106. HAL_TIM_StateTypeDef HAL_TIM_Base_GetState(const TIM_HandleTypeDef *htim);
  2107. HAL_TIM_StateTypeDef HAL_TIM_OC_GetState(const TIM_HandleTypeDef *htim);
  2108. HAL_TIM_StateTypeDef HAL_TIM_PWM_GetState(const TIM_HandleTypeDef *htim);
  2109. HAL_TIM_StateTypeDef HAL_TIM_IC_GetState(const TIM_HandleTypeDef *htim);
  2110. HAL_TIM_StateTypeDef HAL_TIM_OnePulse_GetState(const TIM_HandleTypeDef *htim);
  2111. HAL_TIM_StateTypeDef HAL_TIM_Encoder_GetState(const TIM_HandleTypeDef *htim);
  2112. /* Peripheral Channel state functions ************************************************/
  2113. HAL_TIM_ActiveChannel HAL_TIM_GetActiveChannel(const TIM_HandleTypeDef *htim);
  2114. HAL_TIM_ChannelStateTypeDef HAL_TIM_GetChannelState(const TIM_HandleTypeDef *htim, uint32_t Channel);
  2115. HAL_TIM_DMABurstStateTypeDef HAL_TIM_DMABurstState(const TIM_HandleTypeDef *htim);
  2116. /**
  2117. * @}
  2118. */
  2119. /**
  2120. * @}
  2121. */
  2122. /* End of exported functions -------------------------------------------------*/
  2123. /* Private functions----------------------------------------------------------*/
  2124. /** @defgroup TIM_Private_Functions TIM Private Functions
  2125. * @{
  2126. */
  2127. void TIM_Base_SetConfig(TIM_TypeDef *TIMx, const TIM_Base_InitTypeDef *Structure);
  2128. void TIM_TI1_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, uint32_t TIM_ICFilter);
  2129. void TIM_OC2_SetConfig(TIM_TypeDef *TIMx, const TIM_OC_InitTypeDef *OC_Config);
  2130. void TIM_ETR_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ExtTRGPrescaler,
  2131. uint32_t TIM_ExtTRGPolarity, uint32_t ExtTRGFilter);
  2132. void TIM_DMADelayPulseHalfCplt(DMA_HandleTypeDef *hdma);
  2133. void TIM_DMAError(DMA_HandleTypeDef *hdma);
  2134. void TIM_DMACaptureCplt(DMA_HandleTypeDef *hdma);
  2135. void TIM_DMACaptureHalfCplt(DMA_HandleTypeDef *hdma);
  2136. void TIM_CCxChannelCmd(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ChannelState);
  2137. #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
  2138. void TIM_ResetCallback(TIM_HandleTypeDef *htim);
  2139. #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
  2140. /**
  2141. * @}
  2142. */
  2143. /* End of private functions --------------------------------------------------*/
  2144. /**
  2145. * @}
  2146. */
  2147. /**
  2148. * @}
  2149. */
  2150. #ifdef __cplusplus
  2151. }
  2152. #endif
  2153. #endif /* STM32F7xx_HAL_TIM_H */