stm32h5xx_hal_tim_ex.h 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386
  1. /**
  2. ******************************************************************************
  3. * @file stm32h5xx_hal_tim_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of TIM HAL Extended module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2023 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 STM32H5xx_HAL_TIM_EX_H
  20. #define STM32H5xx_HAL_TIM_EX_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32h5xx_hal_def.h"
  26. /** @addtogroup STM32H5xx_HAL_Driver
  27. * @{
  28. */
  29. /** @addtogroup TIMEx
  30. * @{
  31. */
  32. /* Exported types ------------------------------------------------------------*/
  33. /** @defgroup TIMEx_Exported_Types TIM Extended Exported Types
  34. * @{
  35. */
  36. /**
  37. * @brief TIM Hall sensor Configuration Structure definition
  38. */
  39. typedef struct
  40. {
  41. uint32_t IC1Polarity; /*!< Specifies the active edge of the input signal.
  42. This parameter can be a value of @ref TIM_Input_Capture_Polarity */
  43. uint32_t IC1Prescaler; /*!< Specifies the Input Capture Prescaler.
  44. This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
  45. uint32_t IC1Filter; /*!< Specifies the input capture filter.
  46. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  47. uint32_t Commutation_Delay; /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
  48. This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
  49. } TIM_HallSensor_InitTypeDef;
  50. /**
  51. * @brief TIM Break/Break2 input configuration
  52. */
  53. typedef struct
  54. {
  55. uint32_t Source; /*!< Specifies the source of the timer break input.
  56. This parameter can be a value of @ref TIMEx_Break_Input_Source */
  57. uint32_t Enable; /*!< Specifies whether or not the break input source is enabled.
  58. This parameter can be a value of @ref TIMEx_Break_Input_Source_Enable */
  59. uint32_t Polarity; /*!< Specifies the break input source polarity.
  60. This parameter can be a value of @ref TIMEx_Break_Input_Source_Polarity */
  61. } TIMEx_BreakInputConfigTypeDef;
  62. /**
  63. * @brief TIM Encoder index configuration
  64. */
  65. typedef struct
  66. {
  67. uint32_t Polarity; /*!< TIM Encoder index polarity.This parameter can be a value of @ref TIMEx_Encoder_Index_Polarity */
  68. uint32_t Prescaler; /*!< TIM Encoder index prescaler.This parameter can be a value of @ref TIMEx_Encoder_Index_Prescaler */
  69. uint32_t Filter; /*!< TIM Encoder index filter.This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  70. uint32_t Blanking; /*!< Specifies whether or not the encoder index event is conditioned by TI3 or TI4 input.This parameter can be a value of @ref TIMEx_Encoder_Index_Blanking */
  71. FunctionalState FirstIndexEnable; /*!< Specifies whether or not the encoder first index is enabled.This parameter value can be ENABLE or DISABLE. */
  72. uint32_t Position; /*!< Specifies in which AB input configuration the index event resets the counter.This parameter can be a value of @ref TIMEx_Encoder_Index_Position */
  73. uint32_t Direction; /*!< Specifies in which counter direction the index event resets the counter.This parameter can be a value of @ref TIMEx_Encoder_Index_Direction */
  74. } TIMEx_EncoderIndexConfigTypeDef;
  75. /**
  76. * @}
  77. */
  78. /* End of exported types -----------------------------------------------------*/
  79. /* Exported constants --------------------------------------------------------*/
  80. /** @defgroup TIMEx_Exported_Constants TIM Extended Exported Constants
  81. * @{
  82. */
  83. /** @defgroup TIMEx_Remap TIM Extended Remapping
  84. * @{
  85. */
  86. #define TIM_TIM1_ETR_GPIO 0x00000000UL /*!< TIM1_ETR is not connected to I/O */
  87. #if defined(COMP1)
  88. #define TIM_TIM1_ETR_COMP1 TIM1_AF1_ETRSEL_0 /*!< TIM1_ETR is connected to COMP1 output */
  89. #endif /* COMP1 */
  90. #if defined(COMP1)
  91. #define TIM_TIM1_ETR_COMP2 TIM1_AF1_ETRSEL_1 /*!< TIM1_ETR is connected to COMP2 output */
  92. #endif /* COMP1 */
  93. #define TIM_TIM1_ETR_ADC1_AWD1 (TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< TIM1_ETR is connected to ADC1 AWD1 */
  94. #define TIM_TIM1_ETR_ADC1_AWD2 TIM1_AF1_ETRSEL_2 /*!< TIM1_ETR is connected to ADC1 AWD2 */
  95. #define TIM_TIM1_ETR_ADC1_AWD3 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< TIM1_ETR is connected to ADC1 AWD3 */
  96. #define TIM_TIM2_ETR_GPIO 0x00000000UL /*!< TIM2_ETR is not connected to I/O */
  97. #if defined(COMP1)
  98. #define TIM_TIM2_ETR_COMP1 TIM1_AF1_ETRSEL_0 /*!< TIM2_ETR is connected to COMP1 output */
  99. #endif /* COMP1 */
  100. #if defined(COMP2)
  101. #define TIM_TIM2_ETR_COMP2 TIM1_AF1_ETRSEL_0 /*!< TIM2_ETR is connected to COMP2 output */
  102. #endif /* COMP2 */
  103. #define TIM_TIM2_ETR_LSE (TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< TIM2_ETR is connected to LSE */
  104. #if defined(SAI1)
  105. #define TIM_TIM2_ETR_SAI1_FSA TIM1_AF1_ETRSEL_2 /*!< TIM2_ETR is connected to SAI1 FS_A */
  106. #define TIM_TIM2_ETR_SAI1_FSB (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< TIM2_ETR is connected to SAI1 */
  107. #endif /* SAI1 */
  108. #define TIM_TIM2_ETR_TIM3_ETR (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_0) /*!< TIM2_ETR is connected to TIM3 ETR */
  109. #if defined(TIM4)
  110. #define TIM_TIM2_ETR_TIM4_ETR (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_1) /*!< TIM2_ETR is connected to TIM4 ETR */
  111. #endif /* TIM4 */
  112. #if defined(TIM5)
  113. #define TIM_TIM2_ETR_TIM5_ETR (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< TIM2_ETR is connected to TIM5 ETR */
  114. #endif /* TIM5 */
  115. #if defined(USB_DRD_FS)
  116. #define TIM_TIM2_ETR_USB_SOF (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< TIM2_ETR is connected to USB SOF */
  117. #elif defined(USB_OTG_HS)
  118. #define TIM_TIM2_ETR_USBHS_SOF (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_2) /*!< TIM2_ETR is connected to USBHS OTG SOF */
  119. #define TIM_TIM2_ETR_USBFS_SOF (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< TIM2_ETR is connected to USBFS OTG SOF */
  120. #endif /* USB_DRD_FS */
  121. #if defined(ETH_NS)
  122. #define TIM_TIM2_ETR_ETH_PPS (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1) /*!< TIM2_ETR is connected to ETH PPS */
  123. #endif /* ETH_NS */
  124. #if defined(PLAY1)
  125. #define TIM_TIM2_ETR_PLAY1_OUT0 TIM1_AF1_ETRSEL_Msk /*!< TIM2_ETR is connected to PLAY1 output 0 */
  126. #endif /* PLAY1 */
  127. #define TIM_TIM3_ETR_GPIO 0x00000000UL /*!< TIM3_ETR is not connected to I/O */
  128. #if defined(COMP1)
  129. #define TIM_TIM3_ETR_COMP1 TIM1_AF1_ETRSEL_0 /*!< TIM3_ETR is connected to COMP1 output */
  130. #endif /* COMP1 */
  131. #if defined(COMP2)
  132. #define TIM_TIM3_ETR_COMP2 TIM1_AF1_ETRSEL_1 /*!< TIM3_ETR is connected to COMP2 output */
  133. #endif /* COMP2 */
  134. #if defined(ADC2)
  135. #define TIM_TIM3_ETR_ADC2_AWD1 (TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< TIM3_ETR is connected to ADC2 AWD1 */
  136. #define TIM_TIM3_ETR_ADC2_AWD2 TIM1_AF1_ETRSEL_2 /*!< TIM3_ETR is connected to ADC2 AWD2 */
  137. #define TIM_TIM3_ETR_ADC2_AWD3 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< TIM3_ETR is connected to ADC2 AWD3 */
  138. #endif /* ADC2 */
  139. #define TIM_TIM3_ETR_TIM2_ETR TIM1_AF1_ETRSEL_3 /*!< TIM3_ETR is connected to TIM2 ETR */
  140. #if defined(TIM4)
  141. #define TIM_TIM3_ETR_TIM4_ETR (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_1) /*!< TIM3_ETR is connected to TIM4 ETR */
  142. #endif /* TIM4 */
  143. #if defined(TIM5)
  144. #define TIM_TIM3_ETR_TIM5_ETR (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_1| TIM1_AF1_ETRSEL_0) /*!< TIM3_ETR is connected to TIM5 ETR */
  145. #endif /* TIM5 */
  146. #if defined(ETH_NS)
  147. #define TIM_TIM3_ETR_ETH_PPS (TIM1_AF1_ETRSEL_1| TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_3 ) /*!< TIM3_ETR is connected to ETH PPS */
  148. #endif /* ETH_NS */
  149. #if defined(PLAY1)
  150. #define TIM_TIM3_ETR_PLAY1_OUT0 TIM1_AF1_ETRSEL_Msk /*!< TIM3_ETR is connected to PLAY1 output 0 */
  151. #endif /* PLAY1 */
  152. #if defined(TIM4)
  153. #define TIM_TIM4_ETR_GPIO 0x00000000UL /*!< TIM4_ETR is not connected to I/O */
  154. #if defined(COMP1) && defined(COMP2)
  155. #define TIM_TIM4_ETR_COMP1 TIM1_AF1_ETRSEL_0 /*!< TIM4_ETR is connected to COMP1 output */
  156. #define TIM_TIM4_ETR_COMP2 TIM1_AF1_ETRSEL_1 /*!< TIM4_ETR is connected to COMP2 output */
  157. #endif /* COMP1 && COMP2 */
  158. #define TIM_TIM4_ETR_TIM2_ETR TIM1_AF1_ETRSEL_3 /*!< TIM4_ETR is connected to TIM2 ETR */
  159. #define TIM_TIM4_ETR_TIM3_ETR (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_0) /*!< TIM4_ETR is connected to TIM3 ETR */
  160. #define TIM_TIM4_ETR_TIM5_ETR (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_1| TIM1_AF1_ETRSEL_0) /*!< TIM4_ETR is connected to TIM5 ETR */
  161. #endif /* TIM4 */
  162. #if defined(TIM5)
  163. #define TIM_TIM5_ETR_GPIO 0x00000000UL /*!< TIM5_ETR is not connected to I/O */
  164. #define TIM_TIM5_ETR_SAI2_FSA TIM1_AF1_ETRSEL_0 /*!< TIM5_ETR is connected to SAI2 */
  165. #define TIM_TIM5_ETR_SAI2_FSB TIM1_AF1_ETRSEL_1 /*!< TIM5_ETR is connected to SAI2 */
  166. #if defined(COMP1) && defined(COMP2)
  167. #define TIM_TIM5_ETR_COMP1 TIM1_AF1_ETRSEL_0 /*!< TIM5_ETR is connected to COMP1 output */
  168. #define TIM_TIM5_ETR_COMP2 TIM1_AF1_ETRSEL_1 /*!< TIM5_ETR is connected to COMP2 output */
  169. #endif /* COMP1 && COMP2 */
  170. #define TIM_TIM5_ETR_TIM2_ETR TIM1_AF1_ETRSEL_3 /*!< TIM5_ETR is connected to TIM2 ETR */
  171. #define TIM_TIM5_ETR_TIM3_ETR (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_0) /*!< TIM5_ETR is connected to TIM3 ETR */
  172. #define TIM_TIM5_ETR_TIM4_ETR (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_1) /*!< TIM5_ETR is connected to TIM4 ETR */
  173. #if defined(USB_DRD_FS)
  174. #define TIM_TIM5_ETR_USB_SOF (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< TIM5_ETR is connected to USB SOF */
  175. #elif defined(USB_OTG_HS)
  176. #define TIM_TIM5_ETR_USBHS_SOF (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_2) /*!< TIM5_ETR is connected to USBHS OTG SOF */
  177. #define TIM_TIM5_ETR_USBFS_SOF (TIM1_AF1_ETRSEL_3 | TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< TIM5_ETR is connected to USBFS OTG SOF */
  178. #endif /* USB_DRD_FS */
  179. #endif /* TIM5 */
  180. #if defined(TIM8)
  181. #define TIM_TIM8_ETR_GPIO 0x00000000UL /*!< TIM8_ETR is not connected to I/O */
  182. #if defined(COMP1) && defined(COMP2)
  183. #define TIM_TIM8_ETR_COMP1 TIM1_AF1_ETRSEL_0 /*!< TIM8_ETR is connected to COMP1 output */
  184. #define TIM_TIM8_ETR_COMP2 TIM1_AF1_ETRSEL_1 /*!< TIM8_ETR is connected to COMP2 output */
  185. #endif /* COMP1 && COMP2 */
  186. #define TIM_TIM8_ETR_ADC2_AWD1 (TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< TIM8_ETR is connected to ADC2 AWD1 */
  187. #define TIM_TIM8_ETR_ADC2_AWD2 TIM1_AF1_ETRSEL_2 /*!< TIM8_ETR is connected to ADC2 AWD2 */
  188. #define TIM_TIM8_ETR_ADC2_AWD3 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /*!< TIM8_ETR is connected to ADC2 AWD3 */
  189. #if defined(ADC3)
  190. #define TIM_TIM8_ETR_ADC3_AWD1 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1) /*!< TIM8_ETR is connected to ADC3 AWD1 */
  191. #define TIM_TIM8_ETR_ADC3_AWD2 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /*!< TIM8_ETR is connected to ADC3 AWD2 */
  192. #define TIM_TIM8_ETR_ADC3_AWD3 TIM1_AF1_ETRSEL_3 /*!< TIM8_ETR is connected to ADC3 AWD3 */
  193. #endif /* ADC3 */
  194. #endif /* TIM8 */
  195. /**
  196. * @}
  197. */
  198. /** @defgroup TIMEx_Break_Input TIM Extended Break input
  199. * @{
  200. */
  201. #define TIM_BREAKINPUT_BRK 0x00000001U /*!< Timer break input */
  202. #define TIM_BREAKINPUT_BRK2 0x00000002U /*!< Timer break2 input */
  203. /**
  204. * @}
  205. */
  206. /** @defgroup TIMEx_Break_Input_Source TIM Extended Break input source
  207. * @{
  208. */
  209. #define TIM_BREAKINPUTSOURCE_BKIN 0x00000001U /*!< An external source (GPIO) is connected to the BKIN pin */
  210. #if defined(COMP1)
  211. #define TIM_BREAKINPUTSOURCE_COMP1 0x00000002U /*!< The COMP1 output is connected to the break input */
  212. #endif /* COMP1 */
  213. #if defined(COMP2)
  214. #define TIM_BREAKINPUTSOURCE_COMP2 0x00000004U /*!< The COMP2 output is connected to the break input */
  215. #endif /* COMP2 */
  216. #if defined(PLAY1)
  217. #define TIM_BREAKINPUTSOURCE_PLAY1 0x00000008U /*!< The PLAY1 output is connected to the break input (only for BKIN) */
  218. #endif /* PLAY1 */
  219. #if defined(MDF1)
  220. #define TIM_BREAKINPUTSOURCE_MDF1 0x00000100U /*!< The Digital filter break output is connected to the break input */
  221. #endif /* MDF1 */
  222. /**
  223. * @}
  224. */
  225. /** @defgroup TIMEx_Break_Input_Source_Enable TIM Extended Break input source enabling
  226. * @{
  227. */
  228. #define TIM_BREAKINPUTSOURCE_DISABLE 0x00000000U /*!< Break input source is disabled */
  229. #define TIM_BREAKINPUTSOURCE_ENABLE 0x00000001U /*!< Break input source is enabled */
  230. /**
  231. * @}
  232. */
  233. /** @defgroup TIMEx_Break_Input_Source_Polarity TIM Extended Break input polarity
  234. * @{
  235. */
  236. #define TIM_BREAKINPUTSOURCE_POLARITY_LOW 0x00000001U /*!< Break input source is active low */
  237. #define TIM_BREAKINPUTSOURCE_POLARITY_HIGH 0x00000000U /*!< Break input source is active_high */
  238. /**
  239. * @}
  240. */
  241. /** @defgroup TIMEx_Timer_Input_Selection TIM Extended Timer input selection
  242. * @{
  243. */
  244. #define TIM_TIM1_TI1_GPIO 0x00000000UL /*!< TIM1_TI1 is connected to GPIO */
  245. #if defined(COMP1) && defined(COMP2)
  246. #define TIM_TIM1_TI1_COMP1 TIM_TISEL_TI1SEL_1 /*!< TIM1_TI1 is connected to COMP1 OUT */
  247. #define TIM_TIM1_TI1_COMP2 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM1_TI1 is connected to COMP2 OUT */
  248. #elif defined(COMP1)
  249. #define TIM_TIM1_TI1_COMP1 TIM_TISEL_TI1SEL_0 /*!< TIM1_TI1 is connected to COMP1 OUT */
  250. #endif /* COMP1 && COMP2 */
  251. #define TIM_TIM1_TI2_GPIO 0x00000000UL /*!< TIM1_TI2 is connected to GPIO */
  252. #define TIM_TIM1_TI3_GPIO 0x00000000UL /*!< TIM1_TI3 is connected to GPIO */
  253. #define TIM_TIM1_TI4_GPIO 0x00000000UL /*!< TIM1_TI4 is connected to GPIO */
  254. #define TIM_TIM2_TI1_GPIO 0x00000000UL /*!< TIM2_TI1 is connected to GPIO */
  255. #if defined(STM32H503xx)
  256. #define TIM_TIM2_TI1_LSI TIM_TISEL_TI1SEL_0 /*!< TIM2_TI1 is connected to LSI */
  257. #define TIM_TIM2_TI1_LSE TIM_TISEL_TI1SEL_1 /*!< TIM2_TI1 is connected to LSE */
  258. #define TIM_TIM2_TI1_RTC_WKUP (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM2_TI1 is connected to RTC */
  259. #define TIM_TIM2_TI1_TIM3_TI1 TIM_TISEL_TI1SEL_2 /*!< TIM2_TI1 is connected to TIM3 TI1 */
  260. #endif /* STM32H503xx */
  261. #if defined(ETH_NS)
  262. #define TIM_TIM2_TI1_ETH_PPS TIM_TISEL_TI1SEL_0 /*!< TIM2_TI1 is connected to ETH PPS */
  263. #endif /* ETH_NS */
  264. #if defined(COMP1) && defined(COMP2)
  265. #define TIM_TIM2_TI1_COMP1 TIM_TISEL_TI1SEL_1 /*!< TIM2_TI1 is connected to COMP1 output */
  266. #define TIM_TIM2_TI1_COMP2 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM2_TI1 is connected to COMP2 output */
  267. #define TIM_TIM2_TI1_PLAY1_OUT3 TIM_TISEL_TI1SEL_2 /*!< TIM2_TI1 is connected to PLAY1 output 3 */
  268. #endif /* COMP1 && COMP2 */
  269. #define TIM_TIM2_TI2_GPIO 0x00000000UL /*!< TIM2_TI2 is connected to GPIO */
  270. #if defined(STM32H503xx)
  271. #define TIM_TIM2_TI2_HSI_1024 TIM_TISEL_TI2SEL_0 /*!< TIM2_TI2 is connected to HSI_1024 */
  272. #define TIM_TIM2_TI2_CSI_128 TIM_TISEL_TI2SEL_1 /*!< TIM2_TI2 is connected to CSI_128 */
  273. #define TIM_TIM2_TI2_MCO2 (TIM_TISEL_TI2SEL_1 |TIM_TISEL_TI2SEL_0) /*!< TIM2_TI2 is connected to MCO2 */
  274. #define TIM_TIM2_TI2_MCO1 TIM_TISEL_TI2SEL_2 /*!< TIM2_TI2 is connected to MCO1 */
  275. #endif /* STM32H503xx */
  276. #if defined(COMP1) && defined(COMP2)
  277. #define TIM_TIM2_TI2_COMP1 TIM_TISEL_TI2SEL_0 /*!< TIM2_TI2 is connected to COMP1 output */
  278. #define TIM_TIM2_TI2_COMP2 TIM_TISEL_TI2SEL_1 /*!< TIM2_TI2 is connected to COMP2 output */
  279. #endif /* COMP1 && COMP2 */
  280. #define TIM_TIM2_TI3_GPIO 0x00000000UL /*!< TIM2_TI3 is connected to GPIO */
  281. #define TIM_TIM2_TI4_GPIO 0x00000000UL /*!< TIM2_TI4 is connected to GPIO */
  282. #if defined(STM32H503xx)
  283. #define TIM_TIM2_TI4_COMP1 TIM_TISEL_TI4SEL_0 /*!< TIM2_TI4 is connected to COMP1 */
  284. #endif /* STM32H503xx */
  285. #define TIM_TIM3_TI1_GPIO 0x00000000UL /*!< TIM3_TI1 is connected to GPIO */
  286. #if defined(STM32H503xx)
  287. #define TIM_TIM3_TI1_COMP1 TIM_TISEL_TI1SEL_0 /*!< TIM3_TI1 is connected to COMP1 */
  288. #define TIM_TIM3_TI1_MCO1 TIM_TISEL_TI1SEL_1 /*!< TIM3_TI1 is connected to MCO1 */
  289. #define TIM_TIM3_TI1_TIM2_TI1 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM3_TI1 is connected to TIM2 TI1 */
  290. #define TIM_TIM3_TI1_HSE_1MHZ TIM_TISEL_TI1SEL_2 /*!< TIM3_TI1 is connected to HSE 1MHZ */
  291. #endif /* STM32H503xx */
  292. #if defined(ETH_NS)
  293. #define TIM_TIM3_TI1_ETH_PPS TIM_TISEL_TI1SEL_0 /*!< TIM3_TI1 is connected to ETH PPS */
  294. #endif /* ETH_NS */
  295. #if defined(COMP1) && defined(COMP2)
  296. #define TIM_TIM3_TI1_COMP1 TIM_TISEL_TI1SEL_1 /*!< TIM3_TI1 is connected to COMP1 output */
  297. #define TIM_TIM3_TI1_COMP2 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM3_TI1 is connected to COMP2 output */
  298. #define TIM_TIM3_TI1_PLAY1_OUT3 TIM_TISEL_TI1SEL_2 /*!< TIM3_TI1 is connected to PLAY1 output 3 */
  299. #endif /* COMP1 && COMP2 */
  300. #define TIM_TIM3_TI2_GPIO 0x00000000UL /*!< TIM3_TI2 is connected to GPIO */
  301. #if defined(STM32H503xx)
  302. #define TIM_TIM3_TI2_CSI_128 TIM_TISEL_TI2SEL_0 /*!< TIM3_TI2 is connected to CSI 128 */
  303. #define TIM_TIM3_TI2_MCO2 TIM_TISEL_TI2SEL_1 /*!< TIM3_TI2 is connected to MCO2 */
  304. #define TIM_TIM3_TI2_HSI_1024 (TIM_TISEL_TI2SEL_1 |TIM_TISEL_TI2SEL_0) /*!< TIM3_TI2 is connected to HSI 1024 */
  305. #endif /* STM32H503xx */
  306. #if defined(COMP1) && defined(COMP2)
  307. #define TIM_TIM3_TI2_COMP1 TIM_TISEL_TI2SEL_0 /*!< TIM3_TI2 is connected to COMP1 output */
  308. #define TIM_TIM3_TI2_COMP2 TIM_TISEL_TI2SEL_1 /*!< TIM3_TI2 is connected to COMP2 output */
  309. #endif /* COMP1 && COMP2 */
  310. #define TIM_TIM3_TI3_GPIO 0x00000000UL /*!< TIM3_TI3 is connected to GPIO */
  311. #define TIM_TIM3_TI4_GPIO 0x00000000UL /*!< TIM3_TI4 is connected to GPIO */
  312. #if defined(TIM4)
  313. #define TIM_TIM4_TI1_GPIO 0x00000000UL /*!< TIM4_TI1 is connected to GPIO */
  314. #if defined(COMP1) && defined(COMP2)
  315. #define TIM_TIM4_TI1_COMP1 TIM_TISEL_TI1SEL_1 /*!< TIM4_TI1 is connected to COMP1 output */
  316. #define TIM_TIM4_TI1_COMP2 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM4_TI1 is connected to COMP2 output */
  317. #endif /* COMP1 && COMP2 */
  318. #define TIM_TIM4_TI2_GPIO 0x00000000UL /*!< TIM4_TI2 is connected to GPIO */
  319. #define TIM_TIM4_TI3_GPIO 0x00000000UL /*!< TIM4_TI3 is connected to GPIO */
  320. #define TIM_TIM4_TI4_GPIO 0x00000000UL /*!< TIM4_TI4 is connected to GPIO */
  321. #endif /* TIM4 */
  322. #if defined(TIM5)
  323. #define TIM_TIM5_TI1_GPIO 0x00000000UL /*!< TIM5_TI1 is connected to GPIO */
  324. #if defined(COMP1) && defined(COMP2)
  325. #define TIM_TIM5_TI1_COMP1 TIM_TISEL_TI1SEL_1 /*!< TIM5_TI1 is connected to COMP1 output */
  326. #define TIM_TIM5_TI1_COMP2 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM5_TI1 is connected to COMP2 output */
  327. #endif /* COMP1 && COMP2 */
  328. #define TIM_TIM5_TI2_GPIO 0x00000000UL /*!< TIM5_TI2 is connected to GPIO */
  329. #define TIM_TIM5_TI3_GPIO 0x00000000UL /*!< TIM5_TI3 is connected to GPIO */
  330. #define TIM_TIM5_TI4_GPIO 0x00000000UL /*!< TIM5_TI4 is connected to GPIO */
  331. #endif /* TIM5 */
  332. #if defined(TIM8)
  333. #define TIM_TIM8_TI1_GPIO 0x00000000UL /*!< TIM8_TI1 is connected to GPIO */
  334. #if defined(COMP1) && defined(COMP2)
  335. #define TIM_TIM8_TI1_COMP1 TIM_TISEL_TI1SEL_1 /*!< TIM8_TI1 is connected to COMP1 output */
  336. #define TIM_TIM8_TI1_COMP2 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM8_TI1 is connected to COMP2 output */
  337. #endif /* COMP1 && COMP2 */
  338. #define TIM_TIM8_TI2_GPIO 0x00000000UL /*!< TIM8_TI2 is connected to GPIO */
  339. #define TIM_TIM8_TI3_GPIO 0x00000000UL /*!< TIM8_TI3 is connected to GPIO */
  340. #define TIM_TIM8_TI4_GPIO 0x00000000UL /*!< TIM8_TI4 is connected to GPIO */
  341. #endif /* TIM8 */
  342. #if defined(TIM12)
  343. #define TIM_TIM12_TI1_GPIO 0x00000000UL /*!< TIM12_TI1 is connected to GPIO */
  344. #if defined(COMP1) && defined(COMP2)
  345. #define TIM_TIM12_TI1_COMP1 TIM_TISEL_TI1SEL_1 /*!< TIM12_TI1 is connected to COMP1 output */
  346. #define TIM_TIM12_TI1_COMP2 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM12_TI1 is connected to COMP2 output */
  347. #endif /* COMP1 && COMP2 */
  348. #define TIM_TIM12_TI1_HSI_1024 TIM_TISEL_TI1SEL_2 /*!< TIM12_TI1 is connected to HSI 1024 */
  349. #define TIM_TIM12_TI1_CSI_128 (TIM_TISEL_TI1SEL_2 |TIM_TISEL_TI1SEL_0) /*!< TIM12_TI1 is connected to CSI 128 */
  350. #define TIM_TIM12_TI2_GPIO 0x00000000UL /*!< TIM12_TI2 is connected to GPIO */
  351. #if defined(COMP2)
  352. #define TIM_TIM12_TI2_COMP2 TIM_TISEL_TI2SEL_0 /*!< TIM12_TI2 is connected to COMP2 output */
  353. #endif /* COMP2 */
  354. #endif /* TIM12 */
  355. #if defined(TIM13)
  356. #define TIM_TIM13_TI1_GPIO 0x00000000UL /*!< TIM13_TI1 is connected to GPIO */
  357. #if defined(I3C1)
  358. #define TIM_TIM13_TI1_I3C1_IBIACK TIM_TISEL_TI1SEL_0 /*!< TIM13_TI1 is connected to I3C1 IBI ACK */
  359. #endif /* I3C1 */
  360. #if defined(COMP1) && defined(COMP2)
  361. #define TIM_TIM13_TI1_COMP1 TIM_TISEL_TI1SEL_1 /*!< TIM13_TI1 is connected to COMP1 output */
  362. #define TIM_TIM13_TI1_COMP2 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM13_TI1 is connected to COMP2 output */
  363. #endif /* COMP1 && COMP2 */
  364. #endif /* TIM13 */
  365. #if defined(TIM14)
  366. #define TIM_TIM14_TI1_GPIO 0x00000000UL /*!< TIM14_TI1 is connected to GPIO */
  367. #if defined(I3C2)
  368. #define TIM_TIM14_TI1_I3C2_IBIACK TIM_TISEL_TI1SEL_0 /*!< TIM14_TI1 is connected to I3C2 IBI ACK */
  369. #endif /* I3C1 */
  370. #if defined(COMP1) && defined(COMP2)
  371. #define TIM_TIM14_TI1_COMP1 TIM_TISEL_TI1SEL_1 /*!< TIM14_TI1 is connected to COMP1 output */
  372. #define TIM_TIM14_TI1_COMP2 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM14_TI1 is connected to COMP2 output */
  373. #endif /* COMP1 && COMP2 */
  374. #endif /* TIM14 */
  375. #if defined(TIM15)
  376. #define TIM_TIM15_TI1_GPIO 0x00000000UL /*!< TIM15_TI1 is connected to GPIO */
  377. #define TIM_TIM15_TI1_TIM2 TIM_TISEL_TI1SEL_0 /*!< TIM15_TI1 is connected to TIM2 */
  378. #define TIM_TIM15_TI1_TIM3 TIM_TISEL_TI1SEL_1 /*!< TIM15_TI1 is connected to TIM3 */
  379. #define TIM_TIM15_TI1_TIM4 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM15_TI1 is connected to TIM4 */
  380. #define TIM_TIM15_TI1_LSE TIM_TISEL_TI1SEL_2 /*!< TIM15_TI1 is connected to LSE */
  381. #define TIM_TIM15_TI1_CSI_128 (TIM_TISEL_TI1SEL_2 |TIM_TISEL_TI1SEL_0) /*!< TIM15_TI1 is connected to CSI 128*/
  382. #define TIM_TIM15_TI1_MCO2 (TIM_TISEL_TI1SEL_2 |TIM_TISEL_TI1SEL_1) /*!< TIM15_TI1 is connected to MCO2 */
  383. #if defined(COMP1) && defined(COMP2)
  384. #define TIM_TIM15_TI1_COMP1 TIM_TISEL_TI1SEL_3 /*!< TIM15_TI1 is connected to COMP1 output */
  385. #define TIM_TIM15_TI1_COMP2 (TIM_TISEL_TI1SEL_3 | TIM_TISEL_TI1SEL_0) /*!< TIM15_TI1 is connected to COMP2 output */
  386. #endif /* COMP1 && COMP2 */
  387. #define TIM_TIM15_TI2_GPIO 0x00000000UL /*!< TIM15_TI1 is connected to GPIO */
  388. #define TIM_TIM15_TI2_TIM2 TIM_TISEL_TI2SEL_0 /*!< TIM15_TI2 is connected to TIM2 */
  389. #define TIM_TIM15_TI2_TIM3 TIM_TISEL_TI2SEL_1 /*!< TIM15_TI2 is connected to TIM3 */
  390. #define TIM_TIM15_TI2_TIM4 (TIM_TISEL_TI2SEL_1 | TIM_TISEL_TI2SEL_0) /*!< TIM15_TI2 is connected to TIM4 */
  391. #if defined(COMP1) && defined(COMP2)
  392. #define TIM_TIM15_TI2_COMP1 TIM_TISEL_TI2SEL_2 /*!< TIM15_TI2 is connected to COMP1 output */
  393. #define TIM_TIM15_TI2_COMP2 (TIM_TISEL_TI2SEL_2 | TIM_TISEL_TI2SEL_0) /*!< TIM15_TI2 is connected to COMP2 output */
  394. #endif /* COMP1 && COMP2 */
  395. #endif /* TIM15 */
  396. #if defined(TIM16)
  397. #define TIM_TIM16_TI1_GPIO 0x00000000UL /*!< TIM16_TI1 is connected to GPIO */
  398. #define TIM_TIM16_TI1_LSI TIM_TISEL_TI1SEL_0 /*!< TIM16_TI1 is connected to LSI */
  399. #define TIM_TIM16_TI1_LSE TIM_TISEL_TI1SEL_1 /*!< TIM16_TI1 is connected to LSE */
  400. #define TIM_TIM16_TI1_RTC_WKUP (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM16_TI1 is connected to RTC */
  401. #if defined(COMP1) && defined(COMP2)
  402. #define TIM_TIM16_TI1_COMP1 TIM_TISEL_TI1SEL_3 /*!< TIM16_TI1 is connected to COMP1 output */
  403. #define TIM_TIM16_TI1_COMP2 (TIM_TISEL_TI1SEL_3 | TIM_TISEL_TI1SEL_0) /*!< TIM16_TI1 is connected to COMP2 output */
  404. #endif /* COMP1 && COMP2 */
  405. #endif /* TIM16 */
  406. #if defined(TIM17)
  407. #define TIM_TIM17_TI1_GPIO 0x00000000UL /*!< TIM17_TI1 is connected to GPIO */
  408. #define TIM_TIM17_TI1_HSE_1MHZ TIM_TISEL_TI1SEL_1 /*!< TIM17_TI1 is connected to HSE 1MHZ */
  409. #define TIM_TIM17_TI1_MCO1 (TIM_TISEL_TI1SEL_1 | TIM_TISEL_TI1SEL_0) /*!< TIM17_TI1 is connected to MCO1 */
  410. #if defined(COMP1) && defined(COMP2)
  411. #define TIM_TIM17_TI1_COMP1 TIM_TISEL_TI1SEL_2 /*!< TIM17_TI1 is connected to COMP1 output */
  412. #define TIM_TIM17_TI1_COMP2 (TIM_TISEL_TI1SEL_2 | TIM_TISEL_TI1SEL_0) /*!< TIM17_TI1 is connected to COMP2 output */
  413. #endif /* COMP1 && COMP2 */
  414. #endif /* TIM17 */
  415. /**
  416. * @}
  417. */
  418. /** @defgroup TIMEx_SMS_Preload_Enable TIM Extended Bitfield SMS preload enabling
  419. * @{
  420. */
  421. #define TIM_SMS_PRELOAD_SOURCE_UPDATE 0x00000000U /*!< Prelaod of SMS bitfield is disabled */
  422. #define TIM_SMS_PRELOAD_SOURCE_INDEX TIM_SMCR_SMSPS /*!< Preload of SMS bitfield is enabled */
  423. /**
  424. * @}
  425. */
  426. /** @defgroup TIMEx_Encoder_Index_Blanking TIM Extended Encoder index blanking
  427. * @{
  428. */
  429. #define TIM_ENCODERINDEX_BLANKING_DISABLE 0x00000000U /*!< Encoder index blanking is disabled */
  430. #define TIM_ENCODERINDEX_BLANKING_TI3 TIM_ECR_IBLK_0 /*!< Encoder index blanking is enabled on TI3 */
  431. #define TIM_ENCODERINDEX_BLANKING_TI4 TIM_ECR_IBLK_1 /*!< Encoder index blanking is enabled on TI4 */
  432. /**
  433. * @}
  434. */
  435. /** @defgroup TIMEx_Encoder_Index_Position TIM Extended Encoder index position
  436. * @{
  437. */
  438. #define TIM_ENCODERINDEX_POSITION_00 0x00000000U /*!< Encoder index position is AB=00 */
  439. #define TIM_ENCODERINDEX_POSITION_01 TIM_ECR_IPOS_0 /*!< Encoder index position is AB=01 */
  440. #define TIM_ENCODERINDEX_POSITION_10 TIM_ECR_IPOS_1 /*!< Encoder index position is AB=10 */
  441. #define TIM_ENCODERINDEX_POSITION_11 (TIM_ECR_IPOS_1 | TIM_ECR_IPOS_0) /*!< Encoder index position is AB=11 */
  442. #define TIM_ENCODERINDEX_POSITION_0 0x00000000U /*!< In directional clock mode or clock plus direction mode, index resets the counter when clock is 0 */
  443. #define TIM_ENCODERINDEX_POSITION_1 TIM_ECR_IPOS_0 /*!< In directional clock mode or clock plus direction mode, index resets the counter when clock is 1 */
  444. /**
  445. * @}
  446. */
  447. /** @defgroup TIMEx_Encoder_Index_Direction TIM Extended Encoder index direction
  448. * @{
  449. */
  450. #define TIM_ENCODERINDEX_DIRECTION_UP_DOWN 0x00000000U /*!< Index resets the counter whatever the direction */
  451. #define TIM_ENCODERINDEX_DIRECTION_UP TIM_ECR_IDIR_0 /*!< Index resets the counter when up-counting only */
  452. #define TIM_ENCODERINDEX_DIRECTION_DOWN TIM_ECR_IDIR_1 /*!< Index resets the counter when down-counting only */
  453. /**
  454. * @}
  455. */
  456. /** @defgroup TIMEx_Encoder_Index_Polarity TIM Extended Encoder index polarity
  457. * @{
  458. */
  459. #define TIM_ENCODERINDEX_POLARITY_INVERTED TIM_ETRPOLARITY_INVERTED /*!< Polarity for ETRx pin */
  460. #define TIM_ENCODERINDEX_POLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED /*!< Polarity for ETRx pin */
  461. /**
  462. * @}
  463. */
  464. /** @defgroup TIMEx_Encoder_Index_Prescaler TIM Extended Encodder index prescaler
  465. * @{
  466. */
  467. #define TIM_ENCODERINDEX_PRESCALER_DIV1 TIM_ETRPRESCALER_DIV1 /*!< No prescaler is used */
  468. #define TIM_ENCODERINDEX_PRESCALER_DIV2 TIM_ETRPRESCALER_DIV2 /*!< Prescaler for External ETR pin: Capture performed once every 2 events. */
  469. #define TIM_ENCODERINDEX_PRESCALER_DIV4 TIM_ETRPRESCALER_DIV4 /*!< Prescaler for External ETR pin: Capture performed once every 4 events. */
  470. #define TIM_ENCODERINDEX_PRESCALER_DIV8 TIM_ETRPRESCALER_DIV8 /*!< Prescaler for External ETR pin: Capture performed once every 8 events. */
  471. /**
  472. * @}
  473. */
  474. /**
  475. * @}
  476. */
  477. /* End of exported constants -------------------------------------------------*/
  478. /* Exported macro ------------------------------------------------------------*/
  479. /** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros
  480. * @{
  481. */
  482. /**
  483. * @brief HELPER macro calculating the prescaler value to achieve the required counter clock frequency.
  484. * @note ex: @ref __HAL_TIM_CALC_PSC(80000000, 1000000);
  485. * @param __TIMCLK__ timer input clock frequency (in Hz)
  486. * @param __CNTCLK__ counter clock frequency (in Hz)
  487. * @retval Prescaler value (between Min_Data=0 and Max_Data=65535)
  488. */
  489. #define __HAL_TIM_CALC_PSC(__TIMCLK__, __CNTCLK__) \
  490. ((__TIMCLK__) >= (__CNTCLK__)) ? (uint32_t)((__TIMCLK__)/(__CNTCLK__) - 1U) : 0U
  491. /**
  492. * @brief HELPER macro calculating the auto-reload value to achieve the required output signal frequency.
  493. * @note ex: @ref __HAL_TIM_CALC_PERIOD(1000000, 0, 10000);
  494. * @param __TIMCLK__ timer input clock frequency (in Hz)
  495. * @param __PSC__ prescaler
  496. * @param __FREQ__ output signal frequency (in Hz)
  497. * @retval Auto-reload value (between Min_Data=0 and Max_Data=65535)
  498. */
  499. #define __HAL_TIM_CALC_PERIOD(__TIMCLK__, __PSC__, __FREQ__) \
  500. (((__TIMCLK__)/((__PSC__) + 1U)) >= (__FREQ__)) ? ((__TIMCLK__)/((__FREQ__) * ((__PSC__) + 1U)) - 1U) : 0U
  501. /**
  502. * @brief HELPER macro calculating the auto-reload value, with dithering feature enabled, to achieve the required
  503. * output signal frequency.
  504. * @note ex: @ref __HAL_TIM_CALC_PERIOD_DITHER(1000000, 0, 10000);
  505. * @note This macro should be used only if dithering is already enabled
  506. * @param __TIMCLK__ timer input clock frequency (in Hz)
  507. * @param __PSC__ prescaler
  508. * @param __FREQ__ output signal frequency (in Hz)
  509. * @retval Auto-reload value (between Min_Data=0 and Max_Data=65519)
  510. */
  511. #define __HAL_TIM_CALC_PERIOD_DITHER(__TIMCLK__, __PSC__, __FREQ__) \
  512. (((__TIMCLK__)/((__PSC__) + 1U)) >= (__FREQ__)) ? \
  513. (uint32_t)(((uint64_t)(__TIMCLK__)*16/((__FREQ__) * ((__PSC__) + 1U)) - 16U)) : 0U
  514. /**
  515. * @brief HELPER macro calculating the compare value required to achieve the required timer output compare
  516. * active/inactive delay.
  517. * @note ex: @ref __HAL_TIM_CALC_PULSE(1000000, 0, 10);
  518. * @param __TIMCLK__ timer input clock frequency (in Hz)
  519. * @param __PSC__ prescaler
  520. * @param __DELAY__ timer output compare active/inactive delay (in us)
  521. * @retval Compare value (between Min_Data=0 and Max_Data=65535)
  522. */
  523. #define __HAL_TIM_CALC_PULSE(__TIMCLK__, __PSC__, __DELAY__) \
  524. ((uint32_t)(((uint64_t)(__TIMCLK__) * (uint64_t)(__DELAY__)) \
  525. / ((uint64_t)1000000U * (uint64_t)((__PSC__) + 1U))))
  526. /**
  527. * @brief HELPER macro calculating the compare value, with dithering feature enabled, to achieve the required timer
  528. * output compare active/inactive delay.
  529. * @note ex: @ref __HAL_TIM_CALC_PULSE_DITHER(1000000, 0, 10);
  530. * @note This macro should be used only if dithering is already enabled
  531. * @param __TIMCLK__ timer input clock frequency (in Hz)
  532. * @param __PSC__ prescaler
  533. * @param __DELAY__ timer output compare active/inactive delay (in us)
  534. * @retval Compare value (between Min_Data=0 and Max_Data=65519)
  535. */
  536. #define __HAL_TIM_CALC_PULSE_DITHER(__TIMCLK__, __PSC__, __DELAY__) \
  537. ((uint32_t)(((uint64_t)(__TIMCLK__) * (uint64_t)(__DELAY__) * 16U) \
  538. / ((uint64_t)1000000U * (uint64_t)((__PSC__) + 1U))))
  539. /**
  540. * @brief HELPER macro calculating the auto-reload value to achieve the required pulse duration
  541. * (when the timer operates in one pulse mode).
  542. * @note ex: @ref __HAL_TIM_CALC_PERIOD_BY_DELAY(1000000, 0, 10, 20);
  543. * @param __TIMCLK__ timer input clock frequency (in Hz)
  544. * @param __PSC__ prescaler
  545. * @param __DELAY__ timer output compare active/inactive delay (in us)
  546. * @param __PULSE__ pulse duration (in us)
  547. * @retval Auto-reload value (between Min_Data=0 and Max_Data=65535)
  548. */
  549. #define __HAL_TIM_CALC_PERIOD_BY_DELAY(__TIMCLK__, __PSC__, __DELAY__, __PULSE__) \
  550. ((uint32_t)(__HAL_TIM_CALC_PULSE((__TIMCLK__), (__PSC__), (__PULSE__)) \
  551. + __HAL_TIM_CALC_PULSE((__TIMCLK__), (__PSC__), (__DELAY__))))
  552. /**
  553. * @brief HELPER macro calculating the auto-reload value, with dithering feature enabled, to achieve the required
  554. * pulse duration (when the timer operates in one pulse mode).
  555. * @note ex: @ref __HAL_TIM_CALC_PERIOD_DITHER_BY_DELAY(1000000, 0, 10, 20);
  556. * @note This macro should be used only if dithering is already enabled
  557. * @param __TIMCLK__ timer input clock frequency (in Hz)
  558. * @param __PSC__ prescaler
  559. * @param __DELAY__ timer output compare active/inactive delay (in us)
  560. * @param __PULSE__ pulse duration (in us)
  561. * @retval Auto-reload value (between Min_Data=0 and Max_Data=65519)
  562. */
  563. #define __HAL_TIM_CALC_PERIOD_DITHER_BY_DELAY(__TIMCLK__, __PSC__, __DELAY__, __PULSE__) \
  564. ((uint32_t)(__HAL_TIM_CALC_PULSE_DITHER((__TIMCLK__), (__PSC__), (__PULSE__)) \
  565. + __HAL_TIM_CALC_PULSE_DITHER((__TIMCLK__), (__PSC__), (__DELAY__))))
  566. /**
  567. * @}
  568. */
  569. /* End of exported macro -----------------------------------------------------*/
  570. /* Private macro -------------------------------------------------------------*/
  571. /** @defgroup TIMEx_Private_Macros TIM Extended Private Macros
  572. * @{
  573. */
  574. #define IS_TIM_REMAP(__REMAP__) ((((__REMAP__) & 0xFFFC3FFFU) == 0x00000000U))
  575. #define IS_TIM_BREAKINPUT(__BREAKINPUT__) (((__BREAKINPUT__) == TIM_BREAKINPUT_BRK) || \
  576. ((__BREAKINPUT__) == TIM_BREAKINPUT_BRK2))
  577. #if defined(COMP1) && defined(COMP2)
  578. #define IS_TIM_BREAKINPUTSOURCE(__SOURCE__) (((__SOURCE__) == TIM_BREAKINPUTSOURCE_BKIN) || \
  579. ((__SOURCE__) == TIM_BREAKINPUTSOURCE_COMP1) || \
  580. ((__SOURCE__) == TIM_BREAKINPUTSOURCE_COMP2) || \
  581. ((__SOURCE__) == TIM_BREAKINPUTSOURCE_PLAY1) || \
  582. ((__SOURCE__) == TIM_BREAKINPUTSOURCE_MDF1))
  583. #elif defined(COMP1)
  584. #define IS_TIM_BREAKINPUTSOURCE(__SOURCE__) (((__SOURCE__) == TIM_BREAKINPUTSOURCE_BKIN) || \
  585. ((__SOURCE__) == TIM_BREAKINPUTSOURCE_COMP1))
  586. #else
  587. #define IS_TIM_BREAKINPUTSOURCE(__SOURCE__) ((__SOURCE__) == TIM_BREAKINPUTSOURCE_BKIN)
  588. #endif /* COMP1 && COMP2 */
  589. #define IS_TIM_BREAKINPUTSOURCE_STATE(__STATE__) (((__STATE__) == TIM_BREAKINPUTSOURCE_DISABLE) || \
  590. ((__STATE__) == TIM_BREAKINPUTSOURCE_ENABLE))
  591. #define IS_TIM_BREAKINPUTSOURCE_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_BREAKINPUTSOURCE_POLARITY_LOW) || \
  592. ((__POLARITY__) == TIM_BREAKINPUTSOURCE_POLARITY_HIGH))
  593. #define IS_TIM_TISEL(__TISEL__) ((((__TISEL__) & 0xF0F0F0F0U) == 0x00000000U))
  594. #define IS_TIM_TISEL_TIX_INSTANCE(INSTANCE, CHANNEL) \
  595. (IS_TIM_CCX_INSTANCE(INSTANCE, CHANNEL) && ((CHANNEL) < TIM_CHANNEL_5))
  596. #if defined(STM32H503xx)
  597. #define IS_TIM_CLOCKSOURCE_INSTANCE(INSTANCE, __CLOCK__) \
  598. ((((INSTANCE) == TIM1) && \
  599. (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL) || \
  600. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE1) || \
  601. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE2) || \
  602. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR1) || \
  603. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR2) || \
  604. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1ED) || \
  605. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1) || \
  606. ((__CLOCK__) == TIM_CLOCKSOURCE_TI2))) \
  607. || \
  608. (((INSTANCE) == TIM2) && \
  609. (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL) || \
  610. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE1) || \
  611. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE2) || \
  612. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR0) || \
  613. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR2) || \
  614. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR12) || \
  615. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1ED) || \
  616. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1) || \
  617. ((__CLOCK__) == TIM_CLOCKSOURCE_TI2))) \
  618. || \
  619. (((INSTANCE) == TIM3) && \
  620. (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL) || \
  621. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE1) || \
  622. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE2) || \
  623. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR0) || \
  624. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR1) || \
  625. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1ED) || \
  626. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1) || \
  627. ((__CLOCK__) == TIM_CLOCKSOURCE_TI2))))
  628. #define IS_TIM_TRIGGER_INSTANCE(INSTANCE, __SELECTION__) \
  629. ((((INSTANCE) == TIM1) && \
  630. (((__SELECTION__) == TIM_TS_ITR1) || \
  631. ((__SELECTION__) == TIM_TS_ITR2) || \
  632. ((__SELECTION__) == TIM_TS_TI1F_ED) || \
  633. ((__SELECTION__) == TIM_TS_TI1FP1) || \
  634. ((__SELECTION__) == TIM_TS_TI2FP2) || \
  635. ((__SELECTION__) == TIM_TS_ETRF))) \
  636. || \
  637. (((INSTANCE) == TIM2) && \
  638. (((__SELECTION__) == TIM_TS_ITR0) || \
  639. ((__SELECTION__) == TIM_TS_ITR2) || \
  640. ((__SELECTION__) == TIM_TS_ITR12) || \
  641. ((__SELECTION__) == TIM_TS_TI1F_ED) || \
  642. ((__SELECTION__) == TIM_TS_TI1FP1) || \
  643. ((__SELECTION__) == TIM_TS_TI2FP2) || \
  644. ((__SELECTION__) == TIM_TS_ETRF))) \
  645. || \
  646. (((INSTANCE) == TIM3) && \
  647. (((__SELECTION__) == TIM_TS_ITR0) || \
  648. ((__SELECTION__) == TIM_TS_ITR1) || \
  649. ((__SELECTION__) == TIM_TS_TI1F_ED) || \
  650. ((__SELECTION__) == TIM_TS_TI1FP1) || \
  651. ((__SELECTION__) == TIM_TS_TI2FP2) || \
  652. ((__SELECTION__) == TIM_TS_ETRF))))
  653. #define IS_TIM_INTERNAL_TRIGGEREVENT_INSTANCE(INSTANCE, __SELECTION__) \
  654. ((((INSTANCE) == TIM1) && \
  655. (((__SELECTION__) == TIM_TS_ITR1) || \
  656. ((__SELECTION__) == TIM_TS_ITR2) || \
  657. ((__SELECTION__) == TIM_TS_NONE))) \
  658. || \
  659. (((INSTANCE) == TIM2) && \
  660. (((__SELECTION__) == TIM_TS_ITR0) || \
  661. ((__SELECTION__) == TIM_TS_ITR2) || \
  662. ((__SELECTION__) == TIM_TS_ITR12) || \
  663. ((__SELECTION__) == TIM_TS_NONE))) \
  664. || \
  665. (((INSTANCE) == TIM3) && \
  666. (((__SELECTION__) == TIM_TS_ITR0) || \
  667. ((__SELECTION__) == TIM_TS_ITR1) || \
  668. ((__SELECTION__) == TIM_TS_NONE))))
  669. #else
  670. #define IS_TIM_CLOCKSOURCE_INSTANCE(INSTANCE, __CLOCK__) \
  671. ((((INSTANCE) == TIM1) && \
  672. (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL) || \
  673. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE1) || \
  674. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE2) || \
  675. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1ED) || \
  676. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1) || \
  677. ((__CLOCK__) == TIM_CLOCKSOURCE_TI2) || \
  678. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR1) || \
  679. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR2) || \
  680. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR3) || \
  681. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR4) || \
  682. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR5) || \
  683. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR6) || \
  684. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR7) || \
  685. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR8) || \
  686. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR9) || \
  687. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR10) || \
  688. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR11))) \
  689. || \
  690. (((INSTANCE) == TIM2) && \
  691. (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL) || \
  692. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE1) || \
  693. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE2) || \
  694. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1ED) || \
  695. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1) || \
  696. ((__CLOCK__) == TIM_CLOCKSOURCE_TI2) || \
  697. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR0) || \
  698. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR2) || \
  699. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR3) || \
  700. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR4) || \
  701. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR5) || \
  702. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR6) || \
  703. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR7) || \
  704. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR8) || \
  705. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR9) || \
  706. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR10) || \
  707. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR11) || \
  708. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR12))) \
  709. || \
  710. (((INSTANCE) == TIM3) && \
  711. (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL) || \
  712. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE1) || \
  713. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE2) || \
  714. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1ED) || \
  715. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1) || \
  716. ((__CLOCK__) == TIM_CLOCKSOURCE_TI2) || \
  717. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR0) || \
  718. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR1) || \
  719. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR3) || \
  720. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR4) || \
  721. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR5) || \
  722. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR6) || \
  723. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR7) || \
  724. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR8) || \
  725. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR9) || \
  726. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR10) || \
  727. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR11))) \
  728. || \
  729. (((INSTANCE) == TIM4) && \
  730. (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL) || \
  731. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE1) || \
  732. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE2) || \
  733. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1ED) || \
  734. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1) || \
  735. ((__CLOCK__) == TIM_CLOCKSOURCE_TI2) || \
  736. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR0) || \
  737. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR1) || \
  738. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR2) || \
  739. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR4) || \
  740. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR5) || \
  741. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR6) || \
  742. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR7) || \
  743. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR8) || \
  744. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR9) || \
  745. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR10) || \
  746. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR11))) \
  747. || \
  748. (((INSTANCE) == TIM5) && \
  749. (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL) || \
  750. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE1) || \
  751. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE2) || \
  752. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1ED) || \
  753. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1) || \
  754. ((__CLOCK__) == TIM_CLOCKSOURCE_TI2) || \
  755. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR0) || \
  756. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR1) || \
  757. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR2) || \
  758. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR3) || \
  759. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR5) || \
  760. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR6) || \
  761. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR7) || \
  762. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR8) || \
  763. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR9) || \
  764. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR10) || \
  765. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR11) || \
  766. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR12))) \
  767. || \
  768. (((INSTANCE) == TIM8) && \
  769. (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL) || \
  770. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE1) || \
  771. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE2) || \
  772. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1ED) || \
  773. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1) || \
  774. ((__CLOCK__) == TIM_CLOCKSOURCE_TI2) || \
  775. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR0) || \
  776. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR1) || \
  777. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR2) || \
  778. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR3) || \
  779. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR4) || \
  780. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR6) || \
  781. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR7) || \
  782. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR8) || \
  783. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR9) || \
  784. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR10) || \
  785. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR11))) \
  786. || \
  787. (((INSTANCE) == TIM12) && \
  788. (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL) || \
  789. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE1) || \
  790. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE2) || \
  791. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1ED) || \
  792. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1) || \
  793. ((__CLOCK__) == TIM_CLOCKSOURCE_TI2) || \
  794. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR0) || \
  795. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR1) || \
  796. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR2) || \
  797. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR3) || \
  798. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR4) || \
  799. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR5) || \
  800. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR7) || \
  801. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR8) || \
  802. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR9) || \
  803. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR10) || \
  804. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR11))) \
  805. || \
  806. (((INSTANCE) == TIM15) && \
  807. (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL) || \
  808. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1ED) || \
  809. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1) || \
  810. ((__CLOCK__) == TIM_CLOCKSOURCE_TI2) || \
  811. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR0) || \
  812. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR1) || \
  813. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR2) || \
  814. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR3) || \
  815. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR4) || \
  816. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR5) || \
  817. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR6) || \
  818. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR7) || \
  819. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR8) || \
  820. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR10) || \
  821. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR11))))
  822. #define IS_TIM_TRIGGER_INSTANCE(INSTANCE, __SELECTION__) \
  823. ((((INSTANCE) == TIM1) && \
  824. (((__SELECTION__) == TIM_TS_TI1F_ED) || \
  825. ((__SELECTION__) == TIM_TS_TI1FP1) || \
  826. ((__SELECTION__) == TIM_TS_TI2FP2) || \
  827. ((__SELECTION__) == TIM_TS_ETRF) || \
  828. ((__SELECTION__) == TIM_TS_ITR1) || \
  829. ((__SELECTION__) == TIM_TS_ITR2) || \
  830. ((__SELECTION__) == TIM_TS_ITR3) || \
  831. ((__SELECTION__) == TIM_TS_ITR4) || \
  832. ((__SELECTION__) == TIM_TS_ITR5) || \
  833. ((__SELECTION__) == TIM_TS_ITR6) || \
  834. ((__SELECTION__) == TIM_TS_ITR7) || \
  835. ((__SELECTION__) == TIM_TS_ITR8) || \
  836. ((__SELECTION__) == TIM_TS_ITR9) || \
  837. ((__SELECTION__) == TIM_TS_ITR10) || \
  838. ((__SELECTION__) == TIM_TS_ITR11))) \
  839. || \
  840. (((INSTANCE) == TIM2) && \
  841. (((__SELECTION__) == TIM_TS_TI1F_ED) || \
  842. ((__SELECTION__) == TIM_TS_TI1FP1) || \
  843. ((__SELECTION__) == TIM_TS_TI2FP2) || \
  844. ((__SELECTION__) == TIM_TS_ETRF) || \
  845. ((__SELECTION__) == TIM_TS_ITR0) || \
  846. ((__SELECTION__) == TIM_TS_ITR2) || \
  847. ((__SELECTION__) == TIM_TS_ITR3) || \
  848. ((__SELECTION__) == TIM_TS_ITR4) || \
  849. ((__SELECTION__) == TIM_TS_ITR5) || \
  850. ((__SELECTION__) == TIM_TS_ITR6) || \
  851. ((__SELECTION__) == TIM_TS_ITR7) || \
  852. ((__SELECTION__) == TIM_TS_ITR8) || \
  853. ((__SELECTION__) == TIM_TS_ITR9) || \
  854. ((__SELECTION__) == TIM_TS_ITR10) || \
  855. ((__SELECTION__) == TIM_TS_ITR11) || \
  856. ((__SELECTION__) == TIM_TS_ITR12))) \
  857. || \
  858. (((INSTANCE) == TIM3) && \
  859. (((__SELECTION__) == TIM_TS_TI1F_ED) || \
  860. ((__SELECTION__) == TIM_TS_TI1FP1) || \
  861. ((__SELECTION__) == TIM_TS_TI2FP2) || \
  862. ((__SELECTION__) == TIM_TS_ETRF) || \
  863. ((__SELECTION__) == TIM_TS_ITR0) || \
  864. ((__SELECTION__) == TIM_TS_ITR1) || \
  865. ((__SELECTION__) == TIM_TS_ITR3) || \
  866. ((__SELECTION__) == TIM_TS_ITR4) || \
  867. ((__SELECTION__) == TIM_TS_ITR5) || \
  868. ((__SELECTION__) == TIM_TS_ITR6) || \
  869. ((__SELECTION__) == TIM_TS_ITR7) || \
  870. ((__SELECTION__) == TIM_TS_ITR8) || \
  871. ((__SELECTION__) == TIM_TS_ITR9) || \
  872. ((__SELECTION__) == TIM_TS_ITR10) || \
  873. ((__SELECTION__) == TIM_TS_ITR11))) \
  874. || \
  875. (((INSTANCE) == TIM4) && \
  876. (((__SELECTION__) == TIM_TS_TI1F_ED) || \
  877. ((__SELECTION__) == TIM_TS_TI1FP1) || \
  878. ((__SELECTION__) == TIM_TS_TI2FP2) || \
  879. ((__SELECTION__) == TIM_TS_ETRF) || \
  880. ((__SELECTION__) == TIM_TS_ITR0) || \
  881. ((__SELECTION__) == TIM_TS_ITR1) || \
  882. ((__SELECTION__) == TIM_TS_ITR2) || \
  883. ((__SELECTION__) == TIM_TS_ITR4) || \
  884. ((__SELECTION__) == TIM_TS_ITR5) || \
  885. ((__SELECTION__) == TIM_TS_ITR6) || \
  886. ((__SELECTION__) == TIM_TS_ITR7) || \
  887. ((__SELECTION__) == TIM_TS_ITR8) || \
  888. ((__SELECTION__) == TIM_TS_ITR9) || \
  889. ((__SELECTION__) == TIM_TS_ITR10) || \
  890. ((__SELECTION__) == TIM_TS_ITR11))) \
  891. || \
  892. (((INSTANCE) == TIM5) && \
  893. (((__SELECTION__) == TIM_TS_TI1F_ED) || \
  894. ((__SELECTION__) == TIM_TS_TI1FP1) || \
  895. ((__SELECTION__) == TIM_TS_TI2FP2) || \
  896. ((__SELECTION__) == TIM_TS_ETRF) || \
  897. ((__SELECTION__) == TIM_TS_ITR0) || \
  898. ((__SELECTION__) == TIM_TS_ITR1) || \
  899. ((__SELECTION__) == TIM_TS_ITR2) || \
  900. ((__SELECTION__) == TIM_TS_ITR3) || \
  901. ((__SELECTION__) == TIM_TS_ITR5) || \
  902. ((__SELECTION__) == TIM_TS_ITR6) || \
  903. ((__SELECTION__) == TIM_TS_ITR7) || \
  904. ((__SELECTION__) == TIM_TS_ITR8) || \
  905. ((__SELECTION__) == TIM_TS_ITR9) || \
  906. ((__SELECTION__) == TIM_TS_ITR10) || \
  907. ((__SELECTION__) == TIM_TS_ITR11) || \
  908. ((__SELECTION__) == TIM_TS_ITR12))) \
  909. || \
  910. (((INSTANCE) == TIM8) && \
  911. (((__SELECTION__) == TIM_TS_TI1F_ED) || \
  912. ((__SELECTION__) == TIM_TS_TI1FP1) || \
  913. ((__SELECTION__) == TIM_TS_TI2FP2) || \
  914. ((__SELECTION__) == TIM_TS_ETRF) || \
  915. ((__SELECTION__) == TIM_TS_ITR0) || \
  916. ((__SELECTION__) == TIM_TS_ITR1) || \
  917. ((__SELECTION__) == TIM_TS_ITR2) || \
  918. ((__SELECTION__) == TIM_TS_ITR3) || \
  919. ((__SELECTION__) == TIM_TS_ITR4) || \
  920. ((__SELECTION__) == TIM_TS_ITR6) || \
  921. ((__SELECTION__) == TIM_TS_ITR7) || \
  922. ((__SELECTION__) == TIM_TS_ITR8) || \
  923. ((__SELECTION__) == TIM_TS_ITR9) || \
  924. ((__SELECTION__) == TIM_TS_ITR10) || \
  925. ((__SELECTION__) == TIM_TS_ITR11))) \
  926. || \
  927. (((INSTANCE) == TIM12) && \
  928. (((__SELECTION__) == TIM_TS_TI1F_ED) || \
  929. ((__SELECTION__) == TIM_TS_TI1FP1) || \
  930. ((__SELECTION__) == TIM_TS_TI2FP2) || \
  931. ((__SELECTION__) == TIM_TS_ETRF) || \
  932. ((__SELECTION__) == TIM_TS_ITR0) || \
  933. ((__SELECTION__) == TIM_TS_ITR1) || \
  934. ((__SELECTION__) == TIM_TS_ITR2) || \
  935. ((__SELECTION__) == TIM_TS_ITR3) || \
  936. ((__SELECTION__) == TIM_TS_ITR4) || \
  937. ((__SELECTION__) == TIM_TS_ITR5) || \
  938. ((__SELECTION__) == TIM_TS_ITR7) || \
  939. ((__SELECTION__) == TIM_TS_ITR8) || \
  940. ((__SELECTION__) == TIM_TS_ITR9) || \
  941. ((__SELECTION__) == TIM_TS_ITR10) || \
  942. ((__SELECTION__) == TIM_TS_ITR11))) \
  943. || \
  944. (((INSTANCE) == TIM15) && \
  945. (((__SELECTION__) == TIM_TS_TI1F_ED) || \
  946. ((__SELECTION__) == TIM_TS_TI1FP1) || \
  947. ((__SELECTION__) == TIM_TS_TI2FP2) || \
  948. ((__SELECTION__) == TIM_TS_ITR0) || \
  949. ((__SELECTION__) == TIM_TS_ITR1) || \
  950. ((__SELECTION__) == TIM_TS_ITR2) || \
  951. ((__SELECTION__) == TIM_TS_ITR3) || \
  952. ((__SELECTION__) == TIM_TS_ITR4) || \
  953. ((__SELECTION__) == TIM_TS_ITR5) || \
  954. ((__SELECTION__) == TIM_TS_ITR6) || \
  955. ((__SELECTION__) == TIM_TS_ITR7) || \
  956. ((__SELECTION__) == TIM_TS_ITR8) || \
  957. ((__SELECTION__) == TIM_TS_ITR10) || \
  958. ((__SELECTION__) == TIM_TS_ITR11))))
  959. #define IS_TIM_INTERNAL_TRIGGEREVENT_INSTANCE(INSTANCE, __SELECTION__) \
  960. ((((INSTANCE) == TIM1) && \
  961. (((__SELECTION__) == TIM_TS_ITR1) || \
  962. ((__SELECTION__) == TIM_TS_ITR2) || \
  963. ((__SELECTION__) == TIM_TS_ITR3) || \
  964. ((__SELECTION__) == TIM_TS_ITR4) || \
  965. ((__SELECTION__) == TIM_TS_ITR5) || \
  966. ((__SELECTION__) == TIM_TS_ITR6) || \
  967. ((__SELECTION__) == TIM_TS_ITR7) || \
  968. ((__SELECTION__) == TIM_TS_ITR8) || \
  969. ((__SELECTION__) == TIM_TS_ITR9) || \
  970. ((__SELECTION__) == TIM_TS_ITR10)|| \
  971. ((__SELECTION__) == TIM_TS_ITR11)|| \
  972. ((__SELECTION__) == TIM_TS_NONE))) \
  973. || \
  974. (((INSTANCE) == TIM2) && \
  975. (((__SELECTION__) == TIM_TS_ITR0) || \
  976. ((__SELECTION__) == TIM_TS_ITR2) || \
  977. ((__SELECTION__) == TIM_TS_ITR3) || \
  978. ((__SELECTION__) == TIM_TS_ITR4) || \
  979. ((__SELECTION__) == TIM_TS_ITR5) || \
  980. ((__SELECTION__) == TIM_TS_ITR6) || \
  981. ((__SELECTION__) == TIM_TS_ITR7) || \
  982. ((__SELECTION__) == TIM_TS_ITR8) || \
  983. ((__SELECTION__) == TIM_TS_ITR9) || \
  984. ((__SELECTION__) == TIM_TS_ITR10)|| \
  985. ((__SELECTION__) == TIM_TS_ITR11)|| \
  986. ((__SELECTION__) == TIM_TS_ITR12)|| \
  987. ((__SELECTION__) == TIM_TS_NONE))) \
  988. || \
  989. (((INSTANCE) == TIM3) && \
  990. (((__SELECTION__) == TIM_TS_ITR0) || \
  991. ((__SELECTION__) == TIM_TS_ITR1) || \
  992. ((__SELECTION__) == TIM_TS_ITR3) || \
  993. ((__SELECTION__) == TIM_TS_ITR4) || \
  994. ((__SELECTION__) == TIM_TS_ITR5) || \
  995. ((__SELECTION__) == TIM_TS_ITR6) || \
  996. ((__SELECTION__) == TIM_TS_ITR7) || \
  997. ((__SELECTION__) == TIM_TS_ITR8) || \
  998. ((__SELECTION__) == TIM_TS_ITR9) || \
  999. ((__SELECTION__) == TIM_TS_ITR10)|| \
  1000. ((__SELECTION__) == TIM_TS_ITR11)|| \
  1001. ((__SELECTION__) == TIM_TS_NONE))) \
  1002. || \
  1003. (((INSTANCE) == TIM4) && \
  1004. (((__SELECTION__) == TIM_TS_ITR0) || \
  1005. ((__SELECTION__) == TIM_TS_ITR1) || \
  1006. ((__SELECTION__) == TIM_TS_ITR2) || \
  1007. ((__SELECTION__) == TIM_TS_ITR4) || \
  1008. ((__SELECTION__) == TIM_TS_ITR5) || \
  1009. ((__SELECTION__) == TIM_TS_ITR6) || \
  1010. ((__SELECTION__) == TIM_TS_ITR7) || \
  1011. ((__SELECTION__) == TIM_TS_ITR8) || \
  1012. ((__SELECTION__) == TIM_TS_ITR9) || \
  1013. ((__SELECTION__) == TIM_TS_ITR10)|| \
  1014. ((__SELECTION__) == TIM_TS_ITR11)|| \
  1015. ((__SELECTION__) == TIM_TS_NONE))) \
  1016. || \
  1017. (((INSTANCE) == TIM5) && \
  1018. (((__SELECTION__) == TIM_TS_ITR0) || \
  1019. ((__SELECTION__) == TIM_TS_ITR1) || \
  1020. ((__SELECTION__) == TIM_TS_ITR2) || \
  1021. ((__SELECTION__) == TIM_TS_ITR3) || \
  1022. ((__SELECTION__) == TIM_TS_ITR5) || \
  1023. ((__SELECTION__) == TIM_TS_ITR6) || \
  1024. ((__SELECTION__) == TIM_TS_ITR7) || \
  1025. ((__SELECTION__) == TIM_TS_ITR8) || \
  1026. ((__SELECTION__) == TIM_TS_ITR9) || \
  1027. ((__SELECTION__) == TIM_TS_ITR10)|| \
  1028. ((__SELECTION__) == TIM_TS_ITR11)|| \
  1029. ((__SELECTION__) == TIM_TS_ITR12)|| \
  1030. ((__SELECTION__) == TIM_TS_NONE))) \
  1031. || \
  1032. (((INSTANCE) == TIM8) && \
  1033. (((__SELECTION__) == TIM_TS_ITR0) || \
  1034. ((__SELECTION__) == TIM_TS_ITR1) || \
  1035. ((__SELECTION__) == TIM_TS_ITR2) || \
  1036. ((__SELECTION__) == TIM_TS_ITR3) || \
  1037. ((__SELECTION__) == TIM_TS_ITR4) || \
  1038. ((__SELECTION__) == TIM_TS_ITR6) || \
  1039. ((__SELECTION__) == TIM_TS_ITR7) || \
  1040. ((__SELECTION__) == TIM_TS_ITR8) || \
  1041. ((__SELECTION__) == TIM_TS_ITR9) || \
  1042. ((__SELECTION__) == TIM_TS_ITR10)|| \
  1043. ((__SELECTION__) == TIM_TS_ITR11)|| \
  1044. ((__SELECTION__) == TIM_TS_NONE))) \
  1045. || \
  1046. (((INSTANCE) == TIM12) && \
  1047. (((__SELECTION__) == TIM_TS_ITR0) || \
  1048. ((__SELECTION__) == TIM_TS_ITR1) || \
  1049. ((__SELECTION__) == TIM_TS_ITR2) || \
  1050. ((__SELECTION__) == TIM_TS_ITR3) || \
  1051. ((__SELECTION__) == TIM_TS_ITR4) || \
  1052. ((__SELECTION__) == TIM_TS_ITR5) || \
  1053. ((__SELECTION__) == TIM_TS_ITR7) || \
  1054. ((__SELECTION__) == TIM_TS_ITR8) || \
  1055. ((__SELECTION__) == TIM_TS_ITR9) || \
  1056. ((__SELECTION__) == TIM_TS_ITR10)|| \
  1057. ((__SELECTION__) == TIM_TS_ITR11)|| \
  1058. ((__SELECTION__) == TIM_TS_NONE))) \
  1059. || \
  1060. (((INSTANCE) == TIM15) && \
  1061. (((__SELECTION__) == TIM_TS_ITR0) || \
  1062. ((__SELECTION__) == TIM_TS_ITR1) || \
  1063. ((__SELECTION__) == TIM_TS_ITR2) || \
  1064. ((__SELECTION__) == TIM_TS_ITR3) || \
  1065. ((__SELECTION__) == TIM_TS_ITR4) || \
  1066. ((__SELECTION__) == TIM_TS_ITR5) || \
  1067. ((__SELECTION__) == TIM_TS_ITR6) || \
  1068. ((__SELECTION__) == TIM_TS_ITR7) || \
  1069. ((__SELECTION__) == TIM_TS_ITR8) || \
  1070. ((__SELECTION__) == TIM_TS_ITR10)|| \
  1071. ((__SELECTION__) == TIM_TS_ITR11)|| \
  1072. ((__SELECTION__) == TIM_TS_NONE))))
  1073. #if defined(TIM17)
  1074. #define IS_TIM_RTCPREEN_SELECTION(__SELECTION__) ((__SELECTION__) == TIM_TIM17_TI1_HSE_1MHZ)
  1075. #endif /* TIM17 */
  1076. #endif /* STM32H503xx */
  1077. #define IS_TIM_OC_CHANNEL_MODE(__MODE__, __CHANNEL__) \
  1078. (IS_TIM_OC_MODE(__MODE__) \
  1079. && ((((__MODE__) == TIM_OCMODE_DIRECTION_OUTPUT) || ((__MODE__) == TIM_OCMODE_PULSE_ON_COMPARE)) \
  1080. ? (((__CHANNEL__) == TIM_CHANNEL_3) || ((__CHANNEL__) == TIM_CHANNEL_4)) : (1 == 1)))
  1081. #define IS_TIM_PULSEONCOMPARE_CHANNEL(__CHANNEL__) \
  1082. (((__CHANNEL__) == TIM_CHANNEL_3) || \
  1083. ((__CHANNEL__) == TIM_CHANNEL_4))
  1084. #define IS_TIM_PULSEONCOMPARE_INSTANCE(INSTANCE) IS_TIM_CC3_INSTANCE(INSTANCE)
  1085. #define IS_TIM_PULSEONCOMPARE_WIDTH(__WIDTH__) ((__WIDTH__) <= 0xFFU)
  1086. #define IS_TIM_PULSEONCOMPARE_WIDTHPRESCALER(__PRESCALER__) ((__PRESCALER__) <= 0x7U)
  1087. #define IS_TIM_SLAVE_PRELOAD_SOURCE(__SOURCE__) (((__SOURCE__) == TIM_SMS_PRELOAD_SOURCE_UPDATE) \
  1088. || ((__SOURCE__) == TIM_SMS_PRELOAD_SOURCE_INDEX))
  1089. #define IS_TIM_ENCODERINDEX_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_ENCODERINDEX_POLARITY_INVERTED) || \
  1090. ((__POLARITY__) == TIM_ENCODERINDEX_POLARITY_NONINVERTED))
  1091. #define IS_TIM_ENCODERINDEX_PRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_ENCODERINDEX_PRESCALER_DIV1) || \
  1092. ((__PRESCALER__) == TIM_ENCODERINDEX_PRESCALER_DIV2) || \
  1093. ((__PRESCALER__) == TIM_ENCODERINDEX_PRESCALER_DIV4) || \
  1094. ((__PRESCALER__) == TIM_ENCODERINDEX_PRESCALER_DIV8))
  1095. #define IS_TIM_ENCODERINDEX_FILTER(__FILTER__) ((__FILTER__) <= 0xFUL)
  1096. #define IS_TIM_ENCODERINDEX_POSITION(__POSITION__) (((__POSITION__) == TIM_ENCODERINDEX_POSITION_00) || \
  1097. ((__POSITION__) == TIM_ENCODERINDEX_POSITION_01) || \
  1098. ((__POSITION__) == TIM_ENCODERINDEX_POSITION_10) || \
  1099. ((__POSITION__) == TIM_ENCODERINDEX_POSITION_11) || \
  1100. ((__POSITION__) == TIM_ENCODERINDEX_POSITION_0) || \
  1101. ((__POSITION__) == TIM_ENCODERINDEX_POSITION_1))
  1102. #define IS_TIM_ENCODERINDEX_DIRECTION(__DIRECTION__) (((__DIRECTION__) == TIM_ENCODERINDEX_DIRECTION_UP_DOWN) || \
  1103. ((__DIRECTION__) == TIM_ENCODERINDEX_DIRECTION_UP) || \
  1104. ((__DIRECTION__) == TIM_ENCODERINDEX_DIRECTION_DOWN))
  1105. #define IS_TIM_ENCODERINDEX_BLANKING(__BLANKING__) (((__BLANKING__) == TIM_ENCODERINDEX_BLANKING_DISABLE) || \
  1106. ((__BLANKING__) == TIM_ENCODERINDEX_BLANKING_TI3) || \
  1107. ((__BLANKING__) == TIM_ENCODERINDEX_BLANKING_TI4))
  1108. /**
  1109. * @}
  1110. */
  1111. /* End of private macro ------------------------------------------------------*/
  1112. /* Exported functions --------------------------------------------------------*/
  1113. /** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions
  1114. * @{
  1115. */
  1116. /** @addtogroup TIMEx_Exported_Functions_Group1 Extended Timer Hall Sensor functions
  1117. * @brief Timer Hall Sensor functions
  1118. * @{
  1119. */
  1120. /* Timer Hall Sensor functions **********************************************/
  1121. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, const TIM_HallSensor_InitTypeDef *sConfig);
  1122. HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim);
  1123. void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim);
  1124. void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim);
  1125. /* Blocking mode: Polling */
  1126. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim);
  1127. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim);
  1128. /* Non-Blocking mode: Interrupt */
  1129. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim);
  1130. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim);
  1131. /* Non-Blocking mode: DMA */
  1132. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
  1133. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim);
  1134. /**
  1135. * @}
  1136. */
  1137. /** @addtogroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions
  1138. * @brief Timer Complementary Output Compare functions
  1139. * @{
  1140. */
  1141. /* Timer Complementary Output Compare functions *****************************/
  1142. /* Blocking mode: Polling */
  1143. HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  1144. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  1145. /* Non-Blocking mode: Interrupt */
  1146. HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1147. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1148. /* Non-Blocking mode: DMA */
  1149. HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData,
  1150. uint16_t Length);
  1151. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  1152. /**
  1153. * @}
  1154. */
  1155. /** @addtogroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions
  1156. * @brief Timer Complementary PWM functions
  1157. * @{
  1158. */
  1159. /* Timer Complementary PWM functions ****************************************/
  1160. /* Blocking mode: Polling */
  1161. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  1162. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  1163. /* Non-Blocking mode: Interrupt */
  1164. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1165. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1166. /* Non-Blocking mode: DMA */
  1167. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData,
  1168. uint16_t Length);
  1169. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  1170. /**
  1171. * @}
  1172. */
  1173. /** @addtogroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions
  1174. * @brief Timer Complementary One Pulse functions
  1175. * @{
  1176. */
  1177. /* Timer Complementary One Pulse functions **********************************/
  1178. /* Blocking mode: Polling */
  1179. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  1180. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  1181. /* Non-Blocking mode: Interrupt */
  1182. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  1183. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  1184. /**
  1185. * @}
  1186. */
  1187. /** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions
  1188. * @brief Peripheral Control functions
  1189. * @{
  1190. */
  1191. /* Extended Control functions ************************************************/
  1192. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
  1193. uint32_t CommutationSource);
  1194. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
  1195. uint32_t CommutationSource);
  1196. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
  1197. uint32_t CommutationSource);
  1198. HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim,
  1199. const TIM_MasterConfigTypeDef *sMasterConfig);
  1200. HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim,
  1201. const TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig);
  1202. HAL_StatusTypeDef HAL_TIMEx_ConfigBreakInput(TIM_HandleTypeDef *htim, uint32_t BreakInput,
  1203. const TIMEx_BreakInputConfigTypeDef *sBreakInputConfig);
  1204. HAL_StatusTypeDef HAL_TIMEx_GroupChannel5(TIM_HandleTypeDef *htim, uint32_t Channels);
  1205. HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap);
  1206. HAL_StatusTypeDef HAL_TIMEx_TISelection(TIM_HandleTypeDef *htim, uint32_t TISelection, uint32_t Channel);
  1207. HAL_StatusTypeDef HAL_TIMEx_DisarmBreakInput(TIM_HandleTypeDef *htim, uint32_t BreakInput);
  1208. HAL_StatusTypeDef HAL_TIMEx_ReArmBreakInput(const TIM_HandleTypeDef *htim, uint32_t BreakInput);
  1209. HAL_StatusTypeDef HAL_TIMEx_DitheringEnable(TIM_HandleTypeDef *htim);
  1210. HAL_StatusTypeDef HAL_TIMEx_DitheringDisable(TIM_HandleTypeDef *htim);
  1211. HAL_StatusTypeDef HAL_TIMEx_OC_ConfigPulseOnCompare(TIM_HandleTypeDef *htim, uint32_t PulseWidthPrescaler,
  1212. uint32_t PulseWidth);
  1213. HAL_StatusTypeDef HAL_TIMEx_ConfigSlaveModePreload(TIM_HandleTypeDef *htim, uint32_t Source);
  1214. HAL_StatusTypeDef HAL_TIMEx_EnableSlaveModePreload(TIM_HandleTypeDef *htim);
  1215. HAL_StatusTypeDef HAL_TIMEx_DisableSlaveModePreload(TIM_HandleTypeDef *htim);
  1216. HAL_StatusTypeDef HAL_TIMEx_EnableDeadTimePreload(TIM_HandleTypeDef *htim);
  1217. HAL_StatusTypeDef HAL_TIMEx_DisableDeadTimePreload(TIM_HandleTypeDef *htim);
  1218. HAL_StatusTypeDef HAL_TIMEx_ConfigDeadTime(TIM_HandleTypeDef *htim, uint32_t Deadtime);
  1219. HAL_StatusTypeDef HAL_TIMEx_ConfigAsymmetricalDeadTime(TIM_HandleTypeDef *htim, uint32_t FallingDeadtime);
  1220. HAL_StatusTypeDef HAL_TIMEx_EnableAsymmetricalDeadTime(TIM_HandleTypeDef *htim);
  1221. HAL_StatusTypeDef HAL_TIMEx_DisableAsymmetricalDeadTime(TIM_HandleTypeDef *htim);
  1222. HAL_StatusTypeDef HAL_TIMEx_ConfigEncoderIndex(TIM_HandleTypeDef *htim,
  1223. TIMEx_EncoderIndexConfigTypeDef *sEncoderIndexConfig);
  1224. HAL_StatusTypeDef HAL_TIMEx_EnableEncoderIndex(TIM_HandleTypeDef *htim);
  1225. HAL_StatusTypeDef HAL_TIMEx_DisableEncoderIndex(TIM_HandleTypeDef *htim);
  1226. HAL_StatusTypeDef HAL_TIMEx_EnableEncoderFirstIndex(TIM_HandleTypeDef *htim);
  1227. HAL_StatusTypeDef HAL_TIMEx_DisableEncoderFirstIndex(TIM_HandleTypeDef *htim);
  1228. /**
  1229. * @}
  1230. */
  1231. /** @addtogroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions
  1232. * @brief Extended Callbacks functions
  1233. * @{
  1234. */
  1235. /* Extended Callback **********************************************************/
  1236. void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim);
  1237. void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim);
  1238. void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim);
  1239. void HAL_TIMEx_Break2Callback(TIM_HandleTypeDef *htim);
  1240. void HAL_TIMEx_EncoderIndexCallback(TIM_HandleTypeDef *htim);
  1241. void HAL_TIMEx_DirectionChangeCallback(TIM_HandleTypeDef *htim);
  1242. void HAL_TIMEx_IndexErrorCallback(TIM_HandleTypeDef *htim);
  1243. void HAL_TIMEx_TransitionErrorCallback(TIM_HandleTypeDef *htim);
  1244. /**
  1245. * @}
  1246. */
  1247. /** @addtogroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions
  1248. * @brief Extended Peripheral State functions
  1249. * @{
  1250. */
  1251. /* Extended Peripheral State functions ***************************************/
  1252. HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(const TIM_HandleTypeDef *htim);
  1253. HAL_TIM_ChannelStateTypeDef HAL_TIMEx_GetChannelNState(const TIM_HandleTypeDef *htim, uint32_t ChannelN);
  1254. /**
  1255. * @}
  1256. */
  1257. /**
  1258. * @}
  1259. */
  1260. /* End of exported functions -------------------------------------------------*/
  1261. /* Private functions----------------------------------------------------------*/
  1262. /** @addtogroup TIMEx_Private_Functions TIM Extended Private Functions
  1263. * @{
  1264. */
  1265. void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma);
  1266. void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma);
  1267. /**
  1268. * @}
  1269. */
  1270. /* End of private functions --------------------------------------------------*/
  1271. /**
  1272. * @}
  1273. */
  1274. /**
  1275. * @}
  1276. */
  1277. #ifdef __cplusplus
  1278. }
  1279. #endif
  1280. #endif /* STM32H5xx_HAL_TIM_EX_H */