stm32h7xx_hal_tim.h 93 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919
  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_tim.h
  4. * @author MCD Application Team
  5. * @version V1.0.0
  6. * @date 21-April-2017
  7. * @brief Header file of TIM HAL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32H7xx_HAL_TIM_H
  39. #define __STM32H7xx_HAL_TIM_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32h7xx_hal_def.h"
  45. /** @addtogroup STM32H7xx_HAL_Driver
  46. * @{
  47. */
  48. /** @addtogroup TIM
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /** @defgroup TIM_Exported_Types TIM Exported Types
  53. * @{
  54. */
  55. /**
  56. * @brief TIM Time base Configuration Structure definition
  57. */
  58. typedef struct
  59. {
  60. uint32_t Prescaler; /*!< Specifies the prescaler value used to divide the TIM clock.
  61. This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
  62. uint32_t CounterMode; /*!< Specifies the counter mode.
  63. This parameter can be a value of @ref TIM_Counter_Mode */
  64. uint32_t Period; /*!< Specifies the period value to be loaded into the active
  65. Auto-Reload Register at the next update event.
  66. This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */
  67. uint32_t ClockDivision; /*!< Specifies the clock division.
  68. This parameter can be a value of @ref TIM_ClockDivision */
  69. uint32_t RepetitionCounter; /*!< Specifies the repetition counter value. Each time the RCR down-counter
  70. reaches zero, an update event is generated and counting restarts
  71. from the RCR value (N).
  72. This means in PWM mode that (N+1) corresponds to:
  73. - the number of PWM periods in edge-aligned mode
  74. - the number of half PWM period in center-aligned mode
  75. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF.
  76. @note This parameter is valid only for TIM1 and TIM8. */
  77. uint32_t AutoReloadPreload; /*!< Specifies the auto-reload preload.
  78. This parameter can be a value of @ref TIM_AutoReloadPreload */
  79. } TIM_Base_InitTypeDef;
  80. /**
  81. * @brief TIM Output Compare Configuration Structure definition
  82. */
  83. typedef struct
  84. {
  85. uint32_t OCMode; /*!< Specifies the TIM mode.
  86. This parameter can be a value of @ref TIMEx_Output_Compare_and_PWM_modes */
  87. uint32_t Pulse; /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
  88. This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
  89. uint32_t OCPolarity; /*!< Specifies the output polarity.
  90. This parameter can be a value of @ref TIM_Output_Compare_Polarity */
  91. uint32_t OCNPolarity; /*!< Specifies the complementary output polarity.
  92. This parameter can be a value of @ref TIM_Output_Compare_N_Polarity
  93. @note This parameter is valid only for TIM1 and TIM8. */
  94. uint32_t OCFastMode; /*!< Specifies the Fast mode state.
  95. This parameter can be a value of @ref TIM_Output_Fast_State
  96. @note This parameter is valid only in PWM1 and PWM2 mode. */
  97. uint32_t OCIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
  98. This parameter can be a value of @ref TIM_Output_Compare_Idle_State
  99. @note This parameter is valid only for TIM1 and TIM8. */
  100. uint32_t OCNIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
  101. This parameter can be a value of @ref TIM_Output_Compare_N_Idle_State
  102. @note This parameter is valid only for TIM1 and TIM8. */
  103. } TIM_OC_InitTypeDef;
  104. /**
  105. * @brief TIM One Pulse Mode Configuration Structure definition
  106. */
  107. typedef struct
  108. {
  109. uint32_t OCMode; /*!< Specifies the TIM mode.
  110. This parameter can be a value of @ref TIMEx_Output_Compare_and_PWM_modes */
  111. uint32_t Pulse; /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
  112. This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
  113. uint32_t OCPolarity; /*!< Specifies the output polarity.
  114. This parameter can be a value of @ref TIM_Output_Compare_Polarity */
  115. uint32_t OCNPolarity; /*!< Specifies the complementary output polarity.
  116. This parameter can be a value of @ref TIM_Output_Compare_N_Polarity
  117. @note This parameter is valid only for TIM1 and TIM8. */
  118. uint32_t OCIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
  119. This parameter can be a value of @ref TIM_Output_Compare_Idle_State
  120. @note This parameter is valid only for TIM1 and TIM8. */
  121. uint32_t OCNIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
  122. This parameter can be a value of @ref TIM_Output_Compare_N_Idle_State
  123. @note This parameter is valid only for TIM1 and TIM8. */
  124. uint32_t ICPolarity; /*!< Specifies the active edge of the input signal.
  125. This parameter can be a value of @ref TIM_Input_Capture_Polarity */
  126. uint32_t ICSelection; /*!< Specifies the input.
  127. This parameter can be a value of @ref TIM_Input_Capture_Selection */
  128. uint32_t ICFilter; /*!< Specifies the input capture filter.
  129. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  130. } TIM_OnePulse_InitTypeDef;
  131. /**
  132. * @brief TIM Input Capture Configuration Structure definition
  133. */
  134. typedef struct
  135. {
  136. uint32_t ICPolarity; /*!< Specifies the active edge of the input signal.
  137. This parameter can be a value of @ref TIM_Input_Capture_Polarity */
  138. uint32_t ICSelection; /*!< Specifies the input.
  139. This parameter can be a value of @ref TIM_Input_Capture_Selection */
  140. uint32_t ICPrescaler; /*!< Specifies the Input Capture Prescaler.
  141. This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
  142. uint32_t ICFilter; /*!< Specifies the input capture filter.
  143. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  144. } TIM_IC_InitTypeDef;
  145. /**
  146. * @brief TIM Encoder Configuration Structure definition
  147. */
  148. typedef struct
  149. {
  150. uint32_t EncoderMode; /*!< Specifies the active edge of the input signal.
  151. This parameter can be a value of @ref TIM_Encoder_Mode */
  152. uint32_t IC1Polarity; /*!< Specifies the active edge of the input signal.
  153. This parameter can be a value of @ref TIM_Input_Capture_Polarity */
  154. uint32_t IC1Selection; /*!< Specifies the input.
  155. This parameter can be a value of @ref TIM_Input_Capture_Selection */
  156. uint32_t IC1Prescaler; /*!< Specifies the Input Capture Prescaler.
  157. This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
  158. uint32_t IC1Filter; /*!< Specifies the input capture filter.
  159. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  160. uint32_t IC2Polarity; /*!< Specifies the active edge of the input signal.
  161. This parameter can be a value of @ref TIM_Input_Capture_Polarity */
  162. uint32_t IC2Selection; /*!< Specifies the input.
  163. This parameter can be a value of @ref TIM_Input_Capture_Selection */
  164. uint32_t IC2Prescaler; /*!< Specifies the Input Capture Prescaler.
  165. This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
  166. uint32_t IC2Filter; /*!< Specifies the input capture filter.
  167. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  168. } TIM_Encoder_InitTypeDef;
  169. /**
  170. * @brief Clock Configuration Handle Structure definition
  171. */
  172. typedef struct
  173. {
  174. uint32_t ClockSource; /*!< TIM clock sources
  175. This parameter can be a value of @ref TIM_Clock_Source */
  176. uint32_t ClockPolarity; /*!< TIM clock polarity
  177. This parameter can be a value of @ref TIM_Clock_Polarity */
  178. uint32_t ClockPrescaler; /*!< TIM clock prescaler
  179. This parameter can be a value of @ref TIM_Clock_Prescaler */
  180. uint32_t ClockFilter; /*!< TIM clock filter
  181. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  182. }TIM_ClockConfigTypeDef;
  183. /**
  184. * @brief Clear Input Configuration Handle Structure definition
  185. */
  186. typedef struct
  187. {
  188. uint32_t ClearInputState; /*!< TIM clear Input state
  189. This parameter can be ENABLE or DISABLE */
  190. uint32_t ClearInputSource; /*!< TIM clear Input sources
  191. This parameter can be a value of @ref TIMEx_ClearInput_Source */
  192. uint32_t ClearInputPolarity; /*!< TIM Clear Input polarity
  193. This parameter can be a value of @ref TIM_ClearInput_Polarity */
  194. uint32_t ClearInputPrescaler; /*!< TIM Clear Input prescaler
  195. This parameter can be a value of @ref TIM_ClearInput_Prescaler */
  196. uint32_t ClearInputFilter; /*!< TIM Clear Input filter
  197. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  198. }TIM_ClearInputConfigTypeDef;
  199. /**
  200. * @brief TIM Master configuration Structure definition
  201. * @note Advanced timers provide TRGO2 internal line which is redirected
  202. * to the ADC
  203. */
  204. typedef struct {
  205. uint32_t MasterOutputTrigger; /*!< Trigger output (TRGO) selection
  206. This parameter can be a value of @ref TIM_Master_Mode_Selection */
  207. uint32_t MasterOutputTrigger2; /*!< Trigger output2 (TRGO2) selection
  208. This parameter can be a value of @ref TIM_Master_Mode_Selection_2 */
  209. uint32_t MasterSlaveMode; /*!< Master/slave mode selection
  210. This parameter can be a value of @ref TIM_Master_Slave_Mode */
  211. }TIM_MasterConfigTypeDef;
  212. /**
  213. * @brief TIM Slave configuration Structure definition
  214. */
  215. typedef struct {
  216. uint32_t SlaveMode; /*!< Slave mode selection
  217. This parameter can be a value of @ref TIM_Slave_Mode */
  218. uint32_t InputTrigger; /*!< Input Trigger source
  219. This parameter can be a value of @ref TIM_Trigger_Selection */
  220. uint32_t TriggerPolarity; /*!< Input Trigger polarity
  221. This parameter can be a value of @ref TIM_Trigger_Polarity */
  222. uint32_t TriggerPrescaler; /*!< Input trigger prescaler
  223. This parameter can be a value of @ref TIM_Trigger_Prescaler */
  224. uint32_t TriggerFilter; /*!< Input trigger filter
  225. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  226. }TIM_SlaveConfigTypeDef;
  227. /**
  228. * @brief TIM Break input(s) and Dead time configuration Structure definition
  229. * @note 2 break inputs can be configured (BKIN and BKIN2) with configurable
  230. * filter and polarity.
  231. */
  232. typedef struct
  233. {
  234. uint32_t OffStateRunMode; /*!< TIM off state in run mode
  235. This parameter can be a value of @ref TIM_OSSR_Off_State_Selection_for_Run_mode_state */
  236. uint32_t OffStateIDLEMode; /*!< TIM off state in IDLE mode
  237. This parameter can be a value of @ref TIM_OSSI_Off_State_Selection_for_Idle_mode_state */
  238. uint32_t LockLevel; /*!< TIM Lock level
  239. This parameter can be a value of @ref TIM_Lock_level */
  240. uint32_t DeadTime; /*!< TIM dead Time
  241. This parameter can be a number between Min_Data = 0x00 and Max_Data = 0xFF */
  242. uint32_t BreakState; /*!< TIM Break State
  243. This parameter can be a value of @ref TIM_Break_Input_enable_disable */
  244. uint32_t BreakPolarity; /*!< TIM Break input polarity
  245. This parameter can be a value of @ref TIM_Break_Polarity */
  246. uint32_t BreakFilter; /*!< Specifies the break input filter.
  247. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  248. uint32_t Break2State; /*!< TIM Break2 State
  249. This parameter can be a value of @ref TIMEx_Break2_Input_enable_disable */
  250. uint32_t Break2Polarity; /*!< TIM Break2 input polarity
  251. This parameter can be a value of @ref TIMEx_Break2_Polarity */
  252. uint32_t Break2Filter; /*!< TIM break2 input filter.
  253. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  254. uint32_t AutomaticOutput; /*!< TIM Automatic Output Enable state
  255. This parameter can be a value of @ref TIM_AOE_Bit_Set_Reset */
  256. } TIM_BreakDeadTimeConfigTypeDef;
  257. /**
  258. * @brief HAL State structures definition
  259. */
  260. typedef enum
  261. {
  262. HAL_TIM_STATE_RESET = 0x00U, /*!< Peripheral not yet initialized or disabled */
  263. HAL_TIM_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
  264. HAL_TIM_STATE_BUSY = 0x02U, /*!< An internal process is ongoing */
  265. HAL_TIM_STATE_TIMEOUT = 0x03U, /*!< Timeout state */
  266. HAL_TIM_STATE_ERROR = 0x04U /*!< Reception process is ongoing */
  267. }HAL_TIM_StateTypeDef;
  268. /**
  269. * @brief HAL Active channel structures definition
  270. */
  271. typedef enum
  272. {
  273. HAL_TIM_ACTIVE_CHANNEL_1 = 0x01U, /*!< The active channel is 1 */
  274. HAL_TIM_ACTIVE_CHANNEL_2 = 0x02U, /*!< The active channel is 2 */
  275. HAL_TIM_ACTIVE_CHANNEL_3 = 0x04U, /*!< The active channel is 3 */
  276. HAL_TIM_ACTIVE_CHANNEL_4 = 0x08U, /*!< The active channel is 4 */
  277. HAL_TIM_ACTIVE_CHANNEL_5 = 0x10U, /*!< The active channel is 5 */
  278. HAL_TIM_ACTIVE_CHANNEL_6 = 0x20U, /*!< The active channel is 6 */
  279. HAL_TIM_ACTIVE_CHANNEL_CLEARED = 0x00U /*!< All active channels cleared */
  280. }HAL_TIM_ActiveChannel;
  281. /**
  282. * @brief TIM Time Base Handle Structure definition
  283. */
  284. typedef struct
  285. {
  286. TIM_TypeDef *Instance; /*!< Register base address */
  287. TIM_Base_InitTypeDef Init; /*!< TIM Time Base required parameters */
  288. HAL_TIM_ActiveChannel Channel; /*!< Active channel */
  289. DMA_HandleTypeDef *hdma[7]; /*!< DMA Handlers array This array is accessed by a @ref DMA_Handle_index */
  290. HAL_LockTypeDef Lock; /*!< Locking object */
  291. __IO HAL_TIM_StateTypeDef State; /*!< TIM operation state */
  292. }TIM_HandleTypeDef;
  293. /**
  294. * @}
  295. */
  296. /* End of exported types -----------------------------------------------------*/
  297. /* Exported constants --------------------------------------------------------*/
  298. /** @defgroup TIM_Exported_Constants TIM Exported Constants
  299. * @{
  300. */
  301. /** @defgroup TIM_Event_Source TIM Extended Event Source
  302. * @{
  303. */
  304. #define TIM_EVENTSOURCE_UPDATE TIM_EGR_UG /*!< Reinitialize the counter and generates an update of the registers */
  305. #define TIM_EVENTSOURCE_CC1 TIM_EGR_CC1G /*!< A capture/compare event is generated on channel 1 */
  306. #define TIM_EVENTSOURCE_CC2 TIM_EGR_CC2G /*!< A capture/compare event is generated on channel 2 */
  307. #define TIM_EVENTSOURCE_CC3 TIM_EGR_CC3G /*!< A capture/compare event is generated on channel 3 */
  308. #define TIM_EVENTSOURCE_CC4 TIM_EGR_CC4G /*!< A capture/compare event is generated on channel 4 */
  309. #define TIM_EVENTSOURCE_COM TIM_EGR_COMG /*!< A commutation event is generated */
  310. #define TIM_EVENTSOURCE_TRIGGER TIM_EGR_TG /*!< A trigger event is generated */
  311. #define TIM_EVENTSOURCE_BREAK TIM_EGR_BG /*!< A break event is generated */
  312. #define TIM_EVENTSOURCE_BREAK2 TIM_EGR_B2G /*!< A break 2 event is generated */
  313. /**
  314. * @}
  315. */
  316. /** @defgroup TIM_Input_Channel_Polarity TIM Input Channel polarity
  317. * @{
  318. */
  319. #define TIM_INPUTCHANNELPOLARITY_RISING ((uint32_t)0x00000000U) /*!< Polarity for TIx source */
  320. #define TIM_INPUTCHANNELPOLARITY_FALLING (TIM_CCER_CC1P) /*!< Polarity for TIx source */
  321. #define TIM_INPUTCHANNELPOLARITY_BOTHEDGE (TIM_CCER_CC1P | TIM_CCER_CC1NP) /*!< Polarity for TIx source */
  322. /**
  323. * @}
  324. */
  325. /** @defgroup TIM_ETR_Polarity TIM ETR Polarity
  326. * @{
  327. */
  328. #define TIM_ETRPOLARITY_INVERTED (TIM_SMCR_ETP) /*!< Polarity for ETR source */
  329. #define TIM_ETRPOLARITY_NONINVERTED ((uint32_t)0x0000U) /*!< Polarity for ETR source */
  330. /**
  331. * @}
  332. */
  333. /** @defgroup TIM_ETR_Prescaler TIM ETR Prescaler
  334. * @{
  335. */
  336. #define TIM_ETRPRESCALER_DIV1 ((uint32_t)0x0000U) /*!< No prescaler is used */
  337. #define TIM_ETRPRESCALER_DIV2 (TIM_SMCR_ETPS_0) /*!< ETR input source is divided by 2 */
  338. #define TIM_ETRPRESCALER_DIV4 (TIM_SMCR_ETPS_1) /*!< ETR input source is divided by 4 */
  339. #define TIM_ETRPRESCALER_DIV8 (TIM_SMCR_ETPS) /*!< ETR input source is divided by 8 */
  340. /**
  341. * @}
  342. */
  343. /** @defgroup TIM_Counter_Mode TIM Counter Mode
  344. * @{
  345. */
  346. #define TIM_COUNTERMODE_UP ((uint32_t)0x0000U) /*!< Up counting mode */
  347. #define TIM_COUNTERMODE_DOWN TIM_CR1_DIR /*!< Down counting mode */
  348. #define TIM_COUNTERMODE_CENTERALIGNED1 TIM_CR1_CMS_0 /*!< Center-aligned counting mode 1 */
  349. #define TIM_COUNTERMODE_CENTERALIGNED2 TIM_CR1_CMS_1 /*!< Center-aligned counting mode 2 */
  350. #define TIM_COUNTERMODE_CENTERALIGNED3 TIM_CR1_CMS /*!< Center-aligned counting mode 3 */
  351. /**
  352. * @}
  353. */
  354. /** @defgroup TIM_ClockDivision TIM Clock Division
  355. * @{
  356. */
  357. #define TIM_CLOCKDIVISION_DIV1 ((uint32_t)0x0000U) /*!< Clock Division DIV1 */
  358. #define TIM_CLOCKDIVISION_DIV2 (TIM_CR1_CKD_0) /*!< Clock Division DIV2 */
  359. #define TIM_CLOCKDIVISION_DIV4 (TIM_CR1_CKD_1) /*!< Clock Division DIV4 */
  360. /**
  361. * @}
  362. */
  363. /** @defgroup TIM_Output_Compare_State TIM Output Compare State
  364. * @{
  365. */
  366. #define TIM_OUTPUTSTATE_DISABLE ((uint32_t)0x0000U) /*!< Output State disabled */
  367. #define TIM_OUTPUTSTATE_ENABLE (TIM_CCER_CC1E) /*!< Output State enabled */
  368. /**
  369. * @}
  370. */
  371. /** @defgroup TIM_AutoReloadPreload TIM Auto-Reload Preload
  372. * @{
  373. */
  374. #define TIM_AUTORELOAD_PRELOAD_DISABLE ((uint32_t)0x0000U) /*!< TIMx_ARR register is not buffered */
  375. #define TIM_AUTORELOAD_PRELOAD_ENABLE (TIM_CR1_ARPE) /*!< TIMx_ARR register is buffered */
  376. /**
  377. * @}
  378. */
  379. /** @defgroup TIM_Output_Fast_State TIM Output Fast State
  380. * @{
  381. */
  382. #define TIM_OCFAST_DISABLE ((uint32_t)0x0000U)
  383. #define TIM_OCFAST_ENABLE (TIM_CCMR1_OC1FE)
  384. /**
  385. * @}
  386. */
  387. /** @defgroup TIM_Output_Compare_Polarity TIM Output Compare Polarity
  388. * @{
  389. */
  390. #define TIM_OCPOLARITY_HIGH ((uint32_t)0x0000U)
  391. #define TIM_OCPOLARITY_LOW (TIM_CCER_CC1P)
  392. /**
  393. * @}
  394. */
  395. /** @defgroup TIM_Output_Compare_N_Polarity TIM Complementary Output Compare Polarity
  396. * @{
  397. */
  398. #define TIM_OCNPOLARITY_HIGH ((uint32_t)0x0000U)
  399. #define TIM_OCNPOLARITY_LOW (TIM_CCER_CC1NP)
  400. /**
  401. * @}
  402. */
  403. /** @defgroup TIM_Output_Compare_Idle_State TIM Output Compare Idle State
  404. * @{
  405. */
  406. #define TIM_OCIDLESTATE_SET (TIM_CR2_OIS1)
  407. #define TIM_OCIDLESTATE_RESET ((uint32_t)0x0000U)
  408. /**
  409. * @}
  410. */
  411. /** @defgroup TIM_Output_Compare_N_Idle_State TIM Complementary Output Compare Idle State
  412. * @{
  413. */
  414. #define TIM_OCNIDLESTATE_SET (TIM_CR2_OIS1N)
  415. #define TIM_OCNIDLESTATE_RESET ((uint32_t)0x0000U)
  416. /**
  417. * @}
  418. */
  419. /** @defgroup TIM_Input_Capture_Polarity TIM Input Capture Polarity
  420. * @{
  421. */
  422. #define TIM_ICPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING
  423. #define TIM_ICPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING
  424. #define TIM_ICPOLARITY_BOTHEDGE TIM_INPUTCHANNELPOLARITY_BOTHEDGE
  425. /**
  426. * @}
  427. */
  428. /** @defgroup TIM_Input_Capture_Selection TIM Input Capture Selection
  429. * @{
  430. */
  431. #define TIM_ICSELECTION_DIRECTTI (TIM_CCMR1_CC1S_0) /*!< TIM Input 1, 2, 3 or 4 is selected to be
  432. connected to IC1, IC2, IC3 or IC4, respectively */
  433. #define TIM_ICSELECTION_INDIRECTTI (TIM_CCMR1_CC1S_1) /*!< TIM Input 1, 2, 3 or 4 is selected to be
  434. connected to IC2, IC1, IC4 or IC3, respectively */
  435. #define TIM_ICSELECTION_TRC (TIM_CCMR1_CC1S) /*!< TIM Input 1, 2, 3 or 4 is selected to be connected to TRC */
  436. /**
  437. * @}
  438. */
  439. /** @defgroup TIM_Input_Capture_Prescaler TIM Input Capture Prescaler
  440. * @{
  441. */
  442. #define TIM_ICPSC_DIV1 ((uint32_t)0x0000U) /*!< Capture performed each time an edge is detected on the capture input */
  443. #define TIM_ICPSC_DIV2 (TIM_CCMR1_IC1PSC_0) /*!< Capture performed once every 2 events */
  444. #define TIM_ICPSC_DIV4 (TIM_CCMR1_IC1PSC_1) /*!< Capture performed once every 4 events */
  445. #define TIM_ICPSC_DIV8 (TIM_CCMR1_IC1PSC) /*!< Capture performed once every 8 events */
  446. /**
  447. * @}
  448. */
  449. /** @defgroup TIM_One_Pulse_Mode TIM One Pulse Mode
  450. * @{
  451. */
  452. #define TIM_OPMODE_SINGLE (TIM_CR1_OPM)
  453. #define TIM_OPMODE_REPETITIVE ((uint32_t)0x0000U)
  454. /**
  455. * @}
  456. */
  457. /** @defgroup TIM_Encoder_Mode TIM Encoder Mode
  458. * @{
  459. */
  460. #define TIM_ENCODERMODE_TI1 (TIM_SMCR_SMS_0)
  461. #define TIM_ENCODERMODE_TI2 (TIM_SMCR_SMS_1)
  462. #define TIM_ENCODERMODE_TI12 (TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0)
  463. /**
  464. * @}
  465. */
  466. /** @defgroup TIM_Interrupt_definition TIM interrupt Definition
  467. * @{
  468. */
  469. #define TIM_IT_UPDATE (TIM_DIER_UIE)
  470. #define TIM_IT_CC1 (TIM_DIER_CC1IE)
  471. #define TIM_IT_CC2 (TIM_DIER_CC2IE)
  472. #define TIM_IT_CC3 (TIM_DIER_CC3IE)
  473. #define TIM_IT_CC4 (TIM_DIER_CC4IE)
  474. #define TIM_IT_COM (TIM_DIER_COMIE)
  475. #define TIM_IT_TRIGGER (TIM_DIER_TIE)
  476. #define TIM_IT_BREAK (TIM_DIER_BIE)
  477. /**
  478. * @}
  479. */
  480. /** @defgroup TIM_Commutation_Source TIM Commutation Source
  481. * @{
  482. */
  483. #define TIM_COMMUTATION_TRGI (TIM_CR2_CCUS)
  484. #define TIM_COMMUTATION_SOFTWARE ((uint32_t)0x0000U)
  485. /**
  486. * @}
  487. */
  488. /** @defgroup TIM_DMA_sources TIM DMA Sources
  489. * @{
  490. */
  491. #define TIM_DMA_UPDATE (TIM_DIER_UDE)
  492. #define TIM_DMA_CC1 (TIM_DIER_CC1DE)
  493. #define TIM_DMA_CC2 (TIM_DIER_CC2DE)
  494. #define TIM_DMA_CC3 (TIM_DIER_CC3DE)
  495. #define TIM_DMA_CC4 (TIM_DIER_CC4DE)
  496. #define TIM_DMA_COM (TIM_DIER_COMDE)
  497. #define TIM_DMA_TRIGGER (TIM_DIER_TDE)
  498. /**
  499. * @}
  500. */
  501. /** @defgroup TIM_Flag_definition TIM Flag Definition
  502. * @{
  503. */
  504. #define TIM_FLAG_UPDATE (TIM_SR_UIF)
  505. #define TIM_FLAG_CC1 (TIM_SR_CC1IF)
  506. #define TIM_FLAG_CC2 (TIM_SR_CC2IF)
  507. #define TIM_FLAG_CC3 (TIM_SR_CC3IF)
  508. #define TIM_FLAG_CC4 (TIM_SR_CC4IF)
  509. #define TIM_FLAG_CC5 (TIM_SR_CC5IF)
  510. #define TIM_FLAG_CC6 (TIM_SR_CC6IF)
  511. #define TIM_FLAG_COM (TIM_SR_COMIF)
  512. #define TIM_FLAG_TRIGGER (TIM_SR_TIF)
  513. #define TIM_FLAG_BREAK (TIM_SR_BIF)
  514. #define TIM_FLAG_BREAK2 (TIM_SR_B2IF)
  515. #define TIM_FLAG_SYSTEM_BREAK (TIM_SR_SBIF)
  516. #define TIM_FLAG_CC1OF (TIM_SR_CC1OF)
  517. #define TIM_FLAG_CC2OF (TIM_SR_CC2OF)
  518. #define TIM_FLAG_CC3OF (TIM_SR_CC3OF)
  519. #define TIM_FLAG_CC4OF (TIM_SR_CC4OF)
  520. /**
  521. * @}
  522. */
  523. /** @defgroup TIM_Clock_Source TIM Clock Source
  524. * @{
  525. */
  526. #define TIM_CLOCKSOURCE_ETRMODE2 (TIM_SMCR_ETPS_1)
  527. #define TIM_CLOCKSOURCE_INTERNAL (TIM_SMCR_ETPS_0)
  528. #define TIM_CLOCKSOURCE_ITR0 ((uint32_t)0x0000U)
  529. #define TIM_CLOCKSOURCE_ITR1 (TIM_SMCR_TS_0)
  530. #define TIM_CLOCKSOURCE_ITR2 (TIM_SMCR_TS_1)
  531. #define TIM_CLOCKSOURCE_ITR3 (TIM_SMCR_TS_0 | TIM_SMCR_TS_1)
  532. #define TIM_CLOCKSOURCE_TI1ED (TIM_SMCR_TS_2)
  533. #define TIM_CLOCKSOURCE_TI1 (TIM_SMCR_TS_0 | TIM_SMCR_TS_2)
  534. #define TIM_CLOCKSOURCE_TI2 (TIM_SMCR_TS_1 | TIM_SMCR_TS_2)
  535. #define TIM_CLOCKSOURCE_ETRMODE1 (TIM_SMCR_TS_0 | TIM_SMCR_TS_1 | TIM_SMCR_TS_2)
  536. /**
  537. * @}
  538. */
  539. /** @defgroup TIM_Clock_Polarity TIM Clock Polarity
  540. * @{
  541. */
  542. #define TIM_CLOCKPOLARITY_INVERTED TIM_ETRPOLARITY_INVERTED /*!< Polarity for ETRx clock sources */
  543. #define TIM_CLOCKPOLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED /*!< Polarity for ETRx clock sources */
  544. #define TIM_CLOCKPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING /*!< Polarity for TIx clock sources */
  545. #define TIM_CLOCKPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING /*!< Polarity for TIx clock sources */
  546. #define TIM_CLOCKPOLARITY_BOTHEDGE TIM_INPUTCHANNELPOLARITY_BOTHEDGE /*!< Polarity for TIx clock sources */
  547. /**
  548. * @}
  549. */
  550. /** @defgroup TIM_Clock_Prescaler TIM Clock Prescaler
  551. * @{
  552. */
  553. #define TIM_CLOCKPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1 /*!< No prescaler is used */
  554. #define TIM_CLOCKPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2 /*!< Prescaler for External ETR Clock: Capture performed once every 2 events. */
  555. #define TIM_CLOCKPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4 /*!< Prescaler for External ETR Clock: Capture performed once every 4 events. */
  556. #define TIM_CLOCKPRESCALER_DIV8 TIM_ETRPRESCALER_DIV8 /*!< Prescaler for External ETR Clock: Capture performed once every 8 events. */
  557. /**
  558. * @}
  559. */
  560. /** @defgroup TIM_ClearInput_Polarity TIM Clear Input Polarity
  561. * @{
  562. */
  563. #define TIM_CLEARINPUTPOLARITY_INVERTED TIM_ETRPOLARITY_INVERTED /*!< Polarity for ETRx pin */
  564. #define TIM_CLEARINPUTPOLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED /*!< Polarity for ETRx pin */
  565. /**
  566. * @}
  567. */
  568. /** @defgroup TIM_ClearInput_Prescaler TIM Clear Input Prescaler
  569. * @{
  570. */
  571. #define TIM_CLEARINPUTPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1 /*!< No prescaler is used */
  572. #define TIM_CLEARINPUTPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2 /*!< Prescaler for External ETR pin: Capture performed once every 2 events. */
  573. #define TIM_CLEARINPUTPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4 /*!< Prescaler for External ETR pin: Capture performed once every 4 events. */
  574. #define TIM_CLEARINPUTPRESCALER_DIV8 TIM_ETRPRESCALER_DIV8 /*!< Prescaler for External ETR pin: Capture performed once every 8 events. */
  575. /**
  576. * @}
  577. */
  578. /** @defgroup TIM_OSSR_Off_State_Selection_for_Run_mode_state TIM Off-state Selection for Run Mode
  579. * @{
  580. */
  581. #define TIM_OSSR_ENABLE (TIM_BDTR_OSSR)
  582. #define TIM_OSSR_DISABLE ((uint32_t)0x0000U)
  583. /**
  584. * @}
  585. */
  586. /** @defgroup TIM_OSSI_Off_State_Selection_for_Idle_mode_state TIM Off-state Selection for Idle Mode
  587. * @{
  588. */
  589. #define TIM_OSSI_ENABLE (TIM_BDTR_OSSI)
  590. #define TIM_OSSI_DISABLE ((uint32_t)0x0000U)
  591. /**
  592. * @}
  593. */
  594. /** @defgroup TIM_Lock_level TIM Lock Configuration
  595. * @{
  596. */
  597. #define TIM_LOCKLEVEL_OFF ((uint32_t)0x0000U)
  598. #define TIM_LOCKLEVEL_1 (TIM_BDTR_LOCK_0)
  599. #define TIM_LOCKLEVEL_2 (TIM_BDTR_LOCK_1)
  600. #define TIM_LOCKLEVEL_3 (TIM_BDTR_LOCK)
  601. /**
  602. * @}
  603. */
  604. /** @defgroup TIM_Break_Input_enable_disable TIM Break Input Enable
  605. * @{
  606. */
  607. #define TIM_BREAK_ENABLE (TIM_BDTR_BKE)
  608. #define TIM_BREAK_DISABLE ((uint32_t)0x0000U)
  609. /**
  610. * @}
  611. */
  612. /** @defgroup TIM_Break_Polarity TIM Break Input Polarity
  613. * @{
  614. */
  615. #define TIM_BREAKPOLARITY_LOW ((uint32_t)0x0000U)
  616. #define TIM_BREAKPOLARITY_HIGH (TIM_BDTR_BKP)
  617. /**
  618. * @}
  619. */
  620. /** @defgroup TIM_AOE_Bit_Set_Reset TIM Automatic Output Enable
  621. * @{
  622. */
  623. #define TIM_AUTOMATICOUTPUT_ENABLE (TIM_BDTR_AOE)
  624. #define TIM_AUTOMATICOUTPUT_DISABLE ((uint32_t)0x0000U)
  625. /**
  626. * @}
  627. */
  628. /** @defgroup TIM_Master_Mode_Selection TIM Master Mode Selection
  629. * @{
  630. */
  631. #define TIM_TRGO_RESET ((uint32_t)0x0000U)
  632. #define TIM_TRGO_ENABLE (TIM_CR2_MMS_0)
  633. #define TIM_TRGO_UPDATE (TIM_CR2_MMS_1)
  634. #define TIM_TRGO_OC1 ((TIM_CR2_MMS_1 | TIM_CR2_MMS_0))
  635. #define TIM_TRGO_OC1REF (TIM_CR2_MMS_2)
  636. #define TIM_TRGO_OC2REF ((TIM_CR2_MMS_2 | TIM_CR2_MMS_0))
  637. #define TIM_TRGO_OC3REF ((TIM_CR2_MMS_2 | TIM_CR2_MMS_1))
  638. #define TIM_TRGO_OC4REF ((TIM_CR2_MMS_2 | TIM_CR2_MMS_1 | TIM_CR2_MMS_0))
  639. /**
  640. * @}
  641. */
  642. /** @defgroup TIM_Master_Mode_Selection_2 TIM Master Mode Selection 2 (TRGO2)
  643. * @{
  644. */
  645. #define TIM_TRGO2_RESET ((uint32_t)0x00000000U)
  646. #define TIM_TRGO2_ENABLE ((uint32_t)(TIM_CR2_MMS2_0))
  647. #define TIM_TRGO2_UPDATE ((uint32_t)(TIM_CR2_MMS2_1))
  648. #define TIM_TRGO2_OC1 ((uint32_t)(TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0))
  649. #define TIM_TRGO2_OC1REF ((uint32_t)(TIM_CR2_MMS2_2))
  650. #define TIM_TRGO2_OC2REF ((uint32_t)(TIM_CR2_MMS2_2 | TIM_CR2_MMS2_0))
  651. #define TIM_TRGO2_OC3REF ((uint32_t)(TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1))
  652. #define TIM_TRGO2_OC4REF ((uint32_t)(TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0))
  653. #define TIM_TRGO2_OC5REF ((uint32_t)(TIM_CR2_MMS2_3))
  654. #define TIM_TRGO2_OC6REF ((uint32_t)(TIM_CR2_MMS2_3 | TIM_CR2_MMS2_0))
  655. #define TIM_TRGO2_OC4REF_RISINGFALLING ((uint32_t)(TIM_CR2_MMS2_3 | TIM_CR2_MMS2_1))
  656. #define TIM_TRGO2_OC6REF_RISINGFALLING ((uint32_t)(TIM_CR2_MMS2_3 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0))
  657. #define TIM_TRGO2_OC4REF_RISING_OC6REF_RISING ((uint32_t)(TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2))
  658. #define TIM_TRGO2_OC4REF_RISING_OC6REF_FALLING ((uint32_t)(TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2 | TIM_CR2_MMS2_0))
  659. #define TIM_TRGO2_OC5REF_RISING_OC6REF_RISING ((uint32_t)(TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2 |TIM_CR2_MMS2_1))
  660. #define TIM_TRGO2_OC5REF_RISING_OC6REF_FALLING ((uint32_t)(TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0))
  661. /**
  662. * @}
  663. */
  664. /** @defgroup TIM_Master_Slave_Mode TIM Master/Slave Mode
  665. * @{
  666. */
  667. #define TIM_MASTERSLAVEMODE_ENABLE ((uint32_t)0x0080U)
  668. #define TIM_MASTERSLAVEMODE_DISABLE ((uint32_t)0x0000U)
  669. /**
  670. * @}
  671. */
  672. /** @defgroup TIM_Slave_Mode TIM Slave mode
  673. * @{
  674. */
  675. #define TIM_SLAVEMODE_DISABLE ((uint32_t)0x0000U)
  676. #define TIM_SLAVEMODE_RESET ((uint32_t)(TIM_SMCR_SMS_2))
  677. #define TIM_SLAVEMODE_GATED ((uint32_t)(TIM_SMCR_SMS_2 | TIM_SMCR_SMS_0))
  678. #define TIM_SLAVEMODE_TRIGGER ((uint32_t)(TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1))
  679. #define TIM_SLAVEMODE_EXTERNAL1 ((uint32_t)(TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0))
  680. #define TIM_SLAVEMODE_COMBINED_RESETTRIGGER ((uint32_t)(TIM_SMCR_SMS_3))
  681. /**
  682. * @}
  683. */
  684. /** @defgroup TIM_Trigger_Selection TIM Trigger Selection
  685. * @{
  686. */
  687. #define TIM_TS_ITR0 ((uint32_t)0x0000U)
  688. #define TIM_TS_ITR1 ((uint32_t)0x0010U)
  689. #define TIM_TS_ITR2 ((uint32_t)0x0020U)
  690. #define TIM_TS_ITR3 ((uint32_t)0x0030U)
  691. #define TIM_TS_TI1F_ED ((uint32_t)0x0040U)
  692. #define TIM_TS_TI1FP1 ((uint32_t)0x0050U)
  693. #define TIM_TS_TI2FP2 ((uint32_t)0x0060U)
  694. #define TIM_TS_ETRF ((uint32_t)0x0070U)
  695. #define TIM_TS_NONE ((uint32_t)0xFFFFU)
  696. /**
  697. * @}
  698. */
  699. /** @defgroup TIM_Trigger_Polarity TIM Trigger Polarity
  700. * @{
  701. */
  702. #define TIM_TRIGGERPOLARITY_INVERTED TIM_ETRPOLARITY_INVERTED /*!< Polarity for ETRx trigger sources */
  703. #define TIM_TRIGGERPOLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED /*!< Polarity for ETRx trigger sources */
  704. #define TIM_TRIGGERPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING /*!< Polarity for TIxFPx or TI1_ED trigger sources */
  705. #define TIM_TRIGGERPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING /*!< Polarity for TIxFPx or TI1_ED trigger sources */
  706. #define TIM_TRIGGERPOLARITY_BOTHEDGE TIM_INPUTCHANNELPOLARITY_BOTHEDGE /*!< Polarity for TIxFPx or TI1_ED trigger sources */
  707. /**
  708. * @}
  709. */
  710. /** @defgroup TIM_Trigger_Prescaler TIM Trigger Prescaler
  711. * @{
  712. */
  713. #define TIM_TRIGGERPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1 /*!< No prescaler is used */
  714. #define TIM_TRIGGERPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2 /*!< Prescaler for External ETR Trigger: Capture performed once every 2 events. */
  715. #define TIM_TRIGGERPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4 /*!< Prescaler for External ETR Trigger: Capture performed once every 4 events. */
  716. #define TIM_TRIGGERPRESCALER_DIV8 TIM_ETRPRESCALER_DIV8 /*!< Prescaler for External ETR Trigger: Capture performed once every 8 events. */
  717. /**
  718. * @}
  719. */
  720. /** @defgroup TIM_TI1_Selection TIM TI1 Input Selection
  721. * @{
  722. */
  723. #define TIM_TI1SELECTION_CH1 ((uint32_t)0x0000U)
  724. #define TIM_TI1SELECTION_XORCOMBINATION (TIM_CR2_TI1S)
  725. /**
  726. * @}
  727. */
  728. /** @defgroup TIM_DMA_Burst_Length TIM DMA Burst Length
  729. * @{
  730. */
  731. #define TIM_DMABURSTLENGTH_1TRANSFER (0x00000000U)
  732. #define TIM_DMABURSTLENGTH_2TRANSFERS (0x00000100U)
  733. #define TIM_DMABURSTLENGTH_3TRANSFERS (0x00000200U)
  734. #define TIM_DMABURSTLENGTH_4TRANSFERS (0x00000300U)
  735. #define TIM_DMABURSTLENGTH_5TRANSFERS (0x00000400U)
  736. #define TIM_DMABURSTLENGTH_6TRANSFERS (0x00000500U)
  737. #define TIM_DMABURSTLENGTH_7TRANSFERS (0x00000600U)
  738. #define TIM_DMABURSTLENGTH_8TRANSFERS (0x00000700U)
  739. #define TIM_DMABURSTLENGTH_9TRANSFERS (0x00000800U)
  740. #define TIM_DMABURSTLENGTH_10TRANSFERS (0x00000900U)
  741. #define TIM_DMABURSTLENGTH_11TRANSFERS (0x00000A00U)
  742. #define TIM_DMABURSTLENGTH_12TRANSFERS (0x00000B00U)
  743. #define TIM_DMABURSTLENGTH_13TRANSFERS (0x00000C00U)
  744. #define TIM_DMABURSTLENGTH_14TRANSFERS (0x00000D00U)
  745. #define TIM_DMABURSTLENGTH_15TRANSFERS (0x00000E00U)
  746. #define TIM_DMABURSTLENGTH_16TRANSFERS (0x00000F00U)
  747. #define TIM_DMABURSTLENGTH_17TRANSFERS (0x00001000U)
  748. #define TIM_DMABURSTLENGTH_18TRANSFERS (0x00001100U)
  749. /**
  750. * @}
  751. */
  752. /** @defgroup DMA_Handle_index TIM DMA Handle Index
  753. * @{
  754. */
  755. #define TIM_DMA_ID_UPDATE ((uint16_t) 0x0U) /*!< Index of the DMA handle used for Update DMA requests */
  756. #define TIM_DMA_ID_CC1 ((uint16_t) 0x1U) /*!< Index of the DMA handle used for Capture/Compare 1 DMA requests */
  757. #define TIM_DMA_ID_CC2 ((uint16_t) 0x2U) /*!< Index of the DMA handle used for Capture/Compare 2 DMA requests */
  758. #define TIM_DMA_ID_CC3 ((uint16_t) 0x3U) /*!< Index of the DMA handle used for Capture/Compare 3 DMA requests */
  759. #define TIM_DMA_ID_CC4 ((uint16_t) 0x4U) /*!< Index of the DMA handle used for Capture/Compare 4 DMA requests */
  760. #define TIM_DMA_ID_COMMUTATION ((uint16_t) 0x5U) /*!< Index of the DMA handle used for Commutation DMA requests */
  761. #define TIM_DMA_ID_TRIGGER ((uint16_t) 0x6U) /*!< Index of the DMA handle used for Trigger DMA requests */
  762. /**
  763. * @}
  764. */
  765. /** @defgroup Channel_CC_State TIM Capture/Compare Channel State
  766. * @{
  767. */
  768. #define TIM_CCx_ENABLE ((uint32_t)0x0001U)
  769. #define TIM_CCx_DISABLE ((uint32_t)0x0000U)
  770. #define TIM_CCxN_ENABLE ((uint32_t)0x0004U)
  771. #define TIM_CCxN_DISABLE ((uint32_t)0x0000U)
  772. /**
  773. * @}
  774. */
  775. /**
  776. * @}
  777. */
  778. /* End of exported constants -------------------------------------------------*/
  779. /* Exported macros -----------------------------------------------------------*/
  780. /** @defgroup TIM_Exported_Macros TIM Exported Macros
  781. * @{
  782. */
  783. /** @brief Reset TIM handle state
  784. * @param __HANDLE__: TIM handle.
  785. * @retval None
  786. */
  787. #define __HAL_TIM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_TIM_STATE_RESET)
  788. /**
  789. * @brief Enable the TIM peripheral.
  790. * @param __HANDLE__: TIM handle
  791. * @retval None
  792. */
  793. #define __HAL_TIM_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1|=(TIM_CR1_CEN))
  794. /**
  795. * @brief Set the Update Request Source (URS) bit of the TIMx_CR1 register.
  796. * @param __HANDLE__: TIM handle.
  797. * @note When the USR bit of the TIMx_CR1 register is set, only counter
  798. * overflow/underflow generates an update interrupt or DMA request (if
  799. * enabled)
  800. * @retval None
  801. */
  802. #define __HAL_TIM_URS_ENABLE(__HANDLE__) \
  803. ((__HANDLE__)->Instance->CR1|= (TIM_CR1_URS))
  804. /**
  805. * @brief Enable the TIM main Output.
  806. * @param __HANDLE__: TIM handle
  807. * @retval None
  808. */
  809. #define __HAL_TIM_MOE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->BDTR|=(TIM_BDTR_MOE))
  810. /* The counter of a timer instance is disabled only if all the CCx and CCxN
  811. channels have been disabled */
  812. #define TIM_CCER_CCxE_MASK ((uint32_t)(TIM_CCER_CC1E | TIM_CCER_CC2E | TIM_CCER_CC3E | TIM_CCER_CC4E))
  813. #define TIM_CCER_CCxNE_MASK ((uint32_t)(TIM_CCER_CC1NE | TIM_CCER_CC2NE | TIM_CCER_CC3NE))
  814. /**
  815. * @brief Disable the TIM peripheral.
  816. * @param __HANDLE__: TIM handle
  817. * @retval None
  818. */
  819. #define __HAL_TIM_DISABLE(__HANDLE__) \
  820. do { \
  821. if (((__HANDLE__)->Instance->CCER & TIM_CCER_CCxE_MASK) == 0) \
  822. { \
  823. if(((__HANDLE__)->Instance->CCER & TIM_CCER_CCxNE_MASK) == 0) \
  824. { \
  825. (__HANDLE__)->Instance->CR1 &= ~(TIM_CR1_CEN); \
  826. } \
  827. } \
  828. } while(0)
  829. /**
  830. * @brief Reset the Update Request Source (URS) bit of the TIMx_CR1 register.
  831. * @param __HANDLE__: TIM handle.
  832. * @note When the USR bit of the TIMx_CR1 register is reset, any of the
  833. * following events generate an update interrupt or DMA request (if
  834. * enabled):
  835. * _ Counter overflow underflow
  836. * _ Setting the UG bit
  837. * _ Update generation through the slave mode controller
  838. * @retval None
  839. */
  840. #define __HAL_TIM_URS_DISABLE(__HANDLE__) \
  841. ((__HANDLE__)->Instance->CR1&=~(TIM_CR1_URS))
  842. /**
  843. * @brief Disable the TIM main Output.
  844. * @param __HANDLE__: TIM handle
  845. * @note The Main Output Enable of a timer instance is disabled only if all the CCx and CCxN channels have been disabled
  846. * @retval None
  847. */
  848. #define __HAL_TIM_MOE_DISABLE(__HANDLE__) \
  849. do { \
  850. if (((__HANDLE__)->Instance->CCER & TIM_CCER_CCxE_MASK) == 0) \
  851. { \
  852. if(((__HANDLE__)->Instance->CCER & TIM_CCER_CCxNE_MASK) == 0) \
  853. { \
  854. (__HANDLE__)->Instance->BDTR &= ~(TIM_BDTR_MOE); \
  855. } \
  856. } \
  857. } while(0)
  858. /* The Main Output Enable of a timer instance is disabled unconditionally */
  859. /**
  860. * @brief Disable the TIM main Output.
  861. * @param __HANDLE__: TIM handle
  862. * @retval None
  863. * @note The Main Output Enable of a timer instance is disabled uncondiotionally
  864. */
  865. #define __HAL_TIM_MOE_DISABLE_UNCONDITIONALLY(__HANDLE__) ((__HANDLE__)->Instance->BDTR &= ~(TIM_BDTR_MOE))
  866. /** @brief Enable the specified TIM interrupt.
  867. * @param __HANDLE__: specifies the TIM Handle.
  868. * @param __INTERRUPT__: specifies the TIM interrupt source to enable.
  869. * This parameter can be one of the following values:
  870. * @arg TIM_IT_UPDATE: Update interrupt
  871. * @arg TIM_IT_CC1: Capture/Compare 1 interrupt
  872. * @arg TIM_IT_CC2: Capture/Compare 2 interrupt
  873. * @arg TIM_IT_CC3: Capture/Compare 3 interrupt
  874. * @arg TIM_IT_CC4: Capture/Compare 4 interrupt
  875. * @arg TIM_IT_COM: Commutation interrupt
  876. * @arg TIM_IT_TRIGGER: Trigger interrupt
  877. * @arg TIM_IT_BREAK: Break interrupt
  878. * @retval None
  879. */
  880. #define __HAL_TIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DIER |= (__INTERRUPT__))
  881. /** @brief Disable the specified TIM interrupt.
  882. * @param __HANDLE__: specifies the TIM Handle.
  883. * @param __INTERRUPT__: specifies the TIM interrupt source to disable.
  884. * This parameter can be one of the following values:
  885. * @arg TIM_IT_UPDATE: Update interrupt
  886. * @arg TIM_IT_CC1: Capture/Compare 1 interrupt
  887. * @arg TIM_IT_CC2: Capture/Compare 2 interrupt
  888. * @arg TIM_IT_CC3: Capture/Compare 3 interrupt
  889. * @arg TIM_IT_CC4: Capture/Compare 4 interrupt
  890. * @arg TIM_IT_COM: Commutation interrupt
  891. * @arg TIM_IT_TRIGGER: Trigger interrupt
  892. * @arg TIM_IT_BREAK: Break interrupt
  893. * @retval None
  894. */
  895. #define __HAL_TIM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DIER &= ~(__INTERRUPT__))
  896. /** @brief Enable the specified DMA request.
  897. * @param __HANDLE__: specifies the TIM Handle.
  898. * @param __DMA__: specifies the TIM DMA request to enable.
  899. * This parameter can be one of the following values:
  900. * @arg TIM_DMA_UPDATE: Update DMA request
  901. * @arg TIM_DMA_CC1: Capture/Compare 1 DMA request
  902. * @arg TIM_DMA_CC2: Capture/Compare 2 DMA request
  903. * @arg TIM_DMA_CC3: Capture/Compare 3 DMA request
  904. * @arg TIM_DMA_CC4: Capture/Compare 4 DMA request
  905. * @arg TIM_DMA_COM: Commutation DMA request
  906. * @arg TIM_DMA_TRIGGER: Trigger DMA request
  907. * @retval None
  908. */
  909. #define __HAL_TIM_ENABLE_DMA(__HANDLE__, __DMA__) ((__HANDLE__)->Instance->DIER |= (__DMA__))
  910. /** @brief Disable the specified DMA request.
  911. * @param __HANDLE__: specifies the TIM Handle.
  912. * @param __DMA__: specifies the TIM DMA request to disable.
  913. * This parameter can be one of the following values:
  914. * @arg TIM_DMA_UPDATE: Update DMA request
  915. * @arg TIM_DMA_CC1: Capture/Compare 1 DMA request
  916. * @arg TIM_DMA_CC2: Capture/Compare 2 DMA request
  917. * @arg TIM_DMA_CC3: Capture/Compare 3 DMA request
  918. * @arg TIM_DMA_CC4: Capture/Compare 4 DMA request
  919. * @arg TIM_DMA_COM: Commutation DMA request
  920. * @arg TIM_DMA_TRIGGER: Trigger DMA request
  921. * @arg TIM_DMA_BREAK: Break DMA request
  922. * @retval None
  923. */
  924. #define __HAL_TIM_DISABLE_DMA(__HANDLE__, __DMA__) ((__HANDLE__)->Instance->DIER &= ~(__DMA__))
  925. /** @brief Check whether the specified TIM interrupt flag is set or not.
  926. * @param __HANDLE__: specifies the TIM Handle.
  927. * @param __FLAG__: specifies the TIM interrupt flag to check.
  928. * This parameter can be one of the following values:
  929. * @arg TIM_FLAG_UPDATE: Update interrupt flag
  930. * @arg TIM_FLAG_CC1: Capture/Compare 1 interrupt flag
  931. * @arg TIM_FLAG_CC2: Capture/Compare 2 interrupt flag
  932. * @arg TIM_FLAG_CC3: Capture/Compare 3 interrupt flag
  933. * @arg TIM_FLAG_CC4: Capture/Compare 4 interrupt flag
  934. * @arg TIM_FLAG_CC5: Compare 5 interrupt flag
  935. * @arg TIM_FLAG_CC6: Compare 6 interrupt flag
  936. * @arg TIM_FLAG_COM: Commutation interrupt flag
  937. * @arg TIM_FLAG_TRIGGER: Trigger interrupt flag
  938. * @arg TIM_FLAG_BREAK: Break interrupt flag
  939. * @arg TIM_FLAG_BREAK2: Break 2 interrupt flag
  940. * @arg TIM_FLAG_SYSTEM_BREAK: System Break interrupt flag
  941. * @arg TIM_FLAG_CC1OF: Capture/Compare 1 overcapture flag
  942. * @arg TIM_FLAG_CC2OF: Capture/Compare 2 overcapture flag
  943. * @arg TIM_FLAG_CC3OF: Capture/Compare 3 overcapture flag
  944. * @arg TIM_FLAG_CC4OF: Capture/Compare 4 overcapture flag
  945. * @retval The new state of __FLAG__ (TRUE or FALSE).
  946. */
  947. #define __HAL_TIM_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR &(__FLAG__)) == (__FLAG__))
  948. /** @brief Clear the specified TIM interrupt flag.
  949. * @param __HANDLE__: specifies the TIM Handle.
  950. * @param __FLAG__: specifies the TIM interrupt flag to clear.
  951. * This parameter can be one of the following values:
  952. * @arg TIM_FLAG_UPDATE: Update interrupt flag
  953. * @arg TIM_FLAG_CC1: Capture/Compare 1 interrupt flag
  954. * @arg TIM_FLAG_CC2: Capture/Compare 2 interrupt flag
  955. * @arg TIM_FLAG_CC3: Capture/Compare 3 interrupt flag
  956. * @arg TIM_FLAG_CC4: Capture/Compare 4 interrupt flag
  957. * @arg TIM_FLAG_CC5: Compare 5 interrupt flag
  958. * @arg TIM_FLAG_CC6: Compare 6 interrupt flag
  959. * @arg TIM_FLAG_COM: Commutation interrupt flag
  960. * @arg TIM_FLAG_TRIGGER: Trigger interrupt flag
  961. * @arg TIM_FLAG_BREAK: Break interrupt flag
  962. * @arg TIM_FLAG_BREAK2: Break 2 interrupt flag
  963. * @arg TIM_FLAG_SYSTEM_BREAK: System Break interrupt flag
  964. * @arg TIM_FLAG_CC1OF: Capture/Compare 1 overcapture flag
  965. * @arg TIM_FLAG_CC2OF: Capture/Compare 2 overcapture flag
  966. * @arg TIM_FLAG_CC3OF: Capture/Compare 3 overcapture flag
  967. * @arg TIM_FLAG_CC4OF: Capture/Compare 4 overcapture flag
  968. * @retval The new state of __FLAG__ (TRUE or FALSE).
  969. */
  970. #define __HAL_TIM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
  971. /**
  972. * @brief Check whether the specified TIM interrupt source is enabled or not.
  973. * @param __HANDLE__: TIM handle
  974. * @param __INTERRUPT__: specifies the TIM interrupt source to check.
  975. * This parameter can be one of the following values:
  976. * @arg TIM_IT_UPDATE: Update interrupt
  977. * @arg TIM_IT_CC1: Capture/Compare 1 interrupt
  978. * @arg TIM_IT_CC2: Capture/Compare 2 interrupt
  979. * @arg TIM_IT_CC3: Capture/Compare 3 interrupt
  980. * @arg TIM_IT_CC4: Capture/Compare 4 interrupt
  981. * @arg TIM_IT_COM: Commutation interrupt
  982. * @arg TIM_IT_TRIGGER: Trigger interrupt
  983. * @arg TIM_IT_BREAK: Break interrupt
  984. * @retval The state of TIM_IT (SET or RESET).
  985. */
  986. #define __HAL_TIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->DIER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
  987. /** @brief Clear the TIM interrupt pending bits.
  988. * @param __HANDLE__: TIM handle
  989. * @param __INTERRUPT__: specifies the interrupt pending bit to clear.
  990. * This parameter can be one of the following values:
  991. * @arg TIM_IT_UPDATE: Update interrupt
  992. * @arg TIM_IT_CC1: Capture/Compare 1 interrupt
  993. * @arg TIM_IT_CC2: Capture/Compare 2 interrupt
  994. * @arg TIM_IT_CC3: Capture/Compare 3 interrupt
  995. * @arg TIM_IT_CC4: Capture/Compare 4 interrupt
  996. * @arg TIM_IT_COM: Commutation interrupt
  997. * @arg TIM_IT_TRIGGER: Trigger interrupt
  998. * @arg TIM_IT_BREAK: Break interrupt
  999. * @retval None
  1000. */
  1001. #define __HAL_TIM_CLEAR_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->SR = ~(uint32_t)(__INTERRUPT__))
  1002. /**
  1003. * @brief Indicates whether or not the TIM Counter is used as downcounter.
  1004. * @param __HANDLE__: TIM handle.
  1005. * @retval False (Counter used as upcounter) or True (Counter used as downcounter)
  1006. * @note This macro is particularly useful to get the counting mode when the timer operates in Center-aligned mode or Encoder
  1007. mode.
  1008. */
  1009. #define __HAL_TIM_IS_TIM_COUNTING_DOWN(__HANDLE__) (((__HANDLE__)->Instance->CR1 &(TIM_CR1_DIR)) == (TIM_CR1_DIR))
  1010. /**
  1011. * @brief Set the TIM Prescaler on runtime.
  1012. * @param __HANDLE__: TIM handle.
  1013. * @param __PRESC__: specifies the Prescaler new value.
  1014. * @retval None
  1015. */
  1016. #define __HAL_TIM_SET_PRESCALER(__HANDLE__, __PRESC__) ((__HANDLE__)->Instance->PSC = (__PRESC__))
  1017. #define TIM_SET_ICPRESCALERVALUE(__HANDLE__, __CHANNEL__, __ICPSC__) \
  1018. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 |= (__ICPSC__)) :\
  1019. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 |= ((__ICPSC__) << 8)) :\
  1020. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 |= (__ICPSC__)) :\
  1021. ((__HANDLE__)->Instance->CCMR2 |= ((__ICPSC__) << 8)))
  1022. #define TIM_RESET_ICPRESCALERVALUE(__HANDLE__, __CHANNEL__) \
  1023. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 &= (uint16_t)~TIM_CCMR1_IC1PSC) :\
  1024. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 &= (uint16_t)~TIM_CCMR1_IC2PSC) :\
  1025. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 &= (uint16_t)~TIM_CCMR2_IC3PSC) :\
  1026. ((__HANDLE__)->Instance->CCMR2 &= (uint16_t)~TIM_CCMR2_IC4PSC))
  1027. #define TIM_SET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__, __POLARITY__) \
  1028. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCER |= (__POLARITY__)) :\
  1029. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCER |= ((__POLARITY__) << 4)) :\
  1030. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCER |= ((__POLARITY__) << 8)) :\
  1031. ((__HANDLE__)->Instance->CCER |= (((__POLARITY__) << 12))))
  1032. #define TIM_RESET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__) \
  1033. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCER &= (uint16_t)~(TIM_CCER_CC1P | TIM_CCER_CC1NP)) :\
  1034. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCER &= (uint16_t)~(TIM_CCER_CC2P | TIM_CCER_CC2NP)) :\
  1035. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCER &= (uint16_t)~(TIM_CCER_CC3P | TIM_CCER_CC3NP)) :\
  1036. ((__HANDLE__)->Instance->CCER &= (uint16_t)~(TIM_CCER_CC4P | TIM_CCER_CC4NP)))
  1037. /**
  1038. * @brief Set the TIM Counter Register value on runtime.
  1039. * @param __HANDLE__: TIM handle.
  1040. * @param __COUNTER__: specifies the Counter register new value.
  1041. * @retval None
  1042. */
  1043. #define __HAL_TIM_SET_COUNTER(__HANDLE__, __COUNTER__) ((__HANDLE__)->Instance->CNT = (__COUNTER__))
  1044. /**
  1045. * @brief Get the TIM Counter Register value on runtime.
  1046. * @param __HANDLE__: TIM handle.
  1047. * @retval 16-bit or 32-bit value of the timer counter register (TIMx_CNT)
  1048. */
  1049. #define __HAL_TIM_GET_COUNTER(__HANDLE__) ((__HANDLE__)->Instance->CNT)
  1050. /**
  1051. * @brief Set the TIM Autoreload Register value on runtime without calling another time any Init function.
  1052. * @param __HANDLE__: TIM handle.
  1053. * @param __AUTORELOAD__: specifies the Counter register new value.
  1054. * @retval None
  1055. */
  1056. #define __HAL_TIM_SET_AUTORELOAD(__HANDLE__, __AUTORELOAD__) \
  1057. do{ \
  1058. (__HANDLE__)->Instance->ARR = (__AUTORELOAD__); \
  1059. (__HANDLE__)->Init.Period = (__AUTORELOAD__); \
  1060. } while(0)
  1061. /**
  1062. * @brief Get the TIM Autoreload Register value on runtime.
  1063. * @param __HANDLE__: TIM handle.
  1064. * @retval 16-bit or 32-bit value of the timer auto-reload register(TIMx_ARR)
  1065. */
  1066. #define __HAL_TIM_GET_AUTORELOAD(__HANDLE__) ((__HANDLE__)->Instance->ARR)
  1067. /**
  1068. * @brief Set the TIM Clock Division value on runtime without calling another time any Init function.
  1069. * @param __HANDLE__: TIM handle.
  1070. * @param __CKD__: specifies the clock division value.
  1071. * This parameter can be one of the following value:
  1072. * @arg TIM_CLOCKDIVISION_DIV1
  1073. * @arg TIM_CLOCKDIVISION_DIV2
  1074. * @arg TIM_CLOCKDIVISION_DIV4
  1075. * @retval None
  1076. */
  1077. #define __HAL_TIM_SET_CLOCKDIVISION(__HANDLE__, __CKD__) \
  1078. do{ \
  1079. (__HANDLE__)->Instance->CR1 &= (uint16_t)(~TIM_CR1_CKD); \
  1080. (__HANDLE__)->Instance->CR1 |= (__CKD__); \
  1081. (__HANDLE__)->Init.ClockDivision = (__CKD__); \
  1082. } while(0)
  1083. /**
  1084. * @brief Get the TIM Clock Division value on runtime.
  1085. * @param __HANDLE__: TIM handle.
  1086. * @retval The clock division can be one of the following values:
  1087. * @arg TIM_CLOCKDIVISION_DIV1: tDTS=tCK_INT
  1088. * @arg TIM_CLOCKDIVISION_DIV2: tDTS=2*tCK_INT
  1089. * @arg TIM_CLOCKDIVISION_DIV4: tDTS=4*tCK_INT
  1090. */
  1091. #define __HAL_TIM_GET_CLOCKDIVISION(__HANDLE__) ((__HANDLE__)->Instance->CR1 & TIM_CR1_CKD)
  1092. /**
  1093. * @brief Set the TIM Input Capture prescaler on runtime without calling
  1094. * another time HAL_TIM_IC_ConfigChannel() function.
  1095. * @param __HANDLE__: TIM handle.
  1096. * @param __CHANNEL__: TIM Channels to be configured.
  1097. * This parameter can be one of the following values:
  1098. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  1099. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  1100. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  1101. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  1102. * @param __ICPSC__: specifies the Input Capture4 prescaler new value.
  1103. * This parameter can be one of the following values:
  1104. * @arg TIM_ICPSC_DIV1: no prescaler
  1105. * @arg TIM_ICPSC_DIV2: capture is done once every 2 events
  1106. * @arg TIM_ICPSC_DIV4: capture is done once every 4 events
  1107. * @arg TIM_ICPSC_DIV8: capture is done once every 8 events
  1108. * @retval None
  1109. */
  1110. #define __HAL_TIM_SET_ICPRESCALER(__HANDLE__, __CHANNEL__, __ICPSC__) \
  1111. do{ \
  1112. TIM_RESET_ICPRESCALERVALUE((__HANDLE__), (__CHANNEL__)); \
  1113. TIM_SET_ICPRESCALERVALUE((__HANDLE__), (__CHANNEL__), (__ICPSC__)); \
  1114. } while(0)
  1115. /**
  1116. * @brief Get the TIM Input Capture prescaler on runtime.
  1117. * @param __HANDLE__: TIM handle.
  1118. * @param __CHANNEL__: TIM Channels to be configured.
  1119. * This parameter can be one of the following values:
  1120. * @arg TIM_CHANNEL_1: get input capture 1 prescaler value
  1121. * @arg TIM_CHANNEL_2: get input capture 2 prescaler value
  1122. * @arg TIM_CHANNEL_3: get input capture 3 prescaler value
  1123. * @arg TIM_CHANNEL_4: get input capture 4 prescaler value
  1124. * @retval The input capture prescaler can be one of the following values:
  1125. * @arg TIM_ICPSC_DIV1: no prescaler
  1126. * @arg TIM_ICPSC_DIV2: capture is done once every 2 events
  1127. * @arg TIM_ICPSC_DIV4: capture is done once every 4 events
  1128. * @arg TIM_ICPSC_DIV8: capture is done once every 8 events
  1129. */
  1130. #define __HAL_TIM_GET_ICPRESCALER(__HANDLE__, __CHANNEL__) \
  1131. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 & TIM_CCMR1_IC1PSC) :\
  1132. ((__CHANNEL__) == TIM_CHANNEL_2) ? (((__HANDLE__)->Instance->CCMR1 & TIM_CCMR1_IC2PSC) >> 8) :\
  1133. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 & TIM_CCMR2_IC3PSC) :\
  1134. (((__HANDLE__)->Instance->CCMR2 & TIM_CCMR2_IC4PSC)) >> 8)
  1135. /**
  1136. * @brief Set the TIM Capture x input polarity on runtime.
  1137. * @param __HANDLE__: TIM handle.
  1138. * @param __CHANNEL__: TIM Channels to be configured.
  1139. * This parameter can be one of the following values:
  1140. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  1141. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  1142. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  1143. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  1144. * @param __POLARITY__: Polarity for TIx source
  1145. * @arg TIM_INPUTCHANNELPOLARITY_RISING: Rising Edge
  1146. * @arg TIM_INPUTCHANNELPOLARITY_FALLING: Falling Edge
  1147. * @arg TIM_INPUTCHANNELPOLARITY_BOTHEDGE: Rising and Falling Edge
  1148. * @retval None
  1149. */
  1150. #define __HAL_TIM_SET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__, __POLARITY__) \
  1151. do{ \
  1152. TIM_RESET_CAPTUREPOLARITY((__HANDLE__), (__CHANNEL__)); \
  1153. TIM_SET_CAPTUREPOLARITY((__HANDLE__), (__CHANNEL__), (__POLARITY__)); \
  1154. }while(0)
  1155. /**
  1156. * @brief Set the TIM Capture Compare Register value on runtime without calling another time ConfigChannel function.
  1157. * @param __HANDLE__: TIM handle.
  1158. * @param __CHANNEL__: TIM Channels to be configured.
  1159. * This parameter can be one of the following values:
  1160. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  1161. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  1162. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  1163. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  1164. * @arg TIM_CHANNEL_5: TIM Channel 5 selected
  1165. * @arg TIM_CHANNEL_6: TIM Channel 6 selected
  1166. * @param __COMPARE__: specifies the Capture Compare register new value.
  1167. * @retval None
  1168. */
  1169. #define __HAL_TIM_SET_COMPARE(__HANDLE__, __CHANNEL__, __COMPARE__) \
  1170. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCR1 = (__COMPARE__)) :\
  1171. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCR2 = (__COMPARE__)) :\
  1172. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCR3 = (__COMPARE__)) :\
  1173. ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCR4 = (__COMPARE__)) :\
  1174. ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCR5 = (__COMPARE__)) :\
  1175. ((__HANDLE__)->Instance->CCR6 = (__COMPARE__)))
  1176. /**
  1177. * @brief Get the TIM Capture Compare Register value on runtime.
  1178. * @param __HANDLE__: TIM handle.
  1179. * @param __CHANNEL__: TIM Channel associated with the capture compare register
  1180. * This parameter can be one of the following values:
  1181. * @arg TIM_CHANNEL_1: get capture/compare 1 register value
  1182. * @arg TIM_CHANNEL_2: get capture/compare 2 register value
  1183. * @arg TIM_CHANNEL_3: get capture/compare 3 register value
  1184. * @arg TIM_CHANNEL_4: get capture/compare 4 register value
  1185. * @arg TIM_CHANNEL_5: get capture/compare 5 register value
  1186. * @arg TIM_CHANNEL_6: get capture/compare 6 register value
  1187. * @retval None by @retval 16-bit or 32-bit value of the capture/compare register (TIMx_CCRy)
  1188. */
  1189. #define __HAL_TIM_GET_COMPARE(__HANDLE__, __CHANNEL__) \
  1190. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCR1) :\
  1191. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCR2) :\
  1192. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCR3) :\
  1193. ((__CHANNEL__) == TIM_CHANNEL_4) ? ((__HANDLE__)->Instance->CCR4) :\
  1194. ((__CHANNEL__) == TIM_CHANNEL_5) ? ((__HANDLE__)->Instance->CCR5) :\
  1195. ((__HANDLE__)->Instance->CCR6))
  1196. /**
  1197. * @}
  1198. */
  1199. /* End of exported macros ----------------------------------------------------*/
  1200. /* Private constants ---------------------------------------------------------*/
  1201. /** @defgroup TIM_Private_Constants TIM Private Constants
  1202. * @{
  1203. */
  1204. /**
  1205. * @}
  1206. */
  1207. /* End of private constants --------------------------------------------------*/
  1208. /* Private macros ------------------------------------------------------------*/
  1209. /** @defgroup TIM_Private_Macros TIM Private Macros
  1210. * @{
  1211. */
  1212. #define IS_TIM_CLEARINPUT_SOURCE(__MODE__) (((__MODE__) == TIM_CLEARINPUTSOURCE_ETR) || \
  1213. ((__MODE__) == TIM_CLEARINPUTSOURCE_OCREFCLR) || \
  1214. ((__MODE__) == TIM_CLEARINPUTSOURCE_NONE))
  1215. #define IS_TIM_DMA_BASE(__BASE__) (((__BASE__) == TIM_DMABASE_CR1) || \
  1216. ((__BASE__) == TIM_DMABASE_CR2) || \
  1217. ((__BASE__) == TIM_DMABASE_SMCR) || \
  1218. ((__BASE__) == TIM_DMABASE_DIER) || \
  1219. ((__BASE__) == TIM_DMABASE_SR) || \
  1220. ((__BASE__) == TIM_DMABASE_EGR) || \
  1221. ((__BASE__) == TIM_DMABASE_CCMR1) || \
  1222. ((__BASE__) == TIM_DMABASE_CCMR2) || \
  1223. ((__BASE__) == TIM_DMABASE_CCER) || \
  1224. ((__BASE__) == TIM_DMABASE_CNT) || \
  1225. ((__BASE__) == TIM_DMABASE_PSC) || \
  1226. ((__BASE__) == TIM_DMABASE_ARR) || \
  1227. ((__BASE__) == TIM_DMABASE_RCR) || \
  1228. ((__BASE__) == TIM_DMABASE_CCR1) || \
  1229. ((__BASE__) == TIM_DMABASE_CCR2) || \
  1230. ((__BASE__) == TIM_DMABASE_CCR3) || \
  1231. ((__BASE__) == TIM_DMABASE_CCR4) || \
  1232. ((__BASE__) == TIM_DMABASE_BDTR) || \
  1233. ((__BASE__) == TIM_DMABASE_CCMR3) || \
  1234. ((__BASE__) == TIM_DMABASE_CCR5) || \
  1235. ((__BASE__) == TIM_DMABASE_CCR6) || \
  1236. ((__BASE__) == TIM_DMABASE_AF1) || \
  1237. ((__BASE__) == TIM_DMABASE_AF2) || \
  1238. ((__BASE__) == TIM_DMABASE_TISEL))
  1239. #define IS_TIM_EVENT_SOURCE(__SOURCE__) ((((__SOURCE__) & 0xFFFFFE00U) == 0x00000000U) && ((__SOURCE__) != 0x00000000U))
  1240. #define IS_TIM_COUNTER_MODE(__MODE__) (((__MODE__) == TIM_COUNTERMODE_UP) || \
  1241. ((__MODE__) == TIM_COUNTERMODE_DOWN) || \
  1242. ((__MODE__) == TIM_COUNTERMODE_CENTERALIGNED1) || \
  1243. ((__MODE__) == TIM_COUNTERMODE_CENTERALIGNED2) || \
  1244. ((__MODE__) == TIM_COUNTERMODE_CENTERALIGNED3))
  1245. #define IS_TIM_CLOCKDIVISION_DIV(__DIV__) (((__DIV__) == TIM_CLOCKDIVISION_DIV1) || \
  1246. ((__DIV__) == TIM_CLOCKDIVISION_DIV2) || \
  1247. ((__DIV__) == TIM_CLOCKDIVISION_DIV4))
  1248. #define IS_TIM_AUTORELOAD_PRELOAD(PRELOAD) (((PRELOAD) == TIM_AUTORELOAD_PRELOAD_DISABLE) || \
  1249. ((PRELOAD) == TIM_AUTORELOAD_PRELOAD_ENABLE))
  1250. #define IS_TIM_FAST_STATE(__STATE__) (((__STATE__) == TIM_OCFAST_DISABLE) || \
  1251. ((__STATE__) == TIM_OCFAST_ENABLE))
  1252. #define IS_TIM_OC_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_OCPOLARITY_HIGH) || \
  1253. ((__POLARITY__) == TIM_OCPOLARITY_LOW))
  1254. #define IS_TIM_OCN_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_OCNPOLARITY_HIGH) || \
  1255. ((__POLARITY__) == TIM_OCNPOLARITY_LOW))
  1256. #define IS_TIM_OCIDLE_STATE(__STATE__) (((__STATE__) == TIM_OCIDLESTATE_SET) || \
  1257. ((__STATE__) == TIM_OCIDLESTATE_RESET))
  1258. #define IS_TIM_OCNIDLE_STATE(__STATE__) (((__STATE__) == TIM_OCNIDLESTATE_SET) || \
  1259. ((__STATE__) == TIM_OCNIDLESTATE_RESET))
  1260. #define IS_TIM_IC_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_ICPOLARITY_RISING) || \
  1261. ((__POLARITY__) == TIM_ICPOLARITY_FALLING) || \
  1262. ((__POLARITY__) == TIM_ICPOLARITY_BOTHEDGE))
  1263. #define IS_TIM_IC_SELECTION(__SELECTION__) (((__SELECTION__) == TIM_ICSELECTION_DIRECTTI) || \
  1264. ((__SELECTION__) == TIM_ICSELECTION_INDIRECTTI) || \
  1265. ((__SELECTION__) == TIM_ICSELECTION_TRC))
  1266. #define IS_TIM_IC_PRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_ICPSC_DIV1) || \
  1267. ((__PRESCALER__) == TIM_ICPSC_DIV2) || \
  1268. ((__PRESCALER__) == TIM_ICPSC_DIV4) || \
  1269. ((__PRESCALER__) == TIM_ICPSC_DIV8))
  1270. #define IS_TIM_OPM_MODE(__MODE__) (((__MODE__) == TIM_OPMODE_SINGLE) || \
  1271. ((__MODE__) == TIM_OPMODE_REPETITIVE))
  1272. #define IS_TIM_ENCODER_MODE(__MODE__) (((__MODE__) == TIM_ENCODERMODE_TI1) || \
  1273. ((__MODE__) == TIM_ENCODERMODE_TI2) || \
  1274. ((__MODE__) == TIM_ENCODERMODE_TI12))
  1275. #define IS_TIM_DMA_SOURCE(__SOURCE__) ((((__SOURCE__) & 0xFFFF80FFU) == 0x00000000U) && ((__SOURCE__) != 0x00000000U))
  1276. #define IS_TIM_CHANNELS(__CHANNEL__) (((__CHANNEL__) == TIM_CHANNEL_1) || \
  1277. ((__CHANNEL__) == TIM_CHANNEL_2) || \
  1278. ((__CHANNEL__) == TIM_CHANNEL_3) || \
  1279. ((__CHANNEL__) == TIM_CHANNEL_4) || \
  1280. ((__CHANNEL__) == TIM_CHANNEL_5) || \
  1281. ((__CHANNEL__) == TIM_CHANNEL_6) || \
  1282. ((__CHANNEL__) == TIM_CHANNEL_ALL))
  1283. #define IS_TIM_OPM_CHANNELS(__CHANNEL__) (((__CHANNEL__) == TIM_CHANNEL_1) || \
  1284. ((__CHANNEL__) == TIM_CHANNEL_2))
  1285. #define IS_TIM_COMPLEMENTARY_CHANNELS(__CHANNEL__) (((__CHANNEL__) == TIM_CHANNEL_1) || \
  1286. ((__CHANNEL__) == TIM_CHANNEL_2) || \
  1287. ((__CHANNEL__) == TIM_CHANNEL_3))
  1288. #define IS_TIM_CLOCKSOURCE(__CLOCK__) (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL) || \
  1289. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE2) || \
  1290. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR0) || \
  1291. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR1) || \
  1292. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR2) || \
  1293. ((__CLOCK__) == TIM_CLOCKSOURCE_ITR3) || \
  1294. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1ED) || \
  1295. ((__CLOCK__) == TIM_CLOCKSOURCE_TI1) || \
  1296. ((__CLOCK__) == TIM_CLOCKSOURCE_TI2) || \
  1297. ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE1))
  1298. #define IS_TIM_CLOCKPOLARITY(__POLARITY__) (((__POLARITY__) == TIM_CLOCKPOLARITY_INVERTED) || \
  1299. ((__POLARITY__) == TIM_CLOCKPOLARITY_NONINVERTED) || \
  1300. ((__POLARITY__) == TIM_CLOCKPOLARITY_RISING) || \
  1301. ((__POLARITY__) == TIM_CLOCKPOLARITY_FALLING) || \
  1302. ((__POLARITY__) == TIM_CLOCKPOLARITY_BOTHEDGE))
  1303. #define IS_TIM_CLOCKPRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV1) || \
  1304. ((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV2) || \
  1305. ((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV4) || \
  1306. ((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV8))
  1307. #define IS_TIM_CLOCKFILTER(ICFILTER) ((ICFILTER) <= 0xF)
  1308. #define IS_TIM_CLEARINPUT_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_CLEARINPUTPOLARITY_INVERTED) || \
  1309. ((__POLARITY__) == TIM_CLEARINPUTPOLARITY_NONINVERTED))
  1310. #define IS_TIM_CLEARINPUT_PRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV1) || \
  1311. ((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV2) || \
  1312. ((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV4) || \
  1313. ((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV8))
  1314. #define IS_TIM_CLEARINPUT_FILTER(__ICFILTER__) ((__ICFILTER__) <= 0xFU)
  1315. #define IS_TIM_OSSR_STATE(__STATE__) (((__STATE__) == TIM_OSSR_ENABLE) || \
  1316. ((__STATE__) == TIM_OSSR_DISABLE))
  1317. #define IS_TIM_OSSI_STATE(__STATE__) (((__STATE__) == TIM_OSSI_ENABLE) || \
  1318. ((__STATE__) == TIM_OSSI_DISABLE))
  1319. #define IS_TIM_LOCK_LEVEL(__LEVEL__) (((__LEVEL__) == TIM_LOCKLEVEL_OFF) || \
  1320. ((__LEVEL__) == TIM_LOCKLEVEL_1) || \
  1321. ((__LEVEL__) == TIM_LOCKLEVEL_2) || \
  1322. ((__LEVEL__) == TIM_LOCKLEVEL_3))
  1323. #define IS_TIM_BREAK_FILTER(__BRKFILTER__) ((__BRKFILTER__) <= 0xF)
  1324. #define IS_TIM_BREAK_STATE(__STATE__) (((__STATE__) == TIM_BREAK_ENABLE) || \
  1325. ((__STATE__) == TIM_BREAK_DISABLE))
  1326. #define IS_TIM_BREAK_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_BREAKPOLARITY_LOW) || \
  1327. ((__POLARITY__) == TIM_BREAKPOLARITY_HIGH))
  1328. #define IS_TIM_BREAK2_STATE(__STATE__) (((__STATE__) == TIM_BREAK2_ENABLE) || \
  1329. ((__STATE__) == TIM_BREAK2_DISABLE))
  1330. #define IS_TIM_BREAK2_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_BREAK2POLARITY_LOW) || \
  1331. ((__POLARITY__) == TIM_BREAK2POLARITY_HIGH))
  1332. #define IS_TIM_AUTOMATIC_OUTPUT_STATE(__STATE__) (((__STATE__) == TIM_AUTOMATICOUTPUT_ENABLE) || \
  1333. ((__STATE__) == TIM_AUTOMATICOUTPUT_DISABLE))
  1334. #define IS_TIM_GROUPCH5(__OCREF__) ((((__OCREF__) & 0x1FFFFFFFU) == 0x00000000U))
  1335. #define IS_TIM_TRGO_SOURCE(__SOURCE__) (((__SOURCE__) == TIM_TRGO_RESET) || \
  1336. ((__SOURCE__) == TIM_TRGO_ENABLE) || \
  1337. ((__SOURCE__) == TIM_TRGO_UPDATE) || \
  1338. ((__SOURCE__) == TIM_TRGO_OC1) || \
  1339. ((__SOURCE__) == TIM_TRGO_OC1REF) || \
  1340. ((__SOURCE__) == TIM_TRGO_OC2REF) || \
  1341. ((__SOURCE__) == TIM_TRGO_OC3REF) || \
  1342. ((__SOURCE__) == TIM_TRGO_OC4REF))
  1343. #define IS_TIM_TRGO2_SOURCE(__SOURCE__) (((__SOURCE__) == TIM_TRGO2_RESET) || \
  1344. ((__SOURCE__) == TIM_TRGO2_ENABLE) || \
  1345. ((__SOURCE__) == TIM_TRGO2_UPDATE) || \
  1346. ((__SOURCE__) == TIM_TRGO2_OC1) || \
  1347. ((__SOURCE__) == TIM_TRGO2_OC1REF) || \
  1348. ((__SOURCE__) == TIM_TRGO2_OC2REF) || \
  1349. ((__SOURCE__) == TIM_TRGO2_OC3REF) || \
  1350. ((__SOURCE__) == TIM_TRGO2_OC3REF) || \
  1351. ((__SOURCE__) == TIM_TRGO2_OC4REF) || \
  1352. ((__SOURCE__) == TIM_TRGO2_OC5REF) || \
  1353. ((__SOURCE__) == TIM_TRGO2_OC6REF) || \
  1354. ((__SOURCE__) == TIM_TRGO2_OC4REF_RISINGFALLING) || \
  1355. ((__SOURCE__) == TIM_TRGO2_OC6REF_RISINGFALLING) || \
  1356. ((__SOURCE__) == TIM_TRGO2_OC4REF_RISING_OC6REF_RISING) || \
  1357. ((__SOURCE__) == TIM_TRGO2_OC4REF_RISING_OC6REF_FALLING) || \
  1358. ((__SOURCE__) == TIM_TRGO2_OC5REF_RISING_OC6REF_RISING) || \
  1359. ((__SOURCE__) == TIM_TRGO2_OC5REF_RISING_OC6REF_FALLING))
  1360. #define IS_TIM_MSM_STATE(__STATE__) (((__STATE__) == TIM_MASTERSLAVEMODE_ENABLE) || \
  1361. ((__STATE__) == TIM_MASTERSLAVEMODE_DISABLE))
  1362. #define IS_TIM_SLAVE_MODE(__MODE__) (((__MODE__) == TIM_SLAVEMODE_DISABLE) || \
  1363. ((__MODE__) == TIM_SLAVEMODE_RESET) || \
  1364. ((__MODE__) == TIM_SLAVEMODE_GATED) || \
  1365. ((__MODE__) == TIM_SLAVEMODE_TRIGGER) || \
  1366. ((__MODE__) == TIM_SLAVEMODE_EXTERNAL1) || \
  1367. ((__MODE__) == TIM_SLAVEMODE_COMBINED_RESETTRIGGER))
  1368. #define IS_TIM_PWM_MODE(__MODE__) (((__MODE__) == TIM_OCMODE_PWM1) || \
  1369. ((__MODE__) == TIM_OCMODE_PWM2) || \
  1370. ((__MODE__) == TIM_OCMODE_COMBINED_PWM1) || \
  1371. ((__MODE__) == TIM_OCMODE_COMBINED_PWM2) || \
  1372. ((__MODE__) == TIM_OCMODE_ASSYMETRIC_PWM1) || \
  1373. ((__MODE__) == TIM_OCMODE_ASSYMETRIC_PWM2))
  1374. #define IS_TIM_OC_MODE(__MODE__) (((__MODE__) == TIM_OCMODE_TIMING) || \
  1375. ((__MODE__) == TIM_OCMODE_ACTIVE) || \
  1376. ((__MODE__) == TIM_OCMODE_INACTIVE) || \
  1377. ((__MODE__) == TIM_OCMODE_TOGGLE) || \
  1378. ((__MODE__) == TIM_OCMODE_FORCED_ACTIVE) || \
  1379. ((__MODE__) == TIM_OCMODE_FORCED_INACTIVE) || \
  1380. ((__MODE__) == TIM_OCMODE_RETRIGERRABLE_OPM1) || \
  1381. ((__MODE__) == TIM_OCMODE_RETRIGERRABLE_OPM2))
  1382. #define IS_TIM_TRIGGER_SELECTION(__SELECTION__) (((__SELECTION__) == TIM_TS_ITR0) || \
  1383. ((__SELECTION__) == TIM_TS_ITR1) || \
  1384. ((__SELECTION__) == TIM_TS_ITR2) || \
  1385. ((__SELECTION__) == TIM_TS_ITR3) || \
  1386. ((__SELECTION__) == TIM_TS_TI1F_ED) || \
  1387. ((__SELECTION__) == TIM_TS_TI1FP1) || \
  1388. ((__SELECTION__) == TIM_TS_TI2FP2) || \
  1389. ((__SELECTION__) == TIM_TS_ETRF))
  1390. #define IS_TIM_INTERNAL_TRIGGEREVENT_SELECTION(__SELECTION__) (((__SELECTION__) == TIM_TS_ITR0) || \
  1391. ((__SELECTION__) == TIM_TS_ITR1) || \
  1392. ((__SELECTION__) == TIM_TS_ITR2) || \
  1393. ((__SELECTION__) == TIM_TS_ITR3) || \
  1394. ((__SELECTION__) == TIM_TS_NONE))
  1395. #define IS_TIM_TRIGGERPOLARITY(__POLARITY__) (((__POLARITY__) == TIM_TRIGGERPOLARITY_INVERTED ) || \
  1396. ((__POLARITY__) == TIM_TRIGGERPOLARITY_NONINVERTED) || \
  1397. ((__POLARITY__) == TIM_TRIGGERPOLARITY_RISING ) || \
  1398. ((__POLARITY__) == TIM_TRIGGERPOLARITY_FALLING ) || \
  1399. ((__POLARITY__) == TIM_TRIGGERPOLARITY_BOTHEDGE ))
  1400. #define IS_TIM_TRIGGERPRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV1) || \
  1401. ((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV2) || \
  1402. ((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV4) || \
  1403. ((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV8))
  1404. #define IS_TIM_TRIGGERFILTER(__ICFILTER__) ((__ICFILTER__) <= 0xFU)
  1405. #define IS_TIM_TI1SELECTION(__TI1SELECTION__) (((__TI1SELECTION__) == TIM_TI1SELECTION_CH1) || \
  1406. ((__TI1SELECTION__) == TIM_TI1SELECTION_XORCOMBINATION))
  1407. #define IS_TIM_DMA_LENGTH(__LENGTH__) (((__LENGTH__) == TIM_DMABURSTLENGTH_1TRANSFER) || \
  1408. ((__LENGTH__) == TIM_DMABURSTLENGTH_2TRANSFERS) || \
  1409. ((__LENGTH__) == TIM_DMABURSTLENGTH_3TRANSFERS) || \
  1410. ((__LENGTH__) == TIM_DMABURSTLENGTH_4TRANSFERS) || \
  1411. ((__LENGTH__) == TIM_DMABURSTLENGTH_5TRANSFERS) || \
  1412. ((__LENGTH__) == TIM_DMABURSTLENGTH_6TRANSFERS) || \
  1413. ((__LENGTH__) == TIM_DMABURSTLENGTH_7TRANSFERS) || \
  1414. ((__LENGTH__) == TIM_DMABURSTLENGTH_8TRANSFERS) || \
  1415. ((__LENGTH__) == TIM_DMABURSTLENGTH_9TRANSFERS) || \
  1416. ((__LENGTH__) == TIM_DMABURSTLENGTH_10TRANSFERS) || \
  1417. ((__LENGTH__) == TIM_DMABURSTLENGTH_11TRANSFERS) || \
  1418. ((__LENGTH__) == TIM_DMABURSTLENGTH_12TRANSFERS) || \
  1419. ((__LENGTH__) == TIM_DMABURSTLENGTH_13TRANSFERS) || \
  1420. ((__LENGTH__) == TIM_DMABURSTLENGTH_14TRANSFERS) || \
  1421. ((__LENGTH__) == TIM_DMABURSTLENGTH_15TRANSFERS) || \
  1422. ((__LENGTH__) == TIM_DMABURSTLENGTH_16TRANSFERS) || \
  1423. ((__LENGTH__) == TIM_DMABURSTLENGTH_17TRANSFERS) || \
  1424. ((__LENGTH__) == TIM_DMABURSTLENGTH_18TRANSFERS))
  1425. #define IS_TIM_IC_FILTER(__ICFILTER__) ((__ICFILTER__) <= 0xFU)
  1426. #define IS_TIM_DEADTIME(__DEADTIME__) ((__DEADTIME__) <= 0xFFU)
  1427. #define IS_TIM_BREAK_SYSTEM(__CONFIG__) (((__CONFIG__) == TIM_BREAK_SYSTEM_ECC) || \
  1428. ((__CONFIG__) == TIM_BREAK_SYSTEM_PVD) || \
  1429. ((__CONFIG__) == TIM_BREAK_SYSTEM_SRAM2_PARITY_ERROR) || \
  1430. ((__CONFIG__) == TIM_BREAK_SYSTEM_LOCKUP))
  1431. /**
  1432. * @}
  1433. */
  1434. /* End of private macros -----------------------------------------------------*/
  1435. /* Include TIM HAL Extended module */
  1436. #include "stm32h7xx_hal_tim_ex.h"
  1437. /* Exported functions --------------------------------------------------------*/
  1438. /** @addtogroup TIM_Exported_Functions TIM Exported Functions
  1439. * @{
  1440. */
  1441. /** @addtogroup TIM_Exported_Functions_Group1 Time Base functions
  1442. * @brief Time Base functions
  1443. * @{
  1444. */
  1445. /* Time Base functions ********************************************************/
  1446. HAL_StatusTypeDef HAL_TIM_Base_Init(TIM_HandleTypeDef *htim);
  1447. HAL_StatusTypeDef HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim);
  1448. void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim);
  1449. void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim);
  1450. /* Blocking mode: Polling */
  1451. HAL_StatusTypeDef HAL_TIM_Base_Start(TIM_HandleTypeDef *htim);
  1452. HAL_StatusTypeDef HAL_TIM_Base_Stop(TIM_HandleTypeDef *htim);
  1453. /* Non-Blocking mode: Interrupt */
  1454. HAL_StatusTypeDef HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim);
  1455. HAL_StatusTypeDef HAL_TIM_Base_Stop_IT(TIM_HandleTypeDef *htim);
  1456. /* Non-Blocking mode: DMA */
  1457. HAL_StatusTypeDef HAL_TIM_Base_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
  1458. HAL_StatusTypeDef HAL_TIM_Base_Stop_DMA(TIM_HandleTypeDef *htim);
  1459. /**
  1460. * @}
  1461. */
  1462. /** @addtogroup TIM_Exported_Functions_Group2 Time Output Compare functions
  1463. * @brief Time Output Compare functions
  1464. * @{
  1465. */
  1466. /* Timer Output Compare functions **********************************************/
  1467. HAL_StatusTypeDef HAL_TIM_OC_Init(TIM_HandleTypeDef *htim);
  1468. HAL_StatusTypeDef HAL_TIM_OC_DeInit(TIM_HandleTypeDef *htim);
  1469. void HAL_TIM_OC_MspInit(TIM_HandleTypeDef *htim);
  1470. void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef *htim);
  1471. /* Blocking mode: Polling */
  1472. HAL_StatusTypeDef HAL_TIM_OC_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  1473. HAL_StatusTypeDef HAL_TIM_OC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  1474. /* Non-Blocking mode: Interrupt */
  1475. HAL_StatusTypeDef HAL_TIM_OC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1476. HAL_StatusTypeDef HAL_TIM_OC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1477. /* Non-Blocking mode: DMA */
  1478. HAL_StatusTypeDef HAL_TIM_OC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  1479. HAL_StatusTypeDef HAL_TIM_OC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  1480. /**
  1481. * @}
  1482. */
  1483. /** @addtogroup TIM_Exported_Functions_Group3 Time PWM functions
  1484. * @brief Time PWM functions
  1485. * @{
  1486. */
  1487. /* Timer PWM functions *********************************************************/
  1488. HAL_StatusTypeDef HAL_TIM_PWM_Init(TIM_HandleTypeDef *htim);
  1489. HAL_StatusTypeDef HAL_TIM_PWM_DeInit(TIM_HandleTypeDef *htim);
  1490. void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim);
  1491. void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef *htim);
  1492. /* Blocking mode: Polling */
  1493. HAL_StatusTypeDef HAL_TIM_PWM_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  1494. HAL_StatusTypeDef HAL_TIM_PWM_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  1495. /* Non-Blocking mode: Interrupt */
  1496. HAL_StatusTypeDef HAL_TIM_PWM_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1497. HAL_StatusTypeDef HAL_TIM_PWM_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1498. /* Non-Blocking mode: DMA */
  1499. HAL_StatusTypeDef HAL_TIM_PWM_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  1500. HAL_StatusTypeDef HAL_TIM_PWM_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  1501. /**
  1502. * @}
  1503. */
  1504. /** @addtogroup TIM_Exported_Functions_Group4 Time Input Capture functions
  1505. * @brief Time Input Capture functions
  1506. * @{
  1507. */
  1508. /* Timer Input Capture functions ***********************************************/
  1509. HAL_StatusTypeDef HAL_TIM_IC_Init(TIM_HandleTypeDef *htim);
  1510. HAL_StatusTypeDef HAL_TIM_IC_DeInit(TIM_HandleTypeDef *htim);
  1511. void HAL_TIM_IC_MspInit(TIM_HandleTypeDef *htim);
  1512. void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef *htim);
  1513. /* Blocking mode: Polling */
  1514. HAL_StatusTypeDef HAL_TIM_IC_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  1515. HAL_StatusTypeDef HAL_TIM_IC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  1516. /* Non-Blocking mode: Interrupt */
  1517. HAL_StatusTypeDef HAL_TIM_IC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1518. HAL_StatusTypeDef HAL_TIM_IC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1519. /* Non-Blocking mode: DMA */
  1520. HAL_StatusTypeDef HAL_TIM_IC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  1521. HAL_StatusTypeDef HAL_TIM_IC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  1522. /**
  1523. * @}
  1524. */
  1525. /** @addtogroup TIM_Exported_Functions_Group5 Time One Pulse functions
  1526. * @brief Time One Pulse functions
  1527. * @{
  1528. */
  1529. /* Timer One Pulse functions ***************************************************/
  1530. HAL_StatusTypeDef HAL_TIM_OnePulse_Init(TIM_HandleTypeDef *htim, uint32_t OnePulseMode);
  1531. HAL_StatusTypeDef HAL_TIM_OnePulse_DeInit(TIM_HandleTypeDef *htim);
  1532. void HAL_TIM_OnePulse_MspInit(TIM_HandleTypeDef *htim);
  1533. void HAL_TIM_OnePulse_MspDeInit(TIM_HandleTypeDef *htim);
  1534. /* Blocking mode: Polling */
  1535. HAL_StatusTypeDef HAL_TIM_OnePulse_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  1536. HAL_StatusTypeDef HAL_TIM_OnePulse_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  1537. /* Non-Blocking mode: Interrupt */
  1538. HAL_StatusTypeDef HAL_TIM_OnePulse_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  1539. HAL_StatusTypeDef HAL_TIM_OnePulse_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  1540. /**
  1541. * @}
  1542. */
  1543. /** @addtogroup TIM_Exported_Functions_Group6 Time Encoder functions
  1544. * @brief Time Encoder functions
  1545. * @{
  1546. */
  1547. /* Timer Encoder functions *****************************************************/
  1548. HAL_StatusTypeDef HAL_TIM_Encoder_Init(TIM_HandleTypeDef *htim, TIM_Encoder_InitTypeDef* sConfig);
  1549. HAL_StatusTypeDef HAL_TIM_Encoder_DeInit(TIM_HandleTypeDef *htim);
  1550. void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim);
  1551. void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef *htim);
  1552. /* Blocking mode: Polling */
  1553. HAL_StatusTypeDef HAL_TIM_Encoder_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  1554. HAL_StatusTypeDef HAL_TIM_Encoder_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  1555. /* Non-Blocking mode: Interrupt */
  1556. HAL_StatusTypeDef HAL_TIM_Encoder_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1557. HAL_StatusTypeDef HAL_TIM_Encoder_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1558. /* Non-Blocking mode: DMA */
  1559. HAL_StatusTypeDef HAL_TIM_Encoder_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData1, uint32_t *pData2, uint16_t Length);
  1560. HAL_StatusTypeDef HAL_TIM_Encoder_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  1561. /**
  1562. * @}
  1563. */
  1564. /** @addtogroup TIM_Exported_Functions_Group7 TIM IRQ handler management
  1565. * @brief IRQ handler management
  1566. * @{
  1567. */
  1568. /* Interrupt Handler functions **********************************************/
  1569. void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim);
  1570. /**
  1571. * @}
  1572. */
  1573. /** @defgroup TIM_Exported_Functions_Group8 Peripheral Control functions
  1574. * @brief Peripheral Control functions
  1575. * @{
  1576. */
  1577. /* Control functions *********************************************************/
  1578. HAL_StatusTypeDef HAL_TIM_OC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OC_InitTypeDef* sConfig, uint32_t Channel);
  1579. HAL_StatusTypeDef HAL_TIM_PWM_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OC_InitTypeDef* sConfig, uint32_t Channel);
  1580. HAL_StatusTypeDef HAL_TIM_IC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_IC_InitTypeDef* sConfig, uint32_t Channel);
  1581. HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OnePulse_InitTypeDef* sConfig, uint32_t OutputChannel, uint32_t InputChannel);
  1582. HAL_StatusTypeDef HAL_TIM_ConfigOCrefClear(TIM_HandleTypeDef *htim, TIM_ClearInputConfigTypeDef * sClearInputConfig, uint32_t Channel);
  1583. HAL_StatusTypeDef HAL_TIM_ConfigClockSource(TIM_HandleTypeDef *htim, TIM_ClockConfigTypeDef * sClockSourceConfig);
  1584. HAL_StatusTypeDef HAL_TIM_ConfigTI1Input(TIM_HandleTypeDef *htim, uint32_t TI1_Selection);
  1585. HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchronization(TIM_HandleTypeDef *htim, TIM_SlaveConfigTypeDef * sSlaveConfig);
  1586. HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchronization_IT(TIM_HandleTypeDef *htim, TIM_SlaveConfigTypeDef * sSlaveConfig);
  1587. HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc, \
  1588. uint32_t *BurstBuffer, uint32_t BurstLength);
  1589. HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc);
  1590. HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc, \
  1591. uint32_t *BurstBuffer, uint32_t BurstLength);
  1592. HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc);
  1593. HAL_StatusTypeDef HAL_TIM_GenerateEvent(TIM_HandleTypeDef *htim, uint32_t EventSource);
  1594. uint32_t HAL_TIM_ReadCapturedValue(TIM_HandleTypeDef *htim, uint32_t Channel);
  1595. /**
  1596. * @}
  1597. */
  1598. /** @defgroup TIM_Exported_Functions_Group9 TIM Callbacks functions
  1599. * @brief TIM Callbacks functions
  1600. * @{
  1601. */
  1602. /* Callback in non blocking modes (Interrupt and DMA) *************************/
  1603. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim);
  1604. void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim);
  1605. void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim);
  1606. void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim);
  1607. void HAL_TIM_TriggerCallback(TIM_HandleTypeDef *htim);
  1608. void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim);
  1609. /**
  1610. * @}
  1611. */
  1612. /** @defgroup TIM_Exported_Functions_Group10 Peripheral State functions
  1613. * @brief Peripheral State functions
  1614. * @{
  1615. */
  1616. /* Peripheral State functions **************************************************/
  1617. HAL_TIM_StateTypeDef HAL_TIM_Base_GetState(TIM_HandleTypeDef *htim);
  1618. HAL_TIM_StateTypeDef HAL_TIM_OC_GetState(TIM_HandleTypeDef *htim);
  1619. HAL_TIM_StateTypeDef HAL_TIM_PWM_GetState(TIM_HandleTypeDef *htim);
  1620. HAL_TIM_StateTypeDef HAL_TIM_IC_GetState(TIM_HandleTypeDef *htim);
  1621. HAL_TIM_StateTypeDef HAL_TIM_OnePulse_GetState(TIM_HandleTypeDef *htim);
  1622. HAL_TIM_StateTypeDef HAL_TIM_Encoder_GetState(TIM_HandleTypeDef *htim);
  1623. /**
  1624. * @}
  1625. */
  1626. /**
  1627. * @}
  1628. */
  1629. /* End of exported functions -------------------------------------------------*/
  1630. /* Private functions----------------------------------------------------------*/
  1631. /** @defgroup TIM_Private_Functions TIM Private Functions
  1632. * @{
  1633. */
  1634. void TIM_Base_SetConfig(TIM_TypeDef *TIMx, TIM_Base_InitTypeDef *Structure);
  1635. void TIM_TI1_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, uint32_t TIM_ICFilter);
  1636. void TIM_OC1_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config);
  1637. void TIM_OC2_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config);
  1638. void TIM_OC3_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config);
  1639. void TIM_OC4_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config);
  1640. void TIM_ETR_SetConfig(TIM_TypeDef* TIMx, uint32_t TIM_ExtTRGPrescaler,
  1641. uint32_t TIM_ExtTRGPolarity, uint32_t ExtTRGFilter);
  1642. void HAL_TIM_DMADelayPulseCplt(DMA_HandleTypeDef *hdma);
  1643. void HAL_TIM_DMAError(DMA_HandleTypeDef *hdma);
  1644. void HAL_TIM_DMACaptureCplt(DMA_HandleTypeDef *hdma);
  1645. void TIM_CCxChannelCmd(TIM_TypeDef* TIMx, uint32_t Channel, uint32_t ChannelState);
  1646. /**
  1647. * @}
  1648. */
  1649. /* End of private functions --------------------------------------------------*/
  1650. /**
  1651. * @}
  1652. */
  1653. /**
  1654. * @}
  1655. */
  1656. #ifdef __cplusplus
  1657. }
  1658. #endif
  1659. #endif /* __STM32H7xx_HAL_TIM_H */
  1660. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/