stm32f7xx_hal_tim.h 138 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386
  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_Flag_definition TIM Flag Definition
  642. * @{
  643. */
  644. #define TIM_FLAG_UPDATE TIM_SR_UIF /*!< Update interrupt flag */
  645. #define TIM_FLAG_CC1 TIM_SR_CC1IF /*!< Capture/Compare 1 interrupt flag */
  646. #define TIM_FLAG_CC2 TIM_SR_CC2IF /*!< Capture/Compare 2 interrupt flag */
  647. #define TIM_FLAG_CC3 TIM_SR_CC3IF /*!< Capture/Compare 3 interrupt flag */
  648. #define TIM_FLAG_CC4 TIM_SR_CC4IF /*!< Capture/Compare 4 interrupt flag */
  649. #define TIM_FLAG_CC5 TIM_SR_CC5IF /*!< Capture/Compare 5 interrupt flag */
  650. #define TIM_FLAG_CC6 TIM_SR_CC6IF /*!< Capture/Compare 6 interrupt flag */
  651. #define TIM_FLAG_COM TIM_SR_COMIF /*!< Commutation interrupt flag */
  652. #define TIM_FLAG_TRIGGER TIM_SR_TIF /*!< Trigger interrupt flag */
  653. #define TIM_FLAG_BREAK TIM_SR_BIF /*!< Break interrupt flag */
  654. #define TIM_FLAG_BREAK2 TIM_SR_B2IF /*!< Break 2 interrupt flag */
  655. #define TIM_FLAG_SYSTEM_BREAK TIM_SR_SBIF /*!< System Break interrupt flag */
  656. #define TIM_FLAG_CC1OF TIM_SR_CC1OF /*!< Capture 1 overcapture flag */
  657. #define TIM_FLAG_CC2OF TIM_SR_CC2OF /*!< Capture 2 overcapture flag */
  658. #define TIM_FLAG_CC3OF TIM_SR_CC3OF /*!< Capture 3 overcapture flag */
  659. #define TIM_FLAG_CC4OF TIM_SR_CC4OF /*!< Capture 4 overcapture flag */
  660. /**
  661. * @}
  662. */
  663. /** @defgroup TIM_Channel TIM Channel
  664. * @{
  665. */
  666. #define TIM_CHANNEL_1 0x00000000U /*!< Capture/compare channel 1 identifier */
  667. #define TIM_CHANNEL_2 0x00000004U /*!< Capture/compare channel 2 identifier */
  668. #define TIM_CHANNEL_3 0x00000008U /*!< Capture/compare channel 3 identifier */
  669. #define TIM_CHANNEL_4 0x0000000CU /*!< Capture/compare channel 4 identifier */
  670. #define TIM_CHANNEL_5 0x00000010U /*!< Compare channel 5 identifier */
  671. #define TIM_CHANNEL_6 0x00000014U /*!< Compare channel 6 identifier */
  672. #define TIM_CHANNEL_ALL 0x0000003CU /*!< Global Capture/compare channel identifier */
  673. /**
  674. * @}
  675. */
  676. /** @defgroup TIM_Clock_Source TIM Clock Source
  677. * @{
  678. */
  679. #define TIM_CLOCKSOURCE_ETRMODE2 TIM_SMCR_ETPS_1 /*!< External clock source mode 2 */
  680. #define TIM_CLOCKSOURCE_INTERNAL TIM_SMCR_ETPS_0 /*!< Internal clock source */
  681. #define TIM_CLOCKSOURCE_ITR0 TIM_TS_ITR0 /*!< External clock source mode 1 (ITR0) */
  682. #define TIM_CLOCKSOURCE_ITR1 TIM_TS_ITR1 /*!< External clock source mode 1 (ITR1) */
  683. #define TIM_CLOCKSOURCE_ITR2 TIM_TS_ITR2 /*!< External clock source mode 1 (ITR2) */
  684. #define TIM_CLOCKSOURCE_ITR3 TIM_TS_ITR3 /*!< External clock source mode 1 (ITR3) */
  685. #define TIM_CLOCKSOURCE_TI1ED TIM_TS_TI1F_ED /*!< External clock source mode 1 (TTI1FP1 + edge detect.) */
  686. #define TIM_CLOCKSOURCE_TI1 TIM_TS_TI1FP1 /*!< External clock source mode 1 (TTI1FP1) */
  687. #define TIM_CLOCKSOURCE_TI2 TIM_TS_TI2FP2 /*!< External clock source mode 1 (TTI2FP2) */
  688. #define TIM_CLOCKSOURCE_ETRMODE1 TIM_TS_ETRF /*!< External clock source mode 1 (ETRF) */
  689. /**
  690. * @}
  691. */
  692. /** @defgroup TIM_Clock_Polarity TIM Clock Polarity
  693. * @{
  694. */
  695. #define TIM_CLOCKPOLARITY_INVERTED TIM_ETRPOLARITY_INVERTED /*!< Polarity for ETRx clock sources */
  696. #define TIM_CLOCKPOLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED /*!< Polarity for ETRx clock sources */
  697. #define TIM_CLOCKPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING /*!< Polarity for TIx clock sources */
  698. #define TIM_CLOCKPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING /*!< Polarity for TIx clock sources */
  699. #define TIM_CLOCKPOLARITY_BOTHEDGE TIM_INPUTCHANNELPOLARITY_BOTHEDGE /*!< Polarity for TIx clock sources */
  700. /**
  701. * @}
  702. */
  703. /** @defgroup TIM_Clock_Prescaler TIM Clock Prescaler
  704. * @{
  705. */
  706. #define TIM_CLOCKPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1 /*!< No prescaler is used */
  707. #define TIM_CLOCKPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2 /*!< Prescaler for External ETR Clock: Capture performed once every 2 events. */
  708. #define TIM_CLOCKPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4 /*!< Prescaler for External ETR Clock: Capture performed once every 4 events. */
  709. #define TIM_CLOCKPRESCALER_DIV8 TIM_ETRPRESCALER_DIV8 /*!< Prescaler for External ETR Clock: Capture performed once every 8 events. */
  710. /**
  711. * @}
  712. */
  713. /** @defgroup TIM_ClearInput_Polarity TIM Clear Input Polarity
  714. * @{
  715. */
  716. #define TIM_CLEARINPUTPOLARITY_INVERTED TIM_ETRPOLARITY_INVERTED /*!< Polarity for ETRx pin */
  717. #define TIM_CLEARINPUTPOLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED /*!< Polarity for ETRx pin */
  718. /**
  719. * @}
  720. */
  721. /** @defgroup TIM_ClearInput_Prescaler TIM Clear Input Prescaler
  722. * @{
  723. */
  724. #define TIM_CLEARINPUTPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1 /*!< No prescaler is used */
  725. #define TIM_CLEARINPUTPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2 /*!< Prescaler for External ETR pin: Capture performed once every 2 events. */
  726. #define TIM_CLEARINPUTPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4 /*!< Prescaler for External ETR pin: Capture performed once every 4 events. */
  727. #define TIM_CLEARINPUTPRESCALER_DIV8 TIM_ETRPRESCALER_DIV8 /*!< Prescaler for External ETR pin: Capture performed once every 8 events. */
  728. /**
  729. * @}
  730. */
  731. /** @defgroup TIM_OSSR_Off_State_Selection_for_Run_mode_state TIM OSSR OffState Selection for Run mode state
  732. * @{
  733. */
  734. #define TIM_OSSR_ENABLE TIM_BDTR_OSSR /*!< When inactive, OC/OCN outputs are enabled (still controlled by the timer) */
  735. #define TIM_OSSR_DISABLE 0x00000000U /*!< When inactive, OC/OCN outputs are disabled (not controlled any longer by the timer) */
  736. /**
  737. * @}
  738. */
  739. /** @defgroup TIM_OSSI_Off_State_Selection_for_Idle_mode_state TIM OSSI OffState Selection for Idle mode state
  740. * @{
  741. */
  742. #define TIM_OSSI_ENABLE TIM_BDTR_OSSI /*!< When inactive, OC/OCN outputs are enabled (still controlled by the timer) */
  743. #define TIM_OSSI_DISABLE 0x00000000U /*!< When inactive, OC/OCN outputs are disabled (not controlled any longer by the timer) */
  744. /**
  745. * @}
  746. */
  747. /** @defgroup TIM_Lock_level TIM Lock level
  748. * @{
  749. */
  750. #define TIM_LOCKLEVEL_OFF 0x00000000U /*!< LOCK OFF */
  751. #define TIM_LOCKLEVEL_1 TIM_BDTR_LOCK_0 /*!< LOCK Level 1 */
  752. #define TIM_LOCKLEVEL_2 TIM_BDTR_LOCK_1 /*!< LOCK Level 2 */
  753. #define TIM_LOCKLEVEL_3 TIM_BDTR_LOCK /*!< LOCK Level 3 */
  754. /**
  755. * @}
  756. */
  757. /** @defgroup TIM_Break_Input_enable_disable TIM Break Input Enable
  758. * @{
  759. */
  760. #define TIM_BREAK_ENABLE TIM_BDTR_BKE /*!< Break input BRK is enabled */
  761. #define TIM_BREAK_DISABLE 0x00000000U /*!< Break input BRK is disabled */
  762. /**
  763. * @}
  764. */
  765. /** @defgroup TIM_Break_Polarity TIM Break Input Polarity
  766. * @{
  767. */
  768. #define TIM_BREAKPOLARITY_LOW 0x00000000U /*!< Break input BRK is active low */
  769. #define TIM_BREAKPOLARITY_HIGH TIM_BDTR_BKP /*!< Break input BRK is active high */
  770. /**
  771. * @}
  772. */
  773. /** @defgroup TIM_Break2_Input_enable_disable TIM Break input 2 Enable
  774. * @{
  775. */
  776. #define TIM_BREAK2_DISABLE 0x00000000U /*!< Break input BRK2 is disabled */
  777. #define TIM_BREAK2_ENABLE TIM_BDTR_BK2E /*!< Break input BRK2 is enabled */
  778. /**
  779. * @}
  780. */
  781. /** @defgroup TIM_Break2_Polarity TIM Break Input 2 Polarity
  782. * @{
  783. */
  784. #define TIM_BREAK2POLARITY_LOW 0x00000000U /*!< Break input BRK2 is active low */
  785. #define TIM_BREAK2POLARITY_HIGH TIM_BDTR_BK2P /*!< Break input BRK2 is active high */
  786. /**
  787. * @}
  788. */
  789. /** @defgroup TIM_AOE_Bit_Set_Reset TIM Automatic Output Enable
  790. * @{
  791. */
  792. #define TIM_AUTOMATICOUTPUT_DISABLE 0x00000000U /*!< MOE can be set only by software */
  793. #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) */
  794. /**
  795. * @}
  796. */
  797. /** @defgroup TIM_Group_Channel5 TIM Group Channel 5 and Channel 1, 2 or 3
  798. * @{
  799. */
  800. #define TIM_GROUPCH5_NONE 0x00000000U /*!< No effect of OC5REF on OC1REFC, OC2REFC and OC3REFC */
  801. #define TIM_GROUPCH5_OC1REFC TIM_CCR5_GC5C1 /*!< OC1REFC is the logical AND of OC1REFC and OC5REF */
  802. #define TIM_GROUPCH5_OC2REFC TIM_CCR5_GC5C2 /*!< OC2REFC is the logical AND of OC2REFC and OC5REF */
  803. #define TIM_GROUPCH5_OC3REFC TIM_CCR5_GC5C3 /*!< OC3REFC is the logical AND of OC3REFC and OC5REF */
  804. /**
  805. * @}
  806. */
  807. /** @defgroup TIM_Master_Mode_Selection TIM Master Mode Selection
  808. * @{
  809. */
  810. #define TIM_TRGO_RESET 0x00000000U /*!< TIMx_EGR.UG bit is used as trigger output (TRGO) */
  811. #define TIM_TRGO_ENABLE TIM_CR2_MMS_0 /*!< TIMx_CR1.CEN bit is used as trigger output (TRGO) */
  812. #define TIM_TRGO_UPDATE TIM_CR2_MMS_1 /*!< Update event is used as trigger output (TRGO) */
  813. #define TIM_TRGO_OC1 (TIM_CR2_MMS_1 | TIM_CR2_MMS_0) /*!< Capture or a compare match 1 is used as trigger output (TRGO) */
  814. #define TIM_TRGO_OC1REF TIM_CR2_MMS_2 /*!< OC1REF signal is used as trigger output (TRGO) */
  815. #define TIM_TRGO_OC2REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_0) /*!< OC2REF signal is used as trigger output(TRGO) */
  816. #define TIM_TRGO_OC3REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_1) /*!< OC3REF signal is used as trigger output(TRGO) */
  817. #define TIM_TRGO_OC4REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_1 | TIM_CR2_MMS_0) /*!< OC4REF signal is used as trigger output(TRGO) */
  818. /**
  819. * @}
  820. */
  821. /** @defgroup TIM_Master_Mode_Selection_2 TIM Master Mode Selection 2 (TRGO2)
  822. * @{
  823. */
  824. #define TIM_TRGO2_RESET 0x00000000U /*!< TIMx_EGR.UG bit is used as trigger output (TRGO2) */
  825. #define TIM_TRGO2_ENABLE TIM_CR2_MMS2_0 /*!< TIMx_CR1.CEN bit is used as trigger output (TRGO2) */
  826. #define TIM_TRGO2_UPDATE TIM_CR2_MMS2_1 /*!< Update event is used as trigger output (TRGO2) */
  827. #define TIM_TRGO2_OC1 (TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< Capture or a compare match 1 is used as trigger output (TRGO2) */
  828. #define TIM_TRGO2_OC1REF TIM_CR2_MMS2_2 /*!< OC1REF signal is used as trigger output (TRGO2) */
  829. #define TIM_TRGO2_OC2REF (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_0) /*!< OC2REF signal is used as trigger output (TRGO2) */
  830. #define TIM_TRGO2_OC3REF (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1) /*!< OC3REF signal is used as trigger output (TRGO2) */
  831. #define TIM_TRGO2_OC4REF (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< OC4REF signal is used as trigger output (TRGO2) */
  832. #define TIM_TRGO2_OC5REF TIM_CR2_MMS2_3 /*!< OC5REF signal is used as trigger output (TRGO2) */
  833. #define TIM_TRGO2_OC6REF (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_0) /*!< OC6REF signal is used as trigger output (TRGO2) */
  834. #define TIM_TRGO2_OC4REF_RISINGFALLING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_1) /*!< OC4REF rising or falling edges generate pulses on TRGO2 */
  835. #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 */
  836. #define TIM_TRGO2_OC4REF_RISING_OC6REF_RISING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2) /*!< OC4REF or OC6REF rising edges generate pulses on TRGO2 */
  837. #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 */
  838. #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 */
  839. #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 */
  840. /**
  841. * @}
  842. */
  843. /** @defgroup TIM_Master_Slave_Mode TIM Master/Slave Mode
  844. * @{
  845. */
  846. #define TIM_MASTERSLAVEMODE_ENABLE TIM_SMCR_MSM /*!< No action */
  847. #define TIM_MASTERSLAVEMODE_DISABLE 0x00000000U /*!< Master/slave mode is selected */
  848. /**
  849. * @}
  850. */
  851. /** @defgroup TIM_Slave_Mode TIM Slave mode
  852. * @{
  853. */
  854. #define TIM_SLAVEMODE_DISABLE 0x00000000U /*!< Slave mode disabled */
  855. #define TIM_SLAVEMODE_RESET TIM_SMCR_SMS_2 /*!< Reset Mode */
  856. #define TIM_SLAVEMODE_GATED (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_0) /*!< Gated Mode */
  857. #define TIM_SLAVEMODE_TRIGGER (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1) /*!< Trigger Mode */
  858. #define TIM_SLAVEMODE_EXTERNAL1 (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0) /*!< External Clock Mode 1 */
  859. #define TIM_SLAVEMODE_COMBINED_RESETTRIGGER TIM_SMCR_SMS_3 /*!< Combined reset + trigger mode */
  860. /**
  861. * @}
  862. */
  863. /** @defgroup TIM_Output_Compare_and_PWM_modes TIM Output Compare and PWM Modes
  864. * @{
  865. */
  866. #define TIM_OCMODE_TIMING 0x00000000U /*!< Frozen */
  867. #define TIM_OCMODE_ACTIVE TIM_CCMR1_OC1M_0 /*!< Set channel to active level on match */
  868. #define TIM_OCMODE_INACTIVE TIM_CCMR1_OC1M_1 /*!< Set channel to inactive level on match */
  869. #define TIM_OCMODE_TOGGLE (TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0) /*!< Toggle */
  870. #define TIM_OCMODE_PWM1 (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1) /*!< PWM mode 1 */
  871. #define TIM_OCMODE_PWM2 (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0) /*!< PWM mode 2 */
  872. #define TIM_OCMODE_FORCED_ACTIVE (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_0) /*!< Force active level */
  873. #define TIM_OCMODE_FORCED_INACTIVE TIM_CCMR1_OC1M_2 /*!< Force inactive level */
  874. #define TIM_OCMODE_RETRIGERRABLE_OPM1 TIM_CCMR1_OC1M_3 /*!< Retrigerrable OPM mode 1 */
  875. #define TIM_OCMODE_RETRIGERRABLE_OPM2 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_0) /*!< Retrigerrable OPM mode 2 */
  876. #define TIM_OCMODE_COMBINED_PWM1 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_2) /*!< Combined PWM mode 1 */
  877. #define TIM_OCMODE_COMBINED_PWM2 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_0 | TIM_CCMR1_OC1M_2) /*!< Combined PWM mode 2 */
  878. #define TIM_OCMODE_ASSYMETRIC_PWM1 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2) /*!< Asymmetric PWM mode 1 */
  879. #define TIM_OCMODE_ASSYMETRIC_PWM2 TIM_CCMR1_OC1M /*!< Asymmetric PWM mode 2 */
  880. /**
  881. * @}
  882. */
  883. /** @defgroup TIM_Trigger_Selection TIM Trigger Selection
  884. * @{
  885. */
  886. #define TIM_TS_ITR0 0x00000000U /*!< Internal Trigger 0 (ITR0) */
  887. #define TIM_TS_ITR1 TIM_SMCR_TS_0 /*!< Internal Trigger 1 (ITR1) */
  888. #define TIM_TS_ITR2 TIM_SMCR_TS_1 /*!< Internal Trigger 2 (ITR2) */
  889. #define TIM_TS_ITR3 (TIM_SMCR_TS_0 | TIM_SMCR_TS_1) /*!< Internal Trigger 3 (ITR3) */
  890. #define TIM_TS_TI1F_ED TIM_SMCR_TS_2 /*!< TI1 Edge Detector (TI1F_ED) */
  891. #define TIM_TS_TI1FP1 (TIM_SMCR_TS_0 | TIM_SMCR_TS_2) /*!< Filtered Timer Input 1 (TI1FP1) */
  892. #define TIM_TS_TI2FP2 (TIM_SMCR_TS_1 | TIM_SMCR_TS_2) /*!< Filtered Timer Input 2 (TI2FP2) */
  893. #define TIM_TS_ETRF (TIM_SMCR_TS_0 | TIM_SMCR_TS_1 | TIM_SMCR_TS_2) /*!< Filtered External Trigger input (ETRF) */
  894. #define TIM_TS_NONE 0x0000FFFFU /*!< No trigger selected */
  895. /**
  896. * @}
  897. */
  898. /** @defgroup TIM_Trigger_Polarity TIM Trigger Polarity
  899. * @{
  900. */
  901. #define TIM_TRIGGERPOLARITY_INVERTED TIM_ETRPOLARITY_INVERTED /*!< Polarity for ETRx trigger sources */
  902. #define TIM_TRIGGERPOLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED /*!< Polarity for ETRx trigger sources */
  903. #define TIM_TRIGGERPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING /*!< Polarity for TIxFPx or TI1_ED trigger sources */
  904. #define TIM_TRIGGERPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING /*!< Polarity for TIxFPx or TI1_ED trigger sources */
  905. #define TIM_TRIGGERPOLARITY_BOTHEDGE TIM_INPUTCHANNELPOLARITY_BOTHEDGE /*!< Polarity for TIxFPx or TI1_ED trigger sources */
  906. /**
  907. * @}
  908. */
  909. /** @defgroup TIM_Trigger_Prescaler TIM Trigger Prescaler
  910. * @{
  911. */
  912. #define TIM_TRIGGERPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1 /*!< No prescaler is used */
  913. #define TIM_TRIGGERPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2 /*!< Prescaler for External ETR Trigger: Capture performed once every 2 events. */
  914. #define TIM_TRIGGERPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4 /*!< Prescaler for External ETR Trigger: Capture performed once every 4 events. */
  915. #define TIM_TRIGGERPRESCALER_DIV8 TIM_ETRPRESCALER_DIV8 /*!< Prescaler for External ETR Trigger: Capture performed once every 8 events. */
  916. /**
  917. * @}
  918. */
  919. /** @defgroup TIM_TI1_Selection TIM TI1 Input Selection
  920. * @{
  921. */
  922. #define TIM_TI1SELECTION_CH1 0x00000000U /*!< The TIMx_CH1 pin is connected to TI1 input */
  923. #define TIM_TI1SELECTION_XORCOMBINATION TIM_CR2_TI1S /*!< The TIMx_CH1, CH2 and CH3 pins are connected to the TI1 input (XOR combination) */
  924. /**
  925. * @}
  926. */
  927. /** @defgroup TIM_DMA_Burst_Length TIM DMA Burst Length
  928. * @{
  929. */
  930. #define TIM_DMABURSTLENGTH_1TRANSFER 0x00000000U /*!< The transfer is done to 1 register starting from TIMx_CR1 + TIMx_DCR.DBA */
  931. #define TIM_DMABURSTLENGTH_2TRANSFERS 0x00000100U /*!< The transfer is done to 2 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  932. #define TIM_DMABURSTLENGTH_3TRANSFERS 0x00000200U /*!< The transfer is done to 3 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  933. #define TIM_DMABURSTLENGTH_4TRANSFERS 0x00000300U /*!< The transfer is done to 4 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  934. #define TIM_DMABURSTLENGTH_5TRANSFERS 0x00000400U /*!< The transfer is done to 5 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  935. #define TIM_DMABURSTLENGTH_6TRANSFERS 0x00000500U /*!< The transfer is done to 6 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  936. #define TIM_DMABURSTLENGTH_7TRANSFERS 0x00000600U /*!< The transfer is done to 7 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  937. #define TIM_DMABURSTLENGTH_8TRANSFERS 0x00000700U /*!< The transfer is done to 8 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  938. #define TIM_DMABURSTLENGTH_9TRANSFERS 0x00000800U /*!< The transfer is done to 9 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  939. #define TIM_DMABURSTLENGTH_10TRANSFERS 0x00000900U /*!< The transfer is done to 10 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  940. #define TIM_DMABURSTLENGTH_11TRANSFERS 0x00000A00U /*!< The transfer is done to 11 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  941. #define TIM_DMABURSTLENGTH_12TRANSFERS 0x00000B00U /*!< The transfer is done to 12 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  942. #define TIM_DMABURSTLENGTH_13TRANSFERS 0x00000C00U /*!< The transfer is done to 13 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  943. #define TIM_DMABURSTLENGTH_14TRANSFERS 0x00000D00U /*!< The transfer is done to 14 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  944. #define TIM_DMABURSTLENGTH_15TRANSFERS 0x00000E00U /*!< The transfer is done to 15 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  945. #define TIM_DMABURSTLENGTH_16TRANSFERS 0x00000F00U /*!< The transfer is done to 16 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  946. #define TIM_DMABURSTLENGTH_17TRANSFERS 0x00001000U /*!< The transfer is done to 17 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  947. #define TIM_DMABURSTLENGTH_18TRANSFERS 0x00001100U /*!< The transfer is done to 18 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
  948. /**
  949. * @}
  950. */
  951. /** @defgroup DMA_Handle_index TIM DMA Handle Index
  952. * @{
  953. */
  954. #define TIM_DMA_ID_UPDATE ((uint16_t) 0x0000) /*!< Index of the DMA handle used for Update DMA requests */
  955. #define TIM_DMA_ID_CC1 ((uint16_t) 0x0001) /*!< Index of the DMA handle used for Capture/Compare 1 DMA requests */
  956. #define TIM_DMA_ID_CC2 ((uint16_t) 0x0002) /*!< Index of the DMA handle used for Capture/Compare 2 DMA requests */
  957. #define TIM_DMA_ID_CC3 ((uint16_t) 0x0003) /*!< Index of the DMA handle used for Capture/Compare 3 DMA requests */
  958. #define TIM_DMA_ID_CC4 ((uint16_t) 0x0004) /*!< Index of the DMA handle used for Capture/Compare 4 DMA requests */
  959. #define TIM_DMA_ID_COMMUTATION ((uint16_t) 0x0005) /*!< Index of the DMA handle used for Commutation DMA requests */
  960. #define TIM_DMA_ID_TRIGGER ((uint16_t) 0x0006) /*!< Index of the DMA handle used for Trigger DMA requests */
  961. /**
  962. * @}
  963. */
  964. /** @defgroup Channel_CC_State TIM Capture/Compare Channel State
  965. * @{
  966. */
  967. #define TIM_CCx_ENABLE 0x00000001U /*!< Input or output channel is enabled */
  968. #define TIM_CCx_DISABLE 0x00000000U /*!< Input or output channel is disabled */
  969. #define TIM_CCxN_ENABLE 0x00000004U /*!< Complementary output channel is enabled */
  970. #define TIM_CCxN_DISABLE 0x00000000U /*!< Complementary output channel is enabled */
  971. /**
  972. * @}
  973. */
  974. /** @defgroup TIM_Break_System TIM Break System
  975. * @{
  976. */
  977. #define TIM_BREAK_SYSTEM_ECC SYSCFG_CFGR2_ECCL /*!< Enables and locks the ECC error signal with Break Input of TIM1/8/15/16/17 */
  978. #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 */
  979. #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 */
  980. #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 */
  981. /**
  982. * @}
  983. */
  984. /**
  985. * @}
  986. */
  987. /* End of exported constants -------------------------------------------------*/
  988. /* Exported macros -----------------------------------------------------------*/
  989. /** @defgroup TIM_Exported_Macros TIM Exported Macros
  990. * @{
  991. */
  992. /** @brief Reset TIM handle state.
  993. * @param __HANDLE__ TIM handle.
  994. * @retval None
  995. */
  996. #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
  997. #define __HAL_TIM_RESET_HANDLE_STATE(__HANDLE__) do { \
  998. (__HANDLE__)->State = HAL_TIM_STATE_RESET; \
  999. (__HANDLE__)->ChannelState[0] = HAL_TIM_CHANNEL_STATE_RESET; \
  1000. (__HANDLE__)->ChannelState[1] = HAL_TIM_CHANNEL_STATE_RESET; \
  1001. (__HANDLE__)->ChannelState[2] = HAL_TIM_CHANNEL_STATE_RESET; \
  1002. (__HANDLE__)->ChannelState[3] = HAL_TIM_CHANNEL_STATE_RESET; \
  1003. (__HANDLE__)->ChannelState[4] = HAL_TIM_CHANNEL_STATE_RESET; \
  1004. (__HANDLE__)->ChannelState[5] = HAL_TIM_CHANNEL_STATE_RESET; \
  1005. (__HANDLE__)->ChannelNState[0] = HAL_TIM_CHANNEL_STATE_RESET; \
  1006. (__HANDLE__)->ChannelNState[1] = HAL_TIM_CHANNEL_STATE_RESET; \
  1007. (__HANDLE__)->ChannelNState[2] = HAL_TIM_CHANNEL_STATE_RESET; \
  1008. (__HANDLE__)->ChannelNState[3] = HAL_TIM_CHANNEL_STATE_RESET; \
  1009. (__HANDLE__)->DMABurstState = HAL_DMA_BURST_STATE_RESET; \
  1010. (__HANDLE__)->Base_MspInitCallback = NULL; \
  1011. (__HANDLE__)->Base_MspDeInitCallback = NULL; \
  1012. (__HANDLE__)->IC_MspInitCallback = NULL; \
  1013. (__HANDLE__)->IC_MspDeInitCallback = NULL; \
  1014. (__HANDLE__)->OC_MspInitCallback = NULL; \
  1015. (__HANDLE__)->OC_MspDeInitCallback = NULL; \
  1016. (__HANDLE__)->PWM_MspInitCallback = NULL; \
  1017. (__HANDLE__)->PWM_MspDeInitCallback = NULL; \
  1018. (__HANDLE__)->OnePulse_MspInitCallback = NULL; \
  1019. (__HANDLE__)->OnePulse_MspDeInitCallback = NULL; \
  1020. (__HANDLE__)->Encoder_MspInitCallback = NULL; \
  1021. (__HANDLE__)->Encoder_MspDeInitCallback = NULL; \
  1022. (__HANDLE__)->HallSensor_MspInitCallback = NULL; \
  1023. (__HANDLE__)->HallSensor_MspDeInitCallback = NULL; \
  1024. } while(0)
  1025. #else
  1026. #define __HAL_TIM_RESET_HANDLE_STATE(__HANDLE__) do { \
  1027. (__HANDLE__)->State = HAL_TIM_STATE_RESET; \
  1028. (__HANDLE__)->ChannelState[0] = HAL_TIM_CHANNEL_STATE_RESET; \
  1029. (__HANDLE__)->ChannelState[1] = HAL_TIM_CHANNEL_STATE_RESET; \
  1030. (__HANDLE__)->ChannelState[2] = HAL_TIM_CHANNEL_STATE_RESET; \
  1031. (__HANDLE__)->ChannelState[3] = HAL_TIM_CHANNEL_STATE_RESET; \
  1032. (__HANDLE__)->ChannelState[4] = HAL_TIM_CHANNEL_STATE_RESET; \
  1033. (__HANDLE__)->ChannelState[5] = HAL_TIM_CHANNEL_STATE_RESET; \
  1034. (__HANDLE__)->ChannelNState[0] = HAL_TIM_CHANNEL_STATE_RESET; \
  1035. (__HANDLE__)->ChannelNState[1] = HAL_TIM_CHANNEL_STATE_RESET; \
  1036. (__HANDLE__)->ChannelNState[2] = HAL_TIM_CHANNEL_STATE_RESET; \
  1037. (__HANDLE__)->ChannelNState[3] = HAL_TIM_CHANNEL_STATE_RESET; \
  1038. (__HANDLE__)->DMABurstState = HAL_DMA_BURST_STATE_RESET; \
  1039. } while(0)
  1040. #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
  1041. /**
  1042. * @brief Enable the TIM peripheral.
  1043. * @param __HANDLE__ TIM handle
  1044. * @retval None
  1045. */
  1046. #define __HAL_TIM_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1|=(TIM_CR1_CEN))
  1047. /**
  1048. * @brief Enable the TIM main Output.
  1049. * @param __HANDLE__ TIM handle
  1050. * @retval None
  1051. */
  1052. #define __HAL_TIM_MOE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->BDTR|=(TIM_BDTR_MOE))
  1053. /**
  1054. * @brief Disable the TIM peripheral.
  1055. * @param __HANDLE__ TIM handle
  1056. * @retval None
  1057. */
  1058. #define __HAL_TIM_DISABLE(__HANDLE__) \
  1059. do { \
  1060. if (((__HANDLE__)->Instance->CCER & TIM_CCER_CCxE_MASK) == 0UL) \
  1061. { \
  1062. if(((__HANDLE__)->Instance->CCER & TIM_CCER_CCxNE_MASK) == 0UL) \
  1063. { \
  1064. (__HANDLE__)->Instance->CR1 &= ~(TIM_CR1_CEN); \
  1065. } \
  1066. } \
  1067. } while(0)
  1068. /**
  1069. * @brief Disable the TIM main Output.
  1070. * @param __HANDLE__ TIM handle
  1071. * @retval None
  1072. * @note The Main Output Enable of a timer instance is disabled only if all the CCx and CCxN channels have been
  1073. * disabled
  1074. */
  1075. #define __HAL_TIM_MOE_DISABLE(__HANDLE__) \
  1076. do { \
  1077. if (((__HANDLE__)->Instance->CCER & TIM_CCER_CCxE_MASK) == 0UL) \
  1078. { \
  1079. if(((__HANDLE__)->Instance->CCER & TIM_CCER_CCxNE_MASK) == 0UL) \
  1080. { \
  1081. (__HANDLE__)->Instance->BDTR &= ~(TIM_BDTR_MOE); \
  1082. } \
  1083. } \
  1084. } while(0)
  1085. /**
  1086. * @brief Disable the TIM main Output.
  1087. * @param __HANDLE__ TIM handle
  1088. * @retval None
  1089. * @note The Main Output Enable of a timer instance is disabled unconditionally
  1090. */
  1091. #define __HAL_TIM_MOE_DISABLE_UNCONDITIONALLY(__HANDLE__) (__HANDLE__)->Instance->BDTR &= ~(TIM_BDTR_MOE)
  1092. /** @brief Enable the specified TIM interrupt.
  1093. * @param __HANDLE__ specifies the TIM Handle.
  1094. * @param __INTERRUPT__ specifies the TIM interrupt source to enable.
  1095. * This parameter can be one of the following values:
  1096. * @arg TIM_IT_UPDATE: Update interrupt
  1097. * @arg TIM_IT_CC1: Capture/Compare 1 interrupt
  1098. * @arg TIM_IT_CC2: Capture/Compare 2 interrupt
  1099. * @arg TIM_IT_CC3: Capture/Compare 3 interrupt
  1100. * @arg TIM_IT_CC4: Capture/Compare 4 interrupt
  1101. * @arg TIM_IT_COM: Commutation interrupt
  1102. * @arg TIM_IT_TRIGGER: Trigger interrupt
  1103. * @arg TIM_IT_BREAK: Break interrupt
  1104. * @retval None
  1105. */
  1106. #define __HAL_TIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DIER |= (__INTERRUPT__))
  1107. /** @brief Disable the specified TIM interrupt.
  1108. * @param __HANDLE__ specifies the TIM Handle.
  1109. * @param __INTERRUPT__ specifies the TIM interrupt source to disable.
  1110. * This parameter can be one of the following values:
  1111. * @arg TIM_IT_UPDATE: Update interrupt
  1112. * @arg TIM_IT_CC1: Capture/Compare 1 interrupt
  1113. * @arg TIM_IT_CC2: Capture/Compare 2 interrupt
  1114. * @arg TIM_IT_CC3: Capture/Compare 3 interrupt
  1115. * @arg TIM_IT_CC4: Capture/Compare 4 interrupt
  1116. * @arg TIM_IT_COM: Commutation interrupt
  1117. * @arg TIM_IT_TRIGGER: Trigger interrupt
  1118. * @arg TIM_IT_BREAK: Break interrupt
  1119. * @retval None
  1120. */
  1121. #define __HAL_TIM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DIER &= ~(__INTERRUPT__))
  1122. /** @brief Enable the specified DMA request.
  1123. * @param __HANDLE__ specifies the TIM Handle.
  1124. * @param __DMA__ specifies the TIM DMA request to enable.
  1125. * This parameter can be one of the following values:
  1126. * @arg TIM_DMA_UPDATE: Update DMA request
  1127. * @arg TIM_DMA_CC1: Capture/Compare 1 DMA request
  1128. * @arg TIM_DMA_CC2: Capture/Compare 2 DMA request
  1129. * @arg TIM_DMA_CC3: Capture/Compare 3 DMA request
  1130. * @arg TIM_DMA_CC4: Capture/Compare 4 DMA request
  1131. * @arg TIM_DMA_COM: Commutation DMA request
  1132. * @arg TIM_DMA_TRIGGER: Trigger DMA request
  1133. * @retval None
  1134. */
  1135. #define __HAL_TIM_ENABLE_DMA(__HANDLE__, __DMA__) ((__HANDLE__)->Instance->DIER |= (__DMA__))
  1136. /** @brief Disable the specified DMA request.
  1137. * @param __HANDLE__ specifies the TIM Handle.
  1138. * @param __DMA__ specifies the TIM DMA request to disable.
  1139. * This parameter can be one of the following values:
  1140. * @arg TIM_DMA_UPDATE: Update DMA request
  1141. * @arg TIM_DMA_CC1: Capture/Compare 1 DMA request
  1142. * @arg TIM_DMA_CC2: Capture/Compare 2 DMA request
  1143. * @arg TIM_DMA_CC3: Capture/Compare 3 DMA request
  1144. * @arg TIM_DMA_CC4: Capture/Compare 4 DMA request
  1145. * @arg TIM_DMA_COM: Commutation DMA request
  1146. * @arg TIM_DMA_TRIGGER: Trigger DMA request
  1147. * @retval None
  1148. */
  1149. #define __HAL_TIM_DISABLE_DMA(__HANDLE__, __DMA__) ((__HANDLE__)->Instance->DIER &= ~(__DMA__))
  1150. /** @brief Check whether the specified TIM interrupt flag is set or not.
  1151. * @param __HANDLE__ specifies the TIM Handle.
  1152. * @param __FLAG__ specifies the TIM interrupt flag to check.
  1153. * This parameter can be one of the following values:
  1154. * @arg TIM_FLAG_UPDATE: Update interrupt flag
  1155. * @arg TIM_FLAG_CC1: Capture/Compare 1 interrupt flag
  1156. * @arg TIM_FLAG_CC2: Capture/Compare 2 interrupt flag
  1157. * @arg TIM_FLAG_CC3: Capture/Compare 3 interrupt flag
  1158. * @arg TIM_FLAG_CC4: Capture/Compare 4 interrupt flag
  1159. * @arg TIM_FLAG_CC5: Compare 5 interrupt flag
  1160. * @arg TIM_FLAG_CC6: Compare 6 interrupt flag
  1161. * @arg TIM_FLAG_COM: Commutation interrupt flag
  1162. * @arg TIM_FLAG_TRIGGER: Trigger interrupt flag
  1163. * @arg TIM_FLAG_BREAK: Break interrupt flag
  1164. * @arg TIM_FLAG_BREAK2: Break 2 interrupt flag
  1165. * @arg TIM_FLAG_SYSTEM_BREAK: System Break interrupt flag
  1166. * @arg TIM_FLAG_CC1OF: Capture/Compare 1 overcapture flag
  1167. * @arg TIM_FLAG_CC2OF: Capture/Compare 2 overcapture flag
  1168. * @arg TIM_FLAG_CC3OF: Capture/Compare 3 overcapture flag
  1169. * @arg TIM_FLAG_CC4OF: Capture/Compare 4 overcapture flag
  1170. * @retval The new state of __FLAG__ (TRUE or FALSE).
  1171. */
  1172. #define __HAL_TIM_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR &(__FLAG__)) == (__FLAG__))
  1173. /** @brief Clear the specified TIM interrupt flag.
  1174. * @param __HANDLE__ specifies the TIM Handle.
  1175. * @param __FLAG__ specifies the TIM interrupt flag to clear.
  1176. * This parameter can be one of the following values:
  1177. * @arg TIM_FLAG_UPDATE: Update interrupt flag
  1178. * @arg TIM_FLAG_CC1: Capture/Compare 1 interrupt flag
  1179. * @arg TIM_FLAG_CC2: Capture/Compare 2 interrupt flag
  1180. * @arg TIM_FLAG_CC3: Capture/Compare 3 interrupt flag
  1181. * @arg TIM_FLAG_CC4: Capture/Compare 4 interrupt flag
  1182. * @arg TIM_FLAG_CC5: Compare 5 interrupt flag
  1183. * @arg TIM_FLAG_CC6: Compare 6 interrupt flag
  1184. * @arg TIM_FLAG_COM: Commutation interrupt flag
  1185. * @arg TIM_FLAG_TRIGGER: Trigger interrupt flag
  1186. * @arg TIM_FLAG_BREAK: Break interrupt flag
  1187. * @arg TIM_FLAG_BREAK2: Break 2 interrupt flag
  1188. * @arg TIM_FLAG_SYSTEM_BREAK: System Break interrupt flag
  1189. * @arg TIM_FLAG_CC1OF: Capture/Compare 1 overcapture flag
  1190. * @arg TIM_FLAG_CC2OF: Capture/Compare 2 overcapture flag
  1191. * @arg TIM_FLAG_CC3OF: Capture/Compare 3 overcapture flag
  1192. * @arg TIM_FLAG_CC4OF: Capture/Compare 4 overcapture flag
  1193. * @retval The new state of __FLAG__ (TRUE or FALSE).
  1194. */
  1195. #define __HAL_TIM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
  1196. /**
  1197. * @brief Check whether the specified TIM interrupt source is enabled or not.
  1198. * @param __HANDLE__ TIM handle
  1199. * @param __INTERRUPT__ specifies the TIM interrupt source to check.
  1200. * This parameter can be one of the following values:
  1201. * @arg TIM_IT_UPDATE: Update interrupt
  1202. * @arg TIM_IT_CC1: Capture/Compare 1 interrupt
  1203. * @arg TIM_IT_CC2: Capture/Compare 2 interrupt
  1204. * @arg TIM_IT_CC3: Capture/Compare 3 interrupt
  1205. * @arg TIM_IT_CC4: Capture/Compare 4 interrupt
  1206. * @arg TIM_IT_COM: Commutation interrupt
  1207. * @arg TIM_IT_TRIGGER: Trigger interrupt
  1208. * @arg TIM_IT_BREAK: Break interrupt
  1209. * @retval The state of TIM_IT (SET or RESET).
  1210. */
  1211. #define __HAL_TIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->DIER & (__INTERRUPT__)) \
  1212. == (__INTERRUPT__)) ? SET : RESET)
  1213. /** @brief Clear the TIM interrupt pending bits.
  1214. * @param __HANDLE__ TIM handle
  1215. * @param __INTERRUPT__ specifies the interrupt pending bit to clear.
  1216. * This parameter can be one of the following values:
  1217. * @arg TIM_IT_UPDATE: Update interrupt
  1218. * @arg TIM_IT_CC1: Capture/Compare 1 interrupt
  1219. * @arg TIM_IT_CC2: Capture/Compare 2 interrupt
  1220. * @arg TIM_IT_CC3: Capture/Compare 3 interrupt
  1221. * @arg TIM_IT_CC4: Capture/Compare 4 interrupt
  1222. * @arg TIM_IT_COM: Commutation interrupt
  1223. * @arg TIM_IT_TRIGGER: Trigger interrupt
  1224. * @arg TIM_IT_BREAK: Break interrupt
  1225. * @retval None
  1226. */
  1227. #define __HAL_TIM_CLEAR_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->SR = ~(__INTERRUPT__))
  1228. /**
  1229. * @brief Force a continuous copy of the update interrupt flag (UIF) into the timer counter register (bit 31).
  1230. * @note This allows both the counter value and a potential roll-over condition signalled by the UIFCPY flag to be read
  1231. * in an atomic way.
  1232. * @param __HANDLE__ TIM handle.
  1233. * @retval None
  1234. mode.
  1235. */
  1236. #define __HAL_TIM_UIFREMAP_ENABLE(__HANDLE__) (((__HANDLE__)->Instance->CR1 |= TIM_CR1_UIFREMAP))
  1237. /**
  1238. * @brief Disable update interrupt flag (UIF) remapping.
  1239. * @param __HANDLE__ TIM handle.
  1240. * @retval None
  1241. mode.
  1242. */
  1243. #define __HAL_TIM_UIFREMAP_DISABLE(__HANDLE__) (((__HANDLE__)->Instance->CR1 &= ~TIM_CR1_UIFREMAP))
  1244. /**
  1245. * @brief Get update interrupt flag (UIF) copy status.
  1246. * @param __COUNTER__ Counter value.
  1247. * @retval The state of UIFCPY (TRUE or FALSE).
  1248. mode.
  1249. */
  1250. #define __HAL_TIM_GET_UIFCPY(__COUNTER__) (((__COUNTER__) & (TIM_CNT_UIFCPY)) == (TIM_CNT_UIFCPY))
  1251. /**
  1252. * @brief Indicates whether or not the TIM Counter is used as downcounter.
  1253. * @param __HANDLE__ TIM handle.
  1254. * @retval False (Counter used as upcounter) or True (Counter used as downcounter)
  1255. * @note This macro is particularly useful to get the counting mode when the timer operates in Center-aligned mode
  1256. * or Encoder mode.
  1257. */
  1258. #define __HAL_TIM_IS_TIM_COUNTING_DOWN(__HANDLE__) (((__HANDLE__)->Instance->CR1 &(TIM_CR1_DIR)) == (TIM_CR1_DIR))
  1259. /**
  1260. * @brief Set the TIM Prescaler on runtime.
  1261. * @param __HANDLE__ TIM handle.
  1262. * @param __PRESC__ specifies the Prescaler new value.
  1263. * @retval None
  1264. */
  1265. #define __HAL_TIM_SET_PRESCALER(__HANDLE__, __PRESC__) ((__HANDLE__)->Instance->PSC = (__PRESC__))
  1266. /**
  1267. * @brief Set the TIM Counter Register value on runtime.
  1268. * Note Please check if the bit 31 of CNT register is used as UIF copy or not, this may affect the counter range in
  1269. * case of 32 bits counter TIM instance.
  1270. * Bit 31 of CNT can be enabled/disabled using __HAL_TIM_UIFREMAP_ENABLE()/__HAL_TIM_UIFREMAP_DISABLE() macros.
  1271. * @param __HANDLE__ TIM handle.
  1272. * @param __COUNTER__ specifies the Counter register new value.
  1273. * @retval None
  1274. */
  1275. #define __HAL_TIM_SET_COUNTER(__HANDLE__, __COUNTER__) ((__HANDLE__)->Instance->CNT = (__COUNTER__))
  1276. /**
  1277. * @brief Get the TIM Counter Register value on runtime.
  1278. * @param __HANDLE__ TIM handle.
  1279. * @retval 16-bit or 32-bit value of the timer counter register (TIMx_CNT)
  1280. */
  1281. #define __HAL_TIM_GET_COUNTER(__HANDLE__) ((__HANDLE__)->Instance->CNT)
  1282. /**
  1283. * @brief Set the TIM Autoreload Register value on runtime without calling another time any Init function.
  1284. * @param __HANDLE__ TIM handle.
  1285. * @param __AUTORELOAD__ specifies the Counter register new value.
  1286. * @retval None
  1287. */
  1288. #define __HAL_TIM_SET_AUTORELOAD(__HANDLE__, __AUTORELOAD__) \
  1289. do{ \
  1290. (__HANDLE__)->Instance->ARR = (__AUTORELOAD__); \
  1291. (__HANDLE__)->Init.Period = (__AUTORELOAD__); \
  1292. } while(0)
  1293. /**
  1294. * @brief Get the TIM Autoreload Register value on runtime.
  1295. * @param __HANDLE__ TIM handle.
  1296. * @retval 16-bit or 32-bit value of the timer auto-reload register(TIMx_ARR)
  1297. */
  1298. #define __HAL_TIM_GET_AUTORELOAD(__HANDLE__) ((__HANDLE__)->Instance->ARR)
  1299. /**
  1300. * @brief Set the TIM Clock Division value on runtime without calling another time any Init function.
  1301. * @param __HANDLE__ TIM handle.
  1302. * @param __CKD__ specifies the clock division value.
  1303. * This parameter can be one of the following value:
  1304. * @arg TIM_CLOCKDIVISION_DIV1: tDTS=tCK_INT
  1305. * @arg TIM_CLOCKDIVISION_DIV2: tDTS=2*tCK_INT
  1306. * @arg TIM_CLOCKDIVISION_DIV4: tDTS=4*tCK_INT
  1307. * @retval None
  1308. */
  1309. #define __HAL_TIM_SET_CLOCKDIVISION(__HANDLE__, __CKD__) \
  1310. do{ \
  1311. (__HANDLE__)->Instance->CR1 &= (~TIM_CR1_CKD); \
  1312. (__HANDLE__)->Instance->CR1 |= (__CKD__); \
  1313. (__HANDLE__)->Init.ClockDivision = (__CKD__); \
  1314. } while(0)
  1315. /**
  1316. * @brief Get the TIM Clock Division value on runtime.
  1317. * @param __HANDLE__ TIM handle.
  1318. * @retval The clock division can be one of the following values:
  1319. * @arg TIM_CLOCKDIVISION_DIV1: tDTS=tCK_INT
  1320. * @arg TIM_CLOCKDIVISION_DIV2: tDTS=2*tCK_INT
  1321. * @arg TIM_CLOCKDIVISION_DIV4: tDTS=4*tCK_INT
  1322. */
  1323. #define __HAL_TIM_GET_CLOCKDIVISION(__HANDLE__) ((__HANDLE__)->Instance->CR1 & TIM_CR1_CKD)
  1324. /**
  1325. * @brief Set the TIM Input Capture prescaler on runtime without calling another time HAL_TIM_IC_ConfigChannel()
  1326. * function.
  1327. * @param __HANDLE__ TIM handle.
  1328. * @param __CHANNEL__ TIM Channels to be configured.
  1329. * This parameter can be one of the following values:
  1330. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  1331. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  1332. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  1333. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  1334. * @param __ICPSC__ specifies the Input Capture4 prescaler new value.
  1335. * This parameter can be one of the following values:
  1336. * @arg TIM_ICPSC_DIV1: no prescaler
  1337. * @arg TIM_ICPSC_DIV2: capture is done once every 2 events
  1338. * @arg TIM_ICPSC_DIV4: capture is done once every 4 events
  1339. * @arg TIM_ICPSC_DIV8: capture is done once every 8 events
  1340. * @retval None
  1341. */
  1342. #define __HAL_TIM_SET_ICPRESCALER(__HANDLE__, __CHANNEL__, __ICPSC__) \
  1343. do{ \
  1344. TIM_RESET_ICPRESCALERVALUE((__HANDLE__), (__CHANNEL__)); \
  1345. TIM_SET_ICPRESCALERVALUE((__HANDLE__), (__CHANNEL__), (__ICPSC__)); \
  1346. } while(0)
  1347. /**
  1348. * @brief Get the TIM Input Capture prescaler on runtime.
  1349. * @param __HANDLE__ TIM handle.
  1350. * @param __CHANNEL__ TIM Channels to be configured.
  1351. * This parameter can be one of the following values:
  1352. * @arg TIM_CHANNEL_1: get input capture 1 prescaler value
  1353. * @arg TIM_CHANNEL_2: get input capture 2 prescaler value
  1354. * @arg TIM_CHANNEL_3: get input capture 3 prescaler value
  1355. * @arg TIM_CHANNEL_4: get input capture 4 prescaler value
  1356. * @retval The input capture prescaler can be one of the following values:
  1357. * @arg TIM_ICPSC_DIV1: no prescaler
  1358. * @arg TIM_ICPSC_DIV2: capture is done once every 2 events
  1359. * @arg TIM_ICPSC_DIV4: capture is done once every 4 events
  1360. * @arg TIM_ICPSC_DIV8: capture is done once every 8 events
  1361. */
  1362. #define __HAL_TIM_GET_ICPRESCALER(__HANDLE__, __CHANNEL__) \
  1363. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 & TIM_CCMR1_IC1PSC) :\
  1364. ((__CHANNEL__) == TIM_CHANNEL_2) ? (((__HANDLE__)->Instance->CCMR1 & TIM_CCMR1_IC2PSC) >> 8U) :\
  1365. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 & TIM_CCMR2_IC3PSC) :\
  1366. (((__HANDLE__)->Instance->CCMR2 & TIM_CCMR2_IC4PSC)) >> 8U)
  1367. /**
  1368. * @brief Set the TIM Capture Compare Register value on runtime without calling another time ConfigChannel function.
  1369. * @param __HANDLE__ TIM handle.
  1370. * @param __CHANNEL__ TIM Channels to be configured.
  1371. * This parameter can be one of the following values:
  1372. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  1373. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  1374. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  1375. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  1376. * @arg TIM_CHANNEL_5: TIM Channel 5 selected
  1377. * @arg TIM_CHANNEL_6: TIM Channel 6 selected
  1378. * @param __COMPARE__ specifies the Capture Compare register new value.
  1379. * @retval None
  1380. */
  1381. #define __HAL_TIM_SET_COMPARE(__HANDLE__, __CHANNEL__, __COMPARE__) \
  1382. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCR1 = (__COMPARE__)) :\
  1383. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCR2 = (__COMPARE__)) :\
  1384. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCR3 = (__COMPARE__)) :\
  1385. ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCR4 = (__COMPARE__)) :\
  1386. ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCR5 = (__COMPARE__)) :\
  1387. ((__HANDLE__)->Instance->CCR6 = (__COMPARE__)))
  1388. /**
  1389. * @brief Get the TIM Capture Compare Register value on runtime.
  1390. * @param __HANDLE__ TIM handle.
  1391. * @param __CHANNEL__ TIM Channel associated with the capture compare register
  1392. * This parameter can be one of the following values:
  1393. * @arg TIM_CHANNEL_1: get capture/compare 1 register value
  1394. * @arg TIM_CHANNEL_2: get capture/compare 2 register value
  1395. * @arg TIM_CHANNEL_3: get capture/compare 3 register value
  1396. * @arg TIM_CHANNEL_4: get capture/compare 4 register value
  1397. * @arg TIM_CHANNEL_5: get capture/compare 5 register value
  1398. * @arg TIM_CHANNEL_6: get capture/compare 6 register value
  1399. * @retval 16-bit or 32-bit value of the capture/compare register (TIMx_CCRy)
  1400. */
  1401. #define __HAL_TIM_GET_COMPARE(__HANDLE__, __CHANNEL__) \
  1402. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCR1) :\
  1403. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCR2) :\
  1404. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCR3) :\
  1405. ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCR4) :\
  1406. ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCR5) :\
  1407. ((__HANDLE__)->Instance->CCR6))
  1408. /**
  1409. * @brief Set the TIM Output compare preload.
  1410. * @param __HANDLE__ TIM handle.
  1411. * @param __CHANNEL__ TIM Channels to be configured.
  1412. * This parameter can be one of the following values:
  1413. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  1414. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  1415. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  1416. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  1417. * @arg TIM_CHANNEL_5: TIM Channel 5 selected
  1418. * @arg TIM_CHANNEL_6: TIM Channel 6 selected
  1419. * @retval None
  1420. */
  1421. #define __HAL_TIM_ENABLE_OCxPRELOAD(__HANDLE__, __CHANNEL__) \
  1422. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 |= TIM_CCMR1_OC1PE) :\
  1423. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 |= TIM_CCMR1_OC2PE) :\
  1424. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 |= TIM_CCMR2_OC3PE) :\
  1425. ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCMR2 |= TIM_CCMR2_OC4PE) :\
  1426. ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCMR3 |= TIM_CCMR3_OC5PE) :\
  1427. ((__HANDLE__)->Instance->CCMR3 |= TIM_CCMR3_OC6PE))
  1428. /**
  1429. * @brief Reset the TIM Output compare preload.
  1430. * @param __HANDLE__ TIM handle.
  1431. * @param __CHANNEL__ TIM Channels to be configured.
  1432. * This parameter can be one of the following values:
  1433. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  1434. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  1435. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  1436. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  1437. * @arg TIM_CHANNEL_5: TIM Channel 5 selected
  1438. * @arg TIM_CHANNEL_6: TIM Channel 6 selected
  1439. * @retval None
  1440. */
  1441. #define __HAL_TIM_DISABLE_OCxPRELOAD(__HANDLE__, __CHANNEL__) \
  1442. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_OC1PE) :\
  1443. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_OC2PE) :\
  1444. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_OC3PE) :\
  1445. ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_OC4PE) :\
  1446. ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCMR3 &= ~TIM_CCMR3_OC5PE) :\
  1447. ((__HANDLE__)->Instance->CCMR3 &= ~TIM_CCMR3_OC6PE))
  1448. /**
  1449. * @brief Enable fast mode for a given channel.
  1450. * @param __HANDLE__ TIM handle.
  1451. * @param __CHANNEL__ TIM Channels to be configured.
  1452. * This parameter can be one of the following values:
  1453. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  1454. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  1455. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  1456. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  1457. * @arg TIM_CHANNEL_5: TIM Channel 5 selected
  1458. * @arg TIM_CHANNEL_6: TIM Channel 6 selected
  1459. * @note When fast mode is enabled an active edge on the trigger input acts
  1460. * like a compare match on CCx output. Delay to sample the trigger
  1461. * input and to activate CCx output is reduced to 3 clock cycles.
  1462. * @note Fast mode acts only if the channel is configured in PWM1 or PWM2 mode.
  1463. * @retval None
  1464. */
  1465. #define __HAL_TIM_ENABLE_OCxFAST(__HANDLE__, __CHANNEL__) \
  1466. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 |= TIM_CCMR1_OC1FE) :\
  1467. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 |= TIM_CCMR1_OC2FE) :\
  1468. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 |= TIM_CCMR2_OC3FE) :\
  1469. ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCMR2 |= TIM_CCMR2_OC4FE) :\
  1470. ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCMR3 |= TIM_CCMR3_OC5FE) :\
  1471. ((__HANDLE__)->Instance->CCMR3 |= TIM_CCMR3_OC6FE))
  1472. /**
  1473. * @brief Disable fast mode for a given channel.
  1474. * @param __HANDLE__ TIM handle.
  1475. * @param __CHANNEL__ TIM Channels to be configured.
  1476. * This parameter can be one of the following values:
  1477. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  1478. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  1479. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  1480. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  1481. * @arg TIM_CHANNEL_5: TIM Channel 5 selected
  1482. * @arg TIM_CHANNEL_6: TIM Channel 6 selected
  1483. * @note When fast mode is disabled CCx output behaves normally depending
  1484. * on counter and CCRx values even when the trigger is ON. The minimum
  1485. * delay to activate CCx output when an active edge occurs on the
  1486. * trigger input is 5 clock cycles.
  1487. * @retval None
  1488. */
  1489. #define __HAL_TIM_DISABLE_OCxFAST(__HANDLE__, __CHANNEL__) \
  1490. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_OC1FE) :\
  1491. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_OC2FE) :\
  1492. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_OC3FE) :\
  1493. ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_OC4FE) :\
  1494. ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCMR3 &= ~TIM_CCMR3_OC5FE) :\
  1495. ((__HANDLE__)->Instance->CCMR3 &= ~TIM_CCMR3_OC6FE))
  1496. /**
  1497. * @brief Set the Update Request Source (URS) bit of the TIMx_CR1 register.
  1498. * @param __HANDLE__ TIM handle.
  1499. * @note When the URS bit of the TIMx_CR1 register is set, only counter
  1500. * overflow/underflow generates an update interrupt or DMA request (if
  1501. * enabled)
  1502. * @retval None
  1503. */
  1504. #define __HAL_TIM_URS_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1|= TIM_CR1_URS)
  1505. /**
  1506. * @brief Reset the Update Request Source (URS) bit of the TIMx_CR1 register.
  1507. * @param __HANDLE__ TIM handle.
  1508. * @note When the URS bit of the TIMx_CR1 register is reset, any of the
  1509. * following events generate an update interrupt or DMA request (if
  1510. * enabled):
  1511. * _ Counter overflow underflow
  1512. * _ Setting the UG bit
  1513. * _ Update generation through the slave mode controller
  1514. * @retval None
  1515. */
  1516. #define __HAL_TIM_URS_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1&=~TIM_CR1_URS)
  1517. /**
  1518. * @brief Set the TIM Capture x input polarity on runtime.
  1519. * @param __HANDLE__ TIM handle.
  1520. * @param __CHANNEL__ TIM Channels to be configured.
  1521. * This parameter can be one of the following values:
  1522. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  1523. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  1524. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  1525. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  1526. * @param __POLARITY__ Polarity for TIx source
  1527. * @arg TIM_INPUTCHANNELPOLARITY_RISING: Rising Edge
  1528. * @arg TIM_INPUTCHANNELPOLARITY_FALLING: Falling Edge
  1529. * @arg TIM_INPUTCHANNELPOLARITY_BOTHEDGE: Rising and Falling Edge
  1530. * @retval None
  1531. */
  1532. #define __HAL_TIM_SET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__, __POLARITY__) \
  1533. do{ \
  1534. TIM_RESET_CAPTUREPOLARITY((__HANDLE__), (__CHANNEL__)); \
  1535. TIM_SET_CAPTUREPOLARITY((__HANDLE__), (__CHANNEL__), (__POLARITY__)); \
  1536. }while(0)
  1537. /**
  1538. * @}
  1539. */
  1540. /* End of exported macros ----------------------------------------------------*/
  1541. /* Private constants ---------------------------------------------------------*/
  1542. /** @defgroup TIM_Private_Constants TIM Private Constants
  1543. * @{
  1544. */
  1545. /* The counter of a timer instance is disabled only if all the CCx and CCxN
  1546. channels have been disabled */
  1547. #define TIM_CCER_CCxE_MASK ((uint32_t)(TIM_CCER_CC1E | TIM_CCER_CC2E | TIM_CCER_CC3E | TIM_CCER_CC4E))
  1548. #define TIM_CCER_CCxNE_MASK ((uint32_t)(TIM_CCER_CC1NE | TIM_CCER_CC2NE | TIM_CCER_CC3NE))
  1549. /**
  1550. * @}
  1551. */
  1552. /* End of private constants --------------------------------------------------*/
  1553. /* Private macros ------------------------------------------------------------*/
  1554. /** @defgroup TIM_Private_Macros TIM Private Macros
  1555. * @{
  1556. */
  1557. #define IS_TIM_CLEARINPUT_SOURCE(__MODE__) (((__MODE__) == TIM_CLEARINPUTSOURCE_NONE) || \
  1558. ((__MODE__) == TIM_CLEARINPUTSOURCE_ETR))
  1559. #if defined(TIM_AF1_BKINE)&&defined(TIM_AF2_BKINE)
  1560. #define IS_TIM_DMA_BASE(__BASE__) (((__BASE__) == TIM_DMABASE_CR1) || \
  1561. ((__BASE__) == TIM_DMABASE_CR2) || \
  1562. ((__BASE__) == TIM_DMABASE_SMCR) || \
  1563. ((__BASE__) == TIM_DMABASE_DIER) || \
  1564. ((__BASE__) == TIM_DMABASE_SR) || \
  1565. ((__BASE__) == TIM_DMABASE_EGR) || \
  1566. ((__BASE__) == TIM_DMABASE_CCMR1) || \
  1567. ((__BASE__) == TIM_DMABASE_CCMR2) || \
  1568. ((__BASE__) == TIM_DMABASE_CCER) || \
  1569. ((__BASE__) == TIM_DMABASE_CNT) || \
  1570. ((__BASE__) == TIM_DMABASE_PSC) || \
  1571. ((__BASE__) == TIM_DMABASE_ARR) || \
  1572. ((__BASE__) == TIM_DMABASE_RCR) || \
  1573. ((__BASE__) == TIM_DMABASE_CCR1) || \
  1574. ((__BASE__) == TIM_DMABASE_CCR2) || \
  1575. ((__BASE__) == TIM_DMABASE_CCR3) || \
  1576. ((__BASE__) == TIM_DMABASE_CCR4) || \
  1577. ((__BASE__) == TIM_DMABASE_BDTR) || \
  1578. ((__BASE__) == TIM_DMABASE_OR) || \
  1579. ((__BASE__) == TIM_DMABASE_CCMR3) || \
  1580. ((__BASE__) == TIM_DMABASE_CCR5) || \
  1581. ((__BASE__) == TIM_DMABASE_CCR6) || \
  1582. ((__BASE__) == TIM_DMABASE_AF1) || \
  1583. ((__BASE__) == TIM_DMABASE_AF2))
  1584. #else
  1585. #define IS_TIM_DMA_BASE(__BASE__) (((__BASE__) == TIM_DMABASE_CR1) || \
  1586. ((__BASE__) == TIM_DMABASE_CR2) || \
  1587. ((__BASE__) == TIM_DMABASE_SMCR) || \
  1588. ((__BASE__) == TIM_DMABASE_DIER) || \
  1589. ((__BASE__) == TIM_DMABASE_SR) || \
  1590. ((__BASE__) == TIM_DMABASE_EGR) || \
  1591. ((__BASE__) == TIM_DMABASE_CCMR1) || \
  1592. ((__BASE__) == TIM_DMABASE_CCMR2) || \
  1593. ((__BASE__) == TIM_DMABASE_CCER) || \
  1594. ((__BASE__) == TIM_DMABASE_CNT) || \
  1595. ((__BASE__) == TIM_DMABASE_PSC) || \
  1596. ((__BASE__) == TIM_DMABASE_ARR) || \
  1597. ((__BASE__) == TIM_DMABASE_RCR) || \
  1598. ((__BASE__) == TIM_DMABASE_CCR1) || \
  1599. ((__BASE__) == TIM_DMABASE_CCR2) || \
  1600. ((__BASE__) == TIM_DMABASE_CCR3) || \
  1601. ((__BASE__) == TIM_DMABASE_CCR4) || \
  1602. ((__BASE__) == TIM_DMABASE_BDTR) || \
  1603. ((__BASE__) == TIM_DMABASE_OR) || \
  1604. ((__BASE__) == TIM_DMABASE_CCMR3) || \
  1605. ((__BASE__) == TIM_DMABASE_CCR5) || \
  1606. ((__BASE__) == TIM_DMABASE_CCR6))
  1607. #endif /* TIM_AF1_BKINE && TIM_AF1_BKINE */
  1608. #define IS_TIM_EVENT_SOURCE(__SOURCE__) ((((__SOURCE__) & 0xFFFFFE00U) == 0x00000000U) && ((__SOURCE__) != 0x00000000U))
  1609. #define IS_TIM_COUNTER_MODE(__MODE__) (((__MODE__) == TIM_COUNTERMODE_UP) || \
  1610. ((__MODE__) == TIM_COUNTERMODE_DOWN) || \
  1611. ((__MODE__) == TIM_COUNTERMODE_CENTERALIGNED1) || \
  1612. ((__MODE__) == TIM_COUNTERMODE_CENTERALIGNED2) || \
  1613. ((__MODE__) == TIM_COUNTERMODE_CENTERALIGNED3))
  1614. #define IS_TIM_UIFREMAP_MODE(__MODE__) (((__MODE__) == TIM_UIFREMAP_DISABLE) || \
  1615. ((__MODE__) == TIM_UIFREMAP_ENALE))
  1616. #define IS_TIM_CLOCKDIVISION_DIV(__DIV__) (((__DIV__) == TIM_CLOCKDIVISION_DIV1) || \
  1617. ((__DIV__) == TIM_CLOCKDIVISION_DIV2) || \
  1618. ((__DIV__) == TIM_CLOCKDIVISION_DIV4))
  1619. #define IS_TIM_AUTORELOAD_PRELOAD(PRELOAD) (((PRELOAD) == TIM_AUTORELOAD_PRELOAD_DISABLE) || \
  1620. ((PRELOAD) == TIM_AUTORELOAD_PRELOAD_ENABLE))
  1621. #define IS_TIM_FAST_STATE(__STATE__) (((__STATE__) == TIM_OCFAST_DISABLE) || \
  1622. ((__STATE__) == TIM_OCFAST_ENABLE))
  1623. #define IS_TIM_OC_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_OCPOLARITY_HIGH) || \
  1624. ((__POLARITY__) == TIM_OCPOLARITY_LOW))
  1625. #define IS_TIM_OCN_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_OCNPOLARITY_HIGH) || \
  1626. ((__POLARITY__) == TIM_OCNPOLARITY_LOW))
  1627. #define IS_TIM_OCIDLE_STATE(__STATE__) (((__STATE__) == TIM_OCIDLESTATE_SET) || \
  1628. ((__STATE__) == TIM_OCIDLESTATE_RESET))
  1629. #define IS_TIM_OCNIDLE_STATE(__STATE__) (((__STATE__) == TIM_OCNIDLESTATE_SET) || \
  1630. ((__STATE__) == TIM_OCNIDLESTATE_RESET))
  1631. #define IS_TIM_ENCODERINPUT_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_ENCODERINPUTPOLARITY_RISING) || \
  1632. ((__POLARITY__) == TIM_ENCODERINPUTPOLARITY_FALLING))
  1633. #define IS_TIM_IC_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_ICPOLARITY_RISING) || \
  1634. ((__POLARITY__) == TIM_ICPOLARITY_FALLING) || \
  1635. ((__POLARITY__) == TIM_ICPOLARITY_BOTHEDGE))
  1636. #define IS_TIM_IC_SELECTION(__SELECTION__) (((__SELECTION__) == TIM_ICSELECTION_DIRECTTI) || \
  1637. ((__SELECTION__) == TIM_ICSELECTION_INDIRECTTI) || \
  1638. ((__SELECTION__) == TIM_ICSELECTION_TRC))
  1639. #define IS_TIM_IC_PRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_ICPSC_DIV1) || \
  1640. ((__PRESCALER__) == TIM_ICPSC_DIV2) || \
  1641. ((__PRESCALER__) == TIM_ICPSC_DIV4) || \
  1642. ((__PRESCALER__) == TIM_ICPSC_DIV8))
  1643. #define IS_TIM_OPM_MODE(__MODE__) (((__MODE__) == TIM_OPMODE_SINGLE) || \
  1644. ((__MODE__) == TIM_OPMODE_REPETITIVE))
  1645. #define IS_TIM_ENCODER_MODE(__MODE__) (((__MODE__) == TIM_ENCODERMODE_TI1) || \
  1646. ((__MODE__) == TIM_ENCODERMODE_TI2) || \
  1647. ((__MODE__) == TIM_ENCODERMODE_TI12))
  1648. #define IS_TIM_DMA_SOURCE(__SOURCE__) ((((__SOURCE__) & 0xFFFF80FFU) == 0x00000000U) && ((__SOURCE__) != 0x00000000U))
  1649. #define IS_TIM_CHANNELS(__CHANNEL__) (((__CHANNEL__) == TIM_CHANNEL_1) || \
  1650. ((__CHANNEL__) == TIM_CHANNEL_2) || \
  1651. ((__CHANNEL__) == TIM_CHANNEL_3) || \
  1652. ((__CHANNEL__) == TIM_CHANNEL_4) || \
  1653. ((__CHANNEL__) == TIM_CHANNEL_5) || \
  1654. ((__CHANNEL__) == TIM_CHANNEL_6) || \
  1655. ((__CHANNEL__) == TIM_CHANNEL_ALL))
  1656. #define IS_TIM_OPM_CHANNELS(__CHANNEL__) (((__CHANNEL__) == TIM_CHANNEL_1) || \
  1657. ((__CHANNEL__) == TIM_CHANNEL_2))
  1658. #define IS_TIM_COMPLEMENTARY_CHANNELS(__CHANNEL__) (((__CHANNEL__) == TIM_CHANNEL_1) || \
  1659. ((__CHANNEL__) == TIM_CHANNEL_2) || \
  1660. ((__CHANNEL__) == TIM_CHANNEL_3))
  1661. #define IS_TIM_CLOCKSOURCE(__CLOCK__) (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL) || \
  1662. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE2) || \
  1663. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR0) || \
  1664. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR1) || \
  1665. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR2) || \
  1666. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR3) || \
  1667. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1ED) || \
  1668. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1) || \
  1669. ((__CLOCK__) == TIM_CLOCKSOURCE_TI2) || \
  1670. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE1))
  1671. #define IS_TIM_CLOCKPOLARITY(__POLARITY__) (((__POLARITY__) == TIM_CLOCKPOLARITY_INVERTED) || \
  1672. ((__POLARITY__) == TIM_CLOCKPOLARITY_NONINVERTED) || \
  1673. ((__POLARITY__) == TIM_CLOCKPOLARITY_RISING) || \
  1674. ((__POLARITY__) == TIM_CLOCKPOLARITY_FALLING) || \
  1675. ((__POLARITY__) == TIM_CLOCKPOLARITY_BOTHEDGE))
  1676. #define IS_TIM_CLOCKPRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV1) || \
  1677. ((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV2) || \
  1678. ((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV4) || \
  1679. ((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV8))
  1680. #define IS_TIM_CLOCKFILTER(__ICFILTER__) ((__ICFILTER__) <= 0xFU)
  1681. #define IS_TIM_CLEARINPUT_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_CLEARINPUTPOLARITY_INVERTED) || \
  1682. ((__POLARITY__) == TIM_CLEARINPUTPOLARITY_NONINVERTED))
  1683. #define IS_TIM_CLEARINPUT_PRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV1) || \
  1684. ((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV2) || \
  1685. ((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV4) || \
  1686. ((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV8))
  1687. #define IS_TIM_CLEARINPUT_FILTER(__ICFILTER__) ((__ICFILTER__) <= 0xFU)
  1688. #define IS_TIM_OSSR_STATE(__STATE__) (((__STATE__) == TIM_OSSR_ENABLE) || \
  1689. ((__STATE__) == TIM_OSSR_DISABLE))
  1690. #define IS_TIM_OSSI_STATE(__STATE__) (((__STATE__) == TIM_OSSI_ENABLE) || \
  1691. ((__STATE__) == TIM_OSSI_DISABLE))
  1692. #define IS_TIM_LOCK_LEVEL(__LEVEL__) (((__LEVEL__) == TIM_LOCKLEVEL_OFF) || \
  1693. ((__LEVEL__) == TIM_LOCKLEVEL_1) || \
  1694. ((__LEVEL__) == TIM_LOCKLEVEL_2) || \
  1695. ((__LEVEL__) == TIM_LOCKLEVEL_3))
  1696. #define IS_TIM_BREAK_FILTER(__BRKFILTER__) ((__BRKFILTER__) <= 0xFUL)
  1697. #define IS_TIM_BREAK_STATE(__STATE__) (((__STATE__) == TIM_BREAK_ENABLE) || \
  1698. ((__STATE__) == TIM_BREAK_DISABLE))
  1699. #define IS_TIM_BREAK_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_BREAKPOLARITY_LOW) || \
  1700. ((__POLARITY__) == TIM_BREAKPOLARITY_HIGH))
  1701. #define IS_TIM_BREAK2_STATE(__STATE__) (((__STATE__) == TIM_BREAK2_ENABLE) || \
  1702. ((__STATE__) == TIM_BREAK2_DISABLE))
  1703. #define IS_TIM_BREAK2_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_BREAK2POLARITY_LOW) || \
  1704. ((__POLARITY__) == TIM_BREAK2POLARITY_HIGH))
  1705. #define IS_TIM_AUTOMATIC_OUTPUT_STATE(__STATE__) (((__STATE__) == TIM_AUTOMATICOUTPUT_ENABLE) || \
  1706. ((__STATE__) == TIM_AUTOMATICOUTPUT_DISABLE))
  1707. #define IS_TIM_GROUPCH5(__OCREF__) ((((__OCREF__) & 0x1FFFFFFFU) == 0x00000000U))
  1708. #define IS_TIM_TRGO_SOURCE(__SOURCE__) (((__SOURCE__) == TIM_TRGO_RESET) || \
  1709. ((__SOURCE__) == TIM_TRGO_ENABLE) || \
  1710. ((__SOURCE__) == TIM_TRGO_UPDATE) || \
  1711. ((__SOURCE__) == TIM_TRGO_OC1) || \
  1712. ((__SOURCE__) == TIM_TRGO_OC1REF) || \
  1713. ((__SOURCE__) == TIM_TRGO_OC2REF) || \
  1714. ((__SOURCE__) == TIM_TRGO_OC3REF) || \
  1715. ((__SOURCE__) == TIM_TRGO_OC4REF))
  1716. #define IS_TIM_TRGO2_SOURCE(__SOURCE__) (((__SOURCE__) == TIM_TRGO2_RESET) || \
  1717. ((__SOURCE__) == TIM_TRGO2_ENABLE) || \
  1718. ((__SOURCE__) == TIM_TRGO2_UPDATE) || \
  1719. ((__SOURCE__) == TIM_TRGO2_OC1) || \
  1720. ((__SOURCE__) == TIM_TRGO2_OC1REF) || \
  1721. ((__SOURCE__) == TIM_TRGO2_OC2REF) || \
  1722. ((__SOURCE__) == TIM_TRGO2_OC3REF) || \
  1723. ((__SOURCE__) == TIM_TRGO2_OC3REF) || \
  1724. ((__SOURCE__) == TIM_TRGO2_OC4REF) || \
  1725. ((__SOURCE__) == TIM_TRGO2_OC5REF) || \
  1726. ((__SOURCE__) == TIM_TRGO2_OC6REF) || \
  1727. ((__SOURCE__) == TIM_TRGO2_OC4REF_RISINGFALLING) || \
  1728. ((__SOURCE__) == TIM_TRGO2_OC6REF_RISINGFALLING) || \
  1729. ((__SOURCE__) == TIM_TRGO2_OC4REF_RISING_OC6REF_RISING) || \
  1730. ((__SOURCE__) == TIM_TRGO2_OC4REF_RISING_OC6REF_FALLING) || \
  1731. ((__SOURCE__) == TIM_TRGO2_OC5REF_RISING_OC6REF_RISING) || \
  1732. ((__SOURCE__) == TIM_TRGO2_OC5REF_RISING_OC6REF_FALLING))
  1733. #define IS_TIM_MSM_STATE(__STATE__) (((__STATE__) == TIM_MASTERSLAVEMODE_ENABLE) || \
  1734. ((__STATE__) == TIM_MASTERSLAVEMODE_DISABLE))
  1735. #define IS_TIM_SLAVE_MODE(__MODE__) (((__MODE__) == TIM_SLAVEMODE_DISABLE) || \
  1736. ((__MODE__) == TIM_SLAVEMODE_RESET) || \
  1737. ((__MODE__) == TIM_SLAVEMODE_GATED) || \
  1738. ((__MODE__) == TIM_SLAVEMODE_TRIGGER) || \
  1739. ((__MODE__) == TIM_SLAVEMODE_EXTERNAL1) || \
  1740. ((__MODE__) == TIM_SLAVEMODE_COMBINED_RESETTRIGGER))
  1741. #define IS_TIM_PWM_MODE(__MODE__) (((__MODE__) == TIM_OCMODE_PWM1) || \
  1742. ((__MODE__) == TIM_OCMODE_PWM2) || \
  1743. ((__MODE__) == TIM_OCMODE_COMBINED_PWM1) || \
  1744. ((__MODE__) == TIM_OCMODE_COMBINED_PWM2) || \
  1745. ((__MODE__) == TIM_OCMODE_ASSYMETRIC_PWM1) || \
  1746. ((__MODE__) == TIM_OCMODE_ASSYMETRIC_PWM2))
  1747. #define IS_TIM_OC_MODE(__MODE__) (((__MODE__) == TIM_OCMODE_TIMING) || \
  1748. ((__MODE__) == TIM_OCMODE_ACTIVE) || \
  1749. ((__MODE__) == TIM_OCMODE_INACTIVE) || \
  1750. ((__MODE__) == TIM_OCMODE_TOGGLE) || \
  1751. ((__MODE__) == TIM_OCMODE_FORCED_ACTIVE) || \
  1752. ((__MODE__) == TIM_OCMODE_FORCED_INACTIVE) || \
  1753. ((__MODE__) == TIM_OCMODE_RETRIGERRABLE_OPM1) || \
  1754. ((__MODE__) == TIM_OCMODE_RETRIGERRABLE_OPM2))
  1755. #define IS_TIM_TRIGGER_SELECTION(__SELECTION__) (((__SELECTION__) == TIM_TS_ITR0) || \
  1756. ((__SELECTION__) == TIM_TS_ITR1) || \
  1757. ((__SELECTION__) == TIM_TS_ITR2) || \
  1758. ((__SELECTION__) == TIM_TS_ITR3) || \
  1759. ((__SELECTION__) == TIM_TS_TI1F_ED) || \
  1760. ((__SELECTION__) == TIM_TS_TI1FP1) || \
  1761. ((__SELECTION__) == TIM_TS_TI2FP2) || \
  1762. ((__SELECTION__) == TIM_TS_ETRF))
  1763. #define IS_TIM_INTERNAL_TRIGGEREVENT_SELECTION(__SELECTION__) (((__SELECTION__) == TIM_TS_ITR0) || \
  1764. ((__SELECTION__) == TIM_TS_ITR1) || \
  1765. ((__SELECTION__) == TIM_TS_ITR2) || \
  1766. ((__SELECTION__) == TIM_TS_ITR3) || \
  1767. ((__SELECTION__) == TIM_TS_NONE))
  1768. #define IS_TIM_TRIGGERPOLARITY(__POLARITY__) (((__POLARITY__) == TIM_TRIGGERPOLARITY_INVERTED ) || \
  1769. ((__POLARITY__) == TIM_TRIGGERPOLARITY_NONINVERTED) || \
  1770. ((__POLARITY__) == TIM_TRIGGERPOLARITY_RISING ) || \
  1771. ((__POLARITY__) == TIM_TRIGGERPOLARITY_FALLING ) || \
  1772. ((__POLARITY__) == TIM_TRIGGERPOLARITY_BOTHEDGE ))
  1773. #define IS_TIM_TRIGGERPRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV1) || \
  1774. ((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV2) || \
  1775. ((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV4) || \
  1776. ((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV8))
  1777. #define IS_TIM_TRIGGERFILTER(__ICFILTER__) ((__ICFILTER__) <= 0xFU)
  1778. #define IS_TIM_TI1SELECTION(__TI1SELECTION__) (((__TI1SELECTION__) == TIM_TI1SELECTION_CH1) || \
  1779. ((__TI1SELECTION__) == TIM_TI1SELECTION_XORCOMBINATION))
  1780. #define IS_TIM_DMA_LENGTH(__LENGTH__) (((__LENGTH__) == TIM_DMABURSTLENGTH_1TRANSFER) || \
  1781. ((__LENGTH__) == TIM_DMABURSTLENGTH_2TRANSFERS) || \
  1782. ((__LENGTH__) == TIM_DMABURSTLENGTH_3TRANSFERS) || \
  1783. ((__LENGTH__) == TIM_DMABURSTLENGTH_4TRANSFERS) || \
  1784. ((__LENGTH__) == TIM_DMABURSTLENGTH_5TRANSFERS) || \
  1785. ((__LENGTH__) == TIM_DMABURSTLENGTH_6TRANSFERS) || \
  1786. ((__LENGTH__) == TIM_DMABURSTLENGTH_7TRANSFERS) || \
  1787. ((__LENGTH__) == TIM_DMABURSTLENGTH_8TRANSFERS) || \
  1788. ((__LENGTH__) == TIM_DMABURSTLENGTH_9TRANSFERS) || \
  1789. ((__LENGTH__) == TIM_DMABURSTLENGTH_10TRANSFERS) || \
  1790. ((__LENGTH__) == TIM_DMABURSTLENGTH_11TRANSFERS) || \
  1791. ((__LENGTH__) == TIM_DMABURSTLENGTH_12TRANSFERS) || \
  1792. ((__LENGTH__) == TIM_DMABURSTLENGTH_13TRANSFERS) || \
  1793. ((__LENGTH__) == TIM_DMABURSTLENGTH_14TRANSFERS) || \
  1794. ((__LENGTH__) == TIM_DMABURSTLENGTH_15TRANSFERS) || \
  1795. ((__LENGTH__) == TIM_DMABURSTLENGTH_16TRANSFERS) || \
  1796. ((__LENGTH__) == TIM_DMABURSTLENGTH_17TRANSFERS) || \
  1797. ((__LENGTH__) == TIM_DMABURSTLENGTH_18TRANSFERS))
  1798. #define IS_TIM_DMA_DATA_LENGTH(LENGTH) (((LENGTH) >= 0x1U) && ((LENGTH) < 0x10000U))
  1799. #define IS_TIM_IC_FILTER(__ICFILTER__) ((__ICFILTER__) <= 0xFU)
  1800. #define IS_TIM_DEADTIME(__DEADTIME__) ((__DEADTIME__) <= 0xFFU)
  1801. #define IS_TIM_BREAK_SYSTEM(__CONFIG__) (((__CONFIG__) == TIM_BREAK_SYSTEM_ECC) || \
  1802. ((__CONFIG__) == TIM_BREAK_SYSTEM_PVD) || \
  1803. ((__CONFIG__) == TIM_BREAK_SYSTEM_SRAM_PARITY_ERROR) || \
  1804. ((__CONFIG__) == TIM_BREAK_SYSTEM_LOCKUP))
  1805. #define IS_TIM_SLAVEMODE_TRIGGER_ENABLED(__TRIGGER__) (((__TRIGGER__) == TIM_SLAVEMODE_TRIGGER) || \
  1806. ((__TRIGGER__) == TIM_SLAVEMODE_COMBINED_RESETTRIGGER))
  1807. #define TIM_SET_ICPRESCALERVALUE(__HANDLE__, __CHANNEL__, __ICPSC__) \
  1808. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 |= (__ICPSC__)) :\
  1809. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 |= ((__ICPSC__) << 8U)) :\
  1810. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 |= (__ICPSC__)) :\
  1811. ((__HANDLE__)->Instance->CCMR2 |= ((__ICPSC__) << 8U)))
  1812. #define TIM_RESET_ICPRESCALERVALUE(__HANDLE__, __CHANNEL__) \
  1813. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_IC1PSC) :\
  1814. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_IC2PSC) :\
  1815. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_IC3PSC) :\
  1816. ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_IC4PSC))
  1817. #define TIM_SET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__, __POLARITY__) \
  1818. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCER |= (__POLARITY__)) :\
  1819. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCER |= ((__POLARITY__) << 4U)) :\
  1820. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCER |= ((__POLARITY__) << 8U)) :\
  1821. ((__HANDLE__)->Instance->CCER |= (((__POLARITY__) << 12U))))
  1822. #define TIM_RESET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__) \
  1823. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP)) :\
  1824. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC2P | TIM_CCER_CC2NP)) :\
  1825. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC3P | TIM_CCER_CC3NP)) :\
  1826. ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC4P | TIM_CCER_CC4NP)))
  1827. #define TIM_CHANNEL_STATE_GET(__HANDLE__, __CHANNEL__)\
  1828. (((__CHANNEL__) == TIM_CHANNEL_1) ? (__HANDLE__)->ChannelState[0] :\
  1829. ((__CHANNEL__) == TIM_CHANNEL_2) ? (__HANDLE__)->ChannelState[1] :\
  1830. ((__CHANNEL__) == TIM_CHANNEL_3) ? (__HANDLE__)->ChannelState[2] :\
  1831. ((__CHANNEL__) == TIM_CHANNEL_4) ? (__HANDLE__)->ChannelState[3] :\
  1832. ((__CHANNEL__) == TIM_CHANNEL_5) ? (__HANDLE__)->ChannelState[4] :\
  1833. (__HANDLE__)->ChannelState[5])
  1834. #define TIM_CHANNEL_STATE_SET(__HANDLE__, __CHANNEL__, __CHANNEL_STATE__) \
  1835. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->ChannelState[0] = (__CHANNEL_STATE__)) :\
  1836. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->ChannelState[1] = (__CHANNEL_STATE__)) :\
  1837. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->ChannelState[2] = (__CHANNEL_STATE__)) :\
  1838. ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->ChannelState[3] = (__CHANNEL_STATE__)) :\
  1839. ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->ChannelState[4] = (__CHANNEL_STATE__)) :\
  1840. ((__HANDLE__)->ChannelState[5] = (__CHANNEL_STATE__)))
  1841. #define TIM_CHANNEL_STATE_SET_ALL(__HANDLE__, __CHANNEL_STATE__) do { \
  1842. (__HANDLE__)->ChannelState[0] = \
  1843. (__CHANNEL_STATE__); \
  1844. (__HANDLE__)->ChannelState[1] = \
  1845. (__CHANNEL_STATE__); \
  1846. (__HANDLE__)->ChannelState[2] = \
  1847. (__CHANNEL_STATE__); \
  1848. (__HANDLE__)->ChannelState[3] = \
  1849. (__CHANNEL_STATE__); \
  1850. (__HANDLE__)->ChannelState[4] = \
  1851. (__CHANNEL_STATE__); \
  1852. (__HANDLE__)->ChannelState[5] = \
  1853. (__CHANNEL_STATE__); \
  1854. } while(0)
  1855. #define TIM_CHANNEL_N_STATE_GET(__HANDLE__, __CHANNEL__)\
  1856. (((__CHANNEL__) == TIM_CHANNEL_1) ? (__HANDLE__)->ChannelNState[0] :\
  1857. ((__CHANNEL__) == TIM_CHANNEL_2) ? (__HANDLE__)->ChannelNState[1] :\
  1858. ((__CHANNEL__) == TIM_CHANNEL_3) ? (__HANDLE__)->ChannelNState[2] :\
  1859. (__HANDLE__)->ChannelNState[3])
  1860. #define TIM_CHANNEL_N_STATE_SET(__HANDLE__, __CHANNEL__, __CHANNEL_STATE__) \
  1861. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->ChannelNState[0] = (__CHANNEL_STATE__)) :\
  1862. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->ChannelNState[1] = (__CHANNEL_STATE__)) :\
  1863. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->ChannelNState[2] = (__CHANNEL_STATE__)) :\
  1864. ((__HANDLE__)->ChannelNState[3] = (__CHANNEL_STATE__)))
  1865. #define TIM_CHANNEL_N_STATE_SET_ALL(__HANDLE__, __CHANNEL_STATE__) do { \
  1866. (__HANDLE__)->ChannelNState[0] = \
  1867. (__CHANNEL_STATE__); \
  1868. (__HANDLE__)->ChannelNState[1] = \
  1869. (__CHANNEL_STATE__); \
  1870. (__HANDLE__)->ChannelNState[2] = \
  1871. (__CHANNEL_STATE__); \
  1872. (__HANDLE__)->ChannelNState[3] = \
  1873. (__CHANNEL_STATE__); \
  1874. } while(0)
  1875. /**
  1876. * @}
  1877. */
  1878. /* End of private macros -----------------------------------------------------*/
  1879. /* Include TIM HAL Extended module */
  1880. #include "stm32f7xx_hal_tim_ex.h"
  1881. /* Exported functions --------------------------------------------------------*/
  1882. /** @addtogroup TIM_Exported_Functions TIM Exported Functions
  1883. * @{
  1884. */
  1885. /** @addtogroup TIM_Exported_Functions_Group1 TIM Time Base functions
  1886. * @brief Time Base functions
  1887. * @{
  1888. */
  1889. /* Time Base functions ********************************************************/
  1890. HAL_StatusTypeDef HAL_TIM_Base_Init(TIM_HandleTypeDef *htim);
  1891. HAL_StatusTypeDef HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim);
  1892. void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim);
  1893. void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim);
  1894. /* Blocking mode: Polling */
  1895. HAL_StatusTypeDef HAL_TIM_Base_Start(TIM_HandleTypeDef *htim);
  1896. HAL_StatusTypeDef HAL_TIM_Base_Stop(TIM_HandleTypeDef *htim);
  1897. /* Non-Blocking mode: Interrupt */
  1898. HAL_StatusTypeDef HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim);
  1899. HAL_StatusTypeDef HAL_TIM_Base_Stop_IT(TIM_HandleTypeDef *htim);
  1900. /* Non-Blocking mode: DMA */
  1901. HAL_StatusTypeDef HAL_TIM_Base_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
  1902. HAL_StatusTypeDef HAL_TIM_Base_Stop_DMA(TIM_HandleTypeDef *htim);
  1903. /**
  1904. * @}
  1905. */
  1906. /** @addtogroup TIM_Exported_Functions_Group2 TIM Output Compare functions
  1907. * @brief TIM Output Compare functions
  1908. * @{
  1909. */
  1910. /* Timer Output Compare functions *********************************************/
  1911. HAL_StatusTypeDef HAL_TIM_OC_Init(TIM_HandleTypeDef *htim);
  1912. HAL_StatusTypeDef HAL_TIM_OC_DeInit(TIM_HandleTypeDef *htim);
  1913. void HAL_TIM_OC_MspInit(TIM_HandleTypeDef *htim);
  1914. void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef *htim);
  1915. /* Blocking mode: Polling */
  1916. HAL_StatusTypeDef HAL_TIM_OC_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  1917. HAL_StatusTypeDef HAL_TIM_OC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  1918. /* Non-Blocking mode: Interrupt */
  1919. HAL_StatusTypeDef HAL_TIM_OC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1920. HAL_StatusTypeDef HAL_TIM_OC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1921. /* Non-Blocking mode: DMA */
  1922. HAL_StatusTypeDef HAL_TIM_OC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  1923. HAL_StatusTypeDef HAL_TIM_OC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  1924. /**
  1925. * @}
  1926. */
  1927. /** @addtogroup TIM_Exported_Functions_Group3 TIM PWM functions
  1928. * @brief TIM PWM functions
  1929. * @{
  1930. */
  1931. /* Timer PWM functions ********************************************************/
  1932. HAL_StatusTypeDef HAL_TIM_PWM_Init(TIM_HandleTypeDef *htim);
  1933. HAL_StatusTypeDef HAL_TIM_PWM_DeInit(TIM_HandleTypeDef *htim);
  1934. void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim);
  1935. void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef *htim);
  1936. /* Blocking mode: Polling */
  1937. HAL_StatusTypeDef HAL_TIM_PWM_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  1938. HAL_StatusTypeDef HAL_TIM_PWM_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  1939. /* Non-Blocking mode: Interrupt */
  1940. HAL_StatusTypeDef HAL_TIM_PWM_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1941. HAL_StatusTypeDef HAL_TIM_PWM_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1942. /* Non-Blocking mode: DMA */
  1943. HAL_StatusTypeDef HAL_TIM_PWM_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  1944. HAL_StatusTypeDef HAL_TIM_PWM_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  1945. /**
  1946. * @}
  1947. */
  1948. /** @addtogroup TIM_Exported_Functions_Group4 TIM Input Capture functions
  1949. * @brief TIM Input Capture functions
  1950. * @{
  1951. */
  1952. /* Timer Input Capture functions **********************************************/
  1953. HAL_StatusTypeDef HAL_TIM_IC_Init(TIM_HandleTypeDef *htim);
  1954. HAL_StatusTypeDef HAL_TIM_IC_DeInit(TIM_HandleTypeDef *htim);
  1955. void HAL_TIM_IC_MspInit(TIM_HandleTypeDef *htim);
  1956. void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef *htim);
  1957. /* Blocking mode: Polling */
  1958. HAL_StatusTypeDef HAL_TIM_IC_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  1959. HAL_StatusTypeDef HAL_TIM_IC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  1960. /* Non-Blocking mode: Interrupt */
  1961. HAL_StatusTypeDef HAL_TIM_IC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1962. HAL_StatusTypeDef HAL_TIM_IC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1963. /* Non-Blocking mode: DMA */
  1964. HAL_StatusTypeDef HAL_TIM_IC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  1965. HAL_StatusTypeDef HAL_TIM_IC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  1966. /**
  1967. * @}
  1968. */
  1969. /** @addtogroup TIM_Exported_Functions_Group5 TIM One Pulse functions
  1970. * @brief TIM One Pulse functions
  1971. * @{
  1972. */
  1973. /* Timer One Pulse functions **************************************************/
  1974. HAL_StatusTypeDef HAL_TIM_OnePulse_Init(TIM_HandleTypeDef *htim, uint32_t OnePulseMode);
  1975. HAL_StatusTypeDef HAL_TIM_OnePulse_DeInit(TIM_HandleTypeDef *htim);
  1976. void HAL_TIM_OnePulse_MspInit(TIM_HandleTypeDef *htim);
  1977. void HAL_TIM_OnePulse_MspDeInit(TIM_HandleTypeDef *htim);
  1978. /* Blocking mode: Polling */
  1979. HAL_StatusTypeDef HAL_TIM_OnePulse_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  1980. HAL_StatusTypeDef HAL_TIM_OnePulse_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  1981. /* Non-Blocking mode: Interrupt */
  1982. HAL_StatusTypeDef HAL_TIM_OnePulse_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  1983. HAL_StatusTypeDef HAL_TIM_OnePulse_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  1984. /**
  1985. * @}
  1986. */
  1987. /** @addtogroup TIM_Exported_Functions_Group6 TIM Encoder functions
  1988. * @brief TIM Encoder functions
  1989. * @{
  1990. */
  1991. /* Timer Encoder functions ****************************************************/
  1992. HAL_StatusTypeDef HAL_TIM_Encoder_Init(TIM_HandleTypeDef *htim, TIM_Encoder_InitTypeDef *sConfig);
  1993. HAL_StatusTypeDef HAL_TIM_Encoder_DeInit(TIM_HandleTypeDef *htim);
  1994. void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim);
  1995. void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef *htim);
  1996. /* Blocking mode: Polling */
  1997. HAL_StatusTypeDef HAL_TIM_Encoder_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  1998. HAL_StatusTypeDef HAL_TIM_Encoder_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  1999. /* Non-Blocking mode: Interrupt */
  2000. HAL_StatusTypeDef HAL_TIM_Encoder_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  2001. HAL_StatusTypeDef HAL_TIM_Encoder_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  2002. /* Non-Blocking mode: DMA */
  2003. HAL_StatusTypeDef HAL_TIM_Encoder_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData1,
  2004. uint32_t *pData2, uint16_t Length);
  2005. HAL_StatusTypeDef HAL_TIM_Encoder_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  2006. /**
  2007. * @}
  2008. */
  2009. /** @addtogroup TIM_Exported_Functions_Group7 TIM IRQ handler management
  2010. * @brief IRQ handler management
  2011. * @{
  2012. */
  2013. /* Interrupt Handler functions ***********************************************/
  2014. void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim);
  2015. /**
  2016. * @}
  2017. */
  2018. /** @defgroup TIM_Exported_Functions_Group8 TIM Peripheral Control functions
  2019. * @brief Peripheral Control functions
  2020. * @{
  2021. */
  2022. /* Control functions *********************************************************/
  2023. HAL_StatusTypeDef HAL_TIM_OC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OC_InitTypeDef *sConfig, uint32_t Channel);
  2024. HAL_StatusTypeDef HAL_TIM_PWM_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OC_InitTypeDef *sConfig, uint32_t Channel);
  2025. HAL_StatusTypeDef HAL_TIM_IC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_IC_InitTypeDef *sConfig, uint32_t Channel);
  2026. HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OnePulse_InitTypeDef *sConfig,
  2027. uint32_t OutputChannel, uint32_t InputChannel);
  2028. HAL_StatusTypeDef HAL_TIM_ConfigOCrefClear(TIM_HandleTypeDef *htim, TIM_ClearInputConfigTypeDef *sClearInputConfig,
  2029. uint32_t Channel);
  2030. HAL_StatusTypeDef HAL_TIM_ConfigClockSource(TIM_HandleTypeDef *htim, TIM_ClockConfigTypeDef *sClockSourceConfig);
  2031. HAL_StatusTypeDef HAL_TIM_ConfigTI1Input(TIM_HandleTypeDef *htim, uint32_t TI1_Selection);
  2032. HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchro(TIM_HandleTypeDef *htim, TIM_SlaveConfigTypeDef *sSlaveConfig);
  2033. HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchro_IT(TIM_HandleTypeDef *htim, TIM_SlaveConfigTypeDef *sSlaveConfig);
  2034. HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
  2035. uint32_t BurstRequestSrc, uint32_t *BurstBuffer, uint32_t BurstLength);
  2036. HAL_StatusTypeDef HAL_TIM_DMABurst_MultiWriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
  2037. uint32_t BurstRequestSrc, uint32_t *BurstBuffer,
  2038. uint32_t BurstLength, uint32_t DataLength);
  2039. HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc);
  2040. HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
  2041. uint32_t BurstRequestSrc, uint32_t *BurstBuffer, uint32_t BurstLength);
  2042. HAL_StatusTypeDef HAL_TIM_DMABurst_MultiReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
  2043. uint32_t BurstRequestSrc, uint32_t *BurstBuffer,
  2044. uint32_t BurstLength, uint32_t DataLength);
  2045. HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc);
  2046. HAL_StatusTypeDef HAL_TIM_GenerateEvent(TIM_HandleTypeDef *htim, uint32_t EventSource);
  2047. uint32_t HAL_TIM_ReadCapturedValue(TIM_HandleTypeDef *htim, uint32_t Channel);
  2048. /**
  2049. * @}
  2050. */
  2051. /** @defgroup TIM_Exported_Functions_Group9 TIM Callbacks functions
  2052. * @brief TIM Callbacks functions
  2053. * @{
  2054. */
  2055. /* Callback in non blocking modes (Interrupt and DMA) *************************/
  2056. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim);
  2057. void HAL_TIM_PeriodElapsedHalfCpltCallback(TIM_HandleTypeDef *htim);
  2058. void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim);
  2059. void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim);
  2060. void HAL_TIM_IC_CaptureHalfCpltCallback(TIM_HandleTypeDef *htim);
  2061. void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim);
  2062. void HAL_TIM_PWM_PulseFinishedHalfCpltCallback(TIM_HandleTypeDef *htim);
  2063. void HAL_TIM_TriggerCallback(TIM_HandleTypeDef *htim);
  2064. void HAL_TIM_TriggerHalfCpltCallback(TIM_HandleTypeDef *htim);
  2065. void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim);
  2066. /* Callbacks Register/UnRegister functions ***********************************/
  2067. #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
  2068. HAL_StatusTypeDef HAL_TIM_RegisterCallback(TIM_HandleTypeDef *htim, HAL_TIM_CallbackIDTypeDef CallbackID,
  2069. pTIM_CallbackTypeDef pCallback);
  2070. HAL_StatusTypeDef HAL_TIM_UnRegisterCallback(TIM_HandleTypeDef *htim, HAL_TIM_CallbackIDTypeDef CallbackID);
  2071. #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
  2072. /**
  2073. * @}
  2074. */
  2075. /** @defgroup TIM_Exported_Functions_Group10 TIM Peripheral State functions
  2076. * @brief Peripheral State functions
  2077. * @{
  2078. */
  2079. /* Peripheral State functions ************************************************/
  2080. HAL_TIM_StateTypeDef HAL_TIM_Base_GetState(TIM_HandleTypeDef *htim);
  2081. HAL_TIM_StateTypeDef HAL_TIM_OC_GetState(TIM_HandleTypeDef *htim);
  2082. HAL_TIM_StateTypeDef HAL_TIM_PWM_GetState(TIM_HandleTypeDef *htim);
  2083. HAL_TIM_StateTypeDef HAL_TIM_IC_GetState(TIM_HandleTypeDef *htim);
  2084. HAL_TIM_StateTypeDef HAL_TIM_OnePulse_GetState(TIM_HandleTypeDef *htim);
  2085. HAL_TIM_StateTypeDef HAL_TIM_Encoder_GetState(TIM_HandleTypeDef *htim);
  2086. /* Peripheral Channel state functions ************************************************/
  2087. HAL_TIM_ActiveChannel HAL_TIM_GetActiveChannel(TIM_HandleTypeDef *htim);
  2088. HAL_TIM_ChannelStateTypeDef HAL_TIM_GetChannelState(TIM_HandleTypeDef *htim, uint32_t Channel);
  2089. HAL_TIM_DMABurstStateTypeDef HAL_TIM_DMABurstState(TIM_HandleTypeDef *htim);
  2090. /**
  2091. * @}
  2092. */
  2093. /**
  2094. * @}
  2095. */
  2096. /* End of exported functions -------------------------------------------------*/
  2097. /* Private functions----------------------------------------------------------*/
  2098. /** @defgroup TIM_Private_Functions TIM Private Functions
  2099. * @{
  2100. */
  2101. void TIM_Base_SetConfig(TIM_TypeDef *TIMx, TIM_Base_InitTypeDef *Structure);
  2102. void TIM_TI1_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, uint32_t TIM_ICFilter);
  2103. void TIM_OC2_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config);
  2104. void TIM_ETR_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ExtTRGPrescaler,
  2105. uint32_t TIM_ExtTRGPolarity, uint32_t ExtTRGFilter);
  2106. void TIM_DMADelayPulseHalfCplt(DMA_HandleTypeDef *hdma);
  2107. void TIM_DMAError(DMA_HandleTypeDef *hdma);
  2108. void TIM_DMACaptureCplt(DMA_HandleTypeDef *hdma);
  2109. void TIM_DMACaptureHalfCplt(DMA_HandleTypeDef *hdma);
  2110. void TIM_CCxChannelCmd(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ChannelState);
  2111. #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
  2112. void TIM_ResetCallback(TIM_HandleTypeDef *htim);
  2113. #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
  2114. /**
  2115. * @}
  2116. */
  2117. /* End of private functions --------------------------------------------------*/
  2118. /**
  2119. * @}
  2120. */
  2121. /**
  2122. * @}
  2123. */
  2124. #ifdef __cplusplus
  2125. }
  2126. #endif
  2127. #endif /* STM32F7xx_HAL_TIM_H */