stm32f3xx_hal_tim.h 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625
  1. /**
  2. ******************************************************************************
  3. * @file stm32f3xx_hal_tim.h
  4. * @author MCD Application Team
  5. * @brief Header file of TIM HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32F3xx_HAL_TIM_H
  37. #define __STM32F3xx_HAL_TIM_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. #include "stm32f3xx_hal_def.h"
  42. #include "stm32f3xx_hal_dma.h"
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32f3xx_hal_def.h"
  45. /** @addtogroup STM32F3xx_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 = 0xFFFFU */
  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 downcounter
  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+1U) corresponds to:
  73. - the number of PWM periods in edge-aligned mode
  74. - the number of half PWM period in center-aligned mode
  75. GP timers: this parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF.
  76. Advanced timers: this parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */
  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 = 0xFFFFU */
  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 = 0xFFFFU */
  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 = 0xFU */
  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 = 0xFU */
  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 = 0xFU */
  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 = 0xFU */
  168. } TIM_Encoder_InitTypeDef;
  169. /**
  170. * @brief TIM 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 = 0xFU */
  182. }TIM_ClockConfigTypeDef;
  183. /**
  184. * @brief TIM 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 = 0xFU */
  198. }TIM_ClearInputConfigTypeDef;
  199. /**
  200. * @brief TIM Slave configuration Structure definition
  201. */
  202. typedef struct {
  203. uint32_t SlaveMode; /*!< Slave mode selection
  204. This parameter can be a value of @ref TIMEx_Slave_Mode */
  205. uint32_t InputTrigger; /*!< Input Trigger source
  206. This parameter can be a value of @ref TIM_Trigger_Selection */
  207. uint32_t TriggerPolarity; /*!< Input Trigger polarity
  208. This parameter can be a value of @ref TIM_Trigger_Polarity */
  209. uint32_t TriggerPrescaler; /*!< Input trigger prescaler
  210. This parameter can be a value of @ref TIM_Trigger_Prescaler */
  211. uint32_t TriggerFilter; /*!< Input trigger filter
  212. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xFU */
  213. }TIM_SlaveConfigTypeDef;
  214. /**
  215. * @brief HAL State structures definition
  216. */
  217. typedef enum
  218. {
  219. HAL_TIM_STATE_RESET = 0x00U, /*!< Peripheral not yet initialized or disabled */
  220. HAL_TIM_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
  221. HAL_TIM_STATE_BUSY = 0x02U, /*!< An internal process is ongoing */
  222. HAL_TIM_STATE_TIMEOUT = 0x03U, /*!< Timeout state */
  223. HAL_TIM_STATE_ERROR = 0x04 /*!< Reception process is ongoing */
  224. }HAL_TIM_StateTypeDef;
  225. /**
  226. * @brief HAL Active channel structures definition
  227. */
  228. typedef enum
  229. {
  230. HAL_TIM_ACTIVE_CHANNEL_1 = 0x01U, /*!< The active channel is 1 */
  231. HAL_TIM_ACTIVE_CHANNEL_2 = 0x02U, /*!< The active channel is 2 */
  232. HAL_TIM_ACTIVE_CHANNEL_3 = 0x04U, /*!< The active channel is 3 */
  233. HAL_TIM_ACTIVE_CHANNEL_4 = 0x08U, /*!< The active channel is 4 */
  234. HAL_TIM_ACTIVE_CHANNEL_CLEARED = 0x00 /*!< All active channels cleared */
  235. }HAL_TIM_ActiveChannel;
  236. /**
  237. * @brief TIM Time Base Handle Structure definition
  238. */
  239. typedef struct
  240. {
  241. TIM_TypeDef *Instance; /*!< Register base address */
  242. TIM_Base_InitTypeDef Init; /*!< TIM Time Base required parameters */
  243. HAL_TIM_ActiveChannel Channel; /*!< Active channel */
  244. DMA_HandleTypeDef *hdma[7]; /*!< DMA Handlers array
  245. This array is accessed by a @ref TIM_DMA_Handle_index */
  246. HAL_LockTypeDef Lock; /*!< Locking object */
  247. __IO HAL_TIM_StateTypeDef State; /*!< TIM operation state */
  248. }TIM_HandleTypeDef;
  249. /**
  250. * @}
  251. */
  252. /* End of exported types -----------------------------------------------------*/
  253. /* Exported constants --------------------------------------------------------*/
  254. /** @defgroup TIM_Exported_Constants TIM Exported Constants
  255. * @{
  256. */
  257. /** @defgroup TIM_Input_Channel_Polarity TIM Input Channel Polarity
  258. * @{
  259. */
  260. #define TIM_INPUTCHANNELPOLARITY_RISING (0x00000000U) /*!< Polarity for TIx source */
  261. #define TIM_INPUTCHANNELPOLARITY_FALLING (TIM_CCER_CC1P) /*!< Polarity for TIx source */
  262. #define TIM_INPUTCHANNELPOLARITY_BOTHEDGE (TIM_CCER_CC1P | TIM_CCER_CC1NP) /*!< Polarity for TIx source */
  263. /**
  264. * @}
  265. */
  266. /** @defgroup TIM_ETR_Polarity TIM ETR Polarity
  267. * @{
  268. */
  269. #define TIM_ETRPOLARITY_INVERTED (TIM_SMCR_ETP) /*!< Polarity for ETR source */
  270. #define TIM_ETRPOLARITY_NONINVERTED (0x0000U) /*!< Polarity for ETR source */
  271. /**
  272. * @}
  273. */
  274. /** @defgroup TIM_ETR_Prescaler TIM ETR Prescaler
  275. * @{
  276. */
  277. #define TIM_ETRPRESCALER_DIV1 (0x0000U) /*!< No prescaler is used */
  278. #define TIM_ETRPRESCALER_DIV2 (TIM_SMCR_ETPS_0) /*!< ETR input source is divided by 2U */
  279. #define TIM_ETRPRESCALER_DIV4 (TIM_SMCR_ETPS_1) /*!< ETR input source is divided by 4U */
  280. #define TIM_ETRPRESCALER_DIV8 (TIM_SMCR_ETPS) /*!< ETR input source is divided by 8U */
  281. /**
  282. * @}
  283. */
  284. /** @defgroup TIM_Counter_Mode TIM Counter Mode
  285. * @{
  286. */
  287. #define TIM_COUNTERMODE_UP (0x0000U)
  288. #define TIM_COUNTERMODE_DOWN TIM_CR1_DIR
  289. #define TIM_COUNTERMODE_CENTERALIGNED1 TIM_CR1_CMS_0
  290. #define TIM_COUNTERMODE_CENTERALIGNED2 TIM_CR1_CMS_1
  291. #define TIM_COUNTERMODE_CENTERALIGNED3 TIM_CR1_CMS
  292. /**
  293. * @}
  294. */
  295. /** @defgroup TIM_ClockDivision TIM Clock Division
  296. * @{
  297. */
  298. #define TIM_CLOCKDIVISION_DIV1 (0x0000U)
  299. #define TIM_CLOCKDIVISION_DIV2 (TIM_CR1_CKD_0)
  300. #define TIM_CLOCKDIVISION_DIV4 (TIM_CR1_CKD_1)
  301. /**
  302. * @}
  303. */
  304. /** @defgroup TIM_AutoReloadPreload TIM Auto-Reload Preload
  305. * @{
  306. */
  307. #define TIM_AUTORELOAD_PRELOAD_DISABLE (0x0000U) /*!< TIMx_ARR register is not buffered */
  308. #define TIM_AUTORELOAD_PRELOAD_ENABLE (TIM_CR1_ARPE) /*!< TIMx_ARR register is buffered */
  309. /**
  310. * @}
  311. */
  312. /** @defgroup TIM_Output_Fast_State TIM Output Fast State
  313. * @{
  314. */
  315. #define TIM_OCFAST_DISABLE (0x0000U)
  316. #define TIM_OCFAST_ENABLE (TIM_CCMR1_OC1FE)
  317. /**
  318. * @}
  319. */
  320. /** @defgroup TIM_Output_Compare_Polarity TIM Output Compare Polarity
  321. * @{
  322. */
  323. #define TIM_OCPOLARITY_HIGH (0x0000U)
  324. #define TIM_OCPOLARITY_LOW (TIM_CCER_CC1P)
  325. /**
  326. * @}
  327. */
  328. /** @defgroup TIM_Output_Compare_N_Polarity TIM Complementary Output Compare Polarity
  329. * @{
  330. */
  331. #define TIM_OCNPOLARITY_HIGH (0x0000U)
  332. #define TIM_OCNPOLARITY_LOW (TIM_CCER_CC1NP)
  333. /**
  334. * @}
  335. */
  336. /** @defgroup TIM_Output_Compare_Idle_State TIM Output Compare Idle State
  337. * @{
  338. */
  339. #define TIM_OCIDLESTATE_SET (TIM_CR2_OIS1)
  340. #define TIM_OCIDLESTATE_RESET (0x0000U)
  341. /**
  342. * @}
  343. */
  344. /** @defgroup TIM_Output_Compare_N_Idle_State TIM Complementary Output Compare Idle State
  345. * @{
  346. */
  347. #define TIM_OCNIDLESTATE_SET (TIM_CR2_OIS1N)
  348. #define TIM_OCNIDLESTATE_RESET (0x0000U)
  349. /**
  350. * @}
  351. */
  352. /** @defgroup TIM_Input_Capture_Polarity TIM Input Capture Polarity
  353. * @{
  354. */
  355. #define TIM_ICPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING
  356. #define TIM_ICPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING
  357. #define TIM_ICPOLARITY_BOTHEDGE TIM_INPUTCHANNELPOLARITY_BOTHEDGE
  358. /**
  359. * @}
  360. */
  361. /** @defgroup TIM_Input_Capture_Selection TIM Input Capture Selection
  362. * @{
  363. */
  364. #define TIM_ICSELECTION_DIRECTTI (TIM_CCMR1_CC1S_0) /*!< TIM Input 1U, 2U, 3 or 4 is selected to be
  365. connected to IC1, IC2, IC3 or IC4, respectively */
  366. #define TIM_ICSELECTION_INDIRECTTI (TIM_CCMR1_CC1S_1) /*!< TIM Input 1U, 2U, 3 or 4 is selected to be
  367. connected to IC2, IC1, IC4 or IC3, respectively */
  368. #define TIM_ICSELECTION_TRC (TIM_CCMR1_CC1S) /*!< TIM Input 1U, 2U, 3 or 4 is selected to be connected to TRC */
  369. /**
  370. * @}
  371. */
  372. /** @defgroup TIM_Input_Capture_Prescaler TIM Input Capture Prescaler
  373. * @{
  374. */
  375. #define TIM_ICPSC_DIV1 (0x0000U) /*!< Capture performed each time an edge is detected on the capture input */
  376. #define TIM_ICPSC_DIV2 (TIM_CCMR1_IC1PSC_0) /*!< Capture performed once every 2 events */
  377. #define TIM_ICPSC_DIV4 (TIM_CCMR1_IC1PSC_1) /*!< Capture performed once every 4 events */
  378. #define TIM_ICPSC_DIV8 (TIM_CCMR1_IC1PSC) /*!< Capture performed once every 8 events */
  379. /**
  380. * @}
  381. */
  382. /** @defgroup TIM_One_Pulse_Mode TIM One Pulse Mode
  383. * @{
  384. */
  385. #define TIM_OPMODE_SINGLE (TIM_CR1_OPM)
  386. #define TIM_OPMODE_REPETITIVE (0x0000U)
  387. /**
  388. * @}
  389. */
  390. /** @defgroup TIM_Encoder_Mode TIM Encoder Mode
  391. * @{
  392. */
  393. #define TIM_ENCODERMODE_TI1 (TIM_SMCR_SMS_0)
  394. #define TIM_ENCODERMODE_TI2 (TIM_SMCR_SMS_1)
  395. #define TIM_ENCODERMODE_TI12 (TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0)
  396. /**
  397. * @}
  398. */
  399. /** @defgroup TIM_Interrupt_definition TIM Interrupt Definition
  400. * @{
  401. */
  402. #define TIM_IT_UPDATE (TIM_DIER_UIE)
  403. #define TIM_IT_CC1 (TIM_DIER_CC1IE)
  404. #define TIM_IT_CC2 (TIM_DIER_CC2IE)
  405. #define TIM_IT_CC3 (TIM_DIER_CC3IE)
  406. #define TIM_IT_CC4 (TIM_DIER_CC4IE)
  407. #define TIM_IT_COM (TIM_DIER_COMIE)
  408. #define TIM_IT_TRIGGER (TIM_DIER_TIE)
  409. #define TIM_IT_BREAK (TIM_DIER_BIE)
  410. /**
  411. * @}
  412. */
  413. /** @defgroup TIM_Commutation_Source TIM Commutation Source
  414. * @{
  415. */
  416. #define TIM_COMMUTATION_TRGI (TIM_CR2_CCUS)
  417. #define TIM_COMMUTATION_SOFTWARE (0x0000U)
  418. /**
  419. * @}
  420. */
  421. /** @defgroup TIM_DMA_sources TIM DMA Sources
  422. * @{
  423. */
  424. #define TIM_DMA_UPDATE (TIM_DIER_UDE)
  425. #define TIM_DMA_CC1 (TIM_DIER_CC1DE)
  426. #define TIM_DMA_CC2 (TIM_DIER_CC2DE)
  427. #define TIM_DMA_CC3 (TIM_DIER_CC3DE)
  428. #define TIM_DMA_CC4 (TIM_DIER_CC4DE)
  429. #define TIM_DMA_COM (TIM_DIER_COMDE)
  430. #define TIM_DMA_TRIGGER (TIM_DIER_TDE)
  431. /**
  432. * @}
  433. */
  434. /** @defgroup TIM_Flag_definition TIM Flag Definition
  435. * @{
  436. */
  437. #define TIM_FLAG_UPDATE (TIM_SR_UIF)
  438. #define TIM_FLAG_CC1 (TIM_SR_CC1IF)
  439. #define TIM_FLAG_CC2 (TIM_SR_CC2IF)
  440. #define TIM_FLAG_CC3 (TIM_SR_CC3IF)
  441. #define TIM_FLAG_CC4 (TIM_SR_CC4IF)
  442. #define TIM_FLAG_COM (TIM_SR_COMIF)
  443. #define TIM_FLAG_TRIGGER (TIM_SR_TIF)
  444. #define TIM_FLAG_BREAK (TIM_SR_BIF)
  445. #if defined(TIM_SR_B2IF)
  446. #define TIM_FLAG_BREAK2 (TIM_SR_B2IF)
  447. #endif
  448. #define TIM_FLAG_CC1OF (TIM_SR_CC1OF)
  449. #define TIM_FLAG_CC2OF (TIM_SR_CC2OF)
  450. #define TIM_FLAG_CC3OF (TIM_SR_CC3OF)
  451. #define TIM_FLAG_CC4OF (TIM_SR_CC4OF)
  452. /**
  453. * @}
  454. */
  455. /** @defgroup TIM_Clock_Source TIM Clock Source
  456. * @{
  457. */
  458. #define TIM_CLOCKSOURCE_ETRMODE2 (TIM_SMCR_ETPS_1)
  459. #define TIM_CLOCKSOURCE_INTERNAL (TIM_SMCR_ETPS_0)
  460. #define TIM_CLOCKSOURCE_ITR0 (0x0000U)
  461. #define TIM_CLOCKSOURCE_ITR1 (TIM_SMCR_TS_0)
  462. #define TIM_CLOCKSOURCE_ITR2 (TIM_SMCR_TS_1)
  463. #define TIM_CLOCKSOURCE_ITR3 (TIM_SMCR_TS_0 | TIM_SMCR_TS_1)
  464. #define TIM_CLOCKSOURCE_TI1ED (TIM_SMCR_TS_2)
  465. #define TIM_CLOCKSOURCE_TI1 (TIM_SMCR_TS_0 | TIM_SMCR_TS_2)
  466. #define TIM_CLOCKSOURCE_TI2 (TIM_SMCR_TS_1 | TIM_SMCR_TS_2)
  467. #define TIM_CLOCKSOURCE_ETRMODE1 (TIM_SMCR_TS)
  468. /**
  469. * @}
  470. */
  471. /** @defgroup TIM_Clock_Polarity TIM Clock Polarity
  472. * @{
  473. */
  474. #define TIM_CLOCKPOLARITY_INVERTED TIM_ETRPOLARITY_INVERTED /*!< Polarity for ETRx clock sources */
  475. #define TIM_CLOCKPOLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED /*!< Polarity for ETRx clock sources */
  476. #define TIM_CLOCKPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING /*!< Polarity for TIx clock sources */
  477. #define TIM_CLOCKPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING /*!< Polarity for TIx clock sources */
  478. #define TIM_CLOCKPOLARITY_BOTHEDGE TIM_INPUTCHANNELPOLARITY_BOTHEDGE /*!< Polarity for TIx clock sources */
  479. /**
  480. * @}
  481. */
  482. /** @defgroup TIM_Clock_Prescaler TIM Clock Prescaler
  483. * @{
  484. */
  485. #define TIM_CLOCKPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1 /*!< No prescaler is used */
  486. #define TIM_CLOCKPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2 /*!< Prescaler for External ETR Clock: Capture performed once every 2 events. */
  487. #define TIM_CLOCKPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4 /*!< Prescaler for External ETR Clock: Capture performed once every 4 events. */
  488. #define TIM_CLOCKPRESCALER_DIV8 TIM_ETRPRESCALER_DIV8 /*!< Prescaler for External ETR Clock: Capture performed once every 8 events. */
  489. /**
  490. * @}
  491. */
  492. /** @defgroup TIM_ClearInput_Polarity TIM Clear Input Polarity
  493. * @{
  494. */
  495. #define TIM_CLEARINPUTPOLARITY_INVERTED TIM_ETRPOLARITY_INVERTED /*!< Polarity for ETRx pin */
  496. #define TIM_CLEARINPUTPOLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED /*!< Polarity for ETRx pin */
  497. /**
  498. * @}
  499. */
  500. /** @defgroup TIM_ClearInput_Prescaler TIM Clear Input Prescaler
  501. * @{
  502. */
  503. #define TIM_CLEARINPUTPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1 /*!< No prescaler is used */
  504. #define TIM_CLEARINPUTPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2 /*!< Prescaler for External ETR pin: Capture performed once every 2 events. */
  505. #define TIM_CLEARINPUTPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4 /*!< Prescaler for External ETR pin: Capture performed once every 4 events. */
  506. #define TIM_CLEARINPUTPRESCALER_DIV8 TIM_ETRPRESCALER_DIV8 /*!< Prescaler for External ETR pin: Capture performed once every 8 events. */
  507. /**
  508. * @}
  509. */
  510. /** @defgroup TIM_OSSR_Off_State_Selection_for_Run_mode_state TIM OSSR Off State Selection for Run mode state
  511. * @{
  512. */
  513. #define TIM_OSSR_ENABLE (TIM_BDTR_OSSR)
  514. #define TIM_OSSR_DISABLE (0x0000U)
  515. /**
  516. * @}
  517. */
  518. /** @defgroup TIM_OSSI_Off_State_Selection_for_Idle_mode_state TIM OSSI Off State Selection for Idle mode state
  519. * @{
  520. */
  521. #define TIM_OSSI_ENABLE (TIM_BDTR_OSSI)
  522. #define TIM_OSSI_DISABLE (0x0000U)
  523. /**
  524. * @}
  525. */
  526. /** @defgroup TIM_Lock_level TIM Lock level
  527. * @{
  528. */
  529. #define TIM_LOCKLEVEL_OFF (0x0000U)
  530. #define TIM_LOCKLEVEL_1 (TIM_BDTR_LOCK_0)
  531. #define TIM_LOCKLEVEL_2 (TIM_BDTR_LOCK_1)
  532. #define TIM_LOCKLEVEL_3 (TIM_BDTR_LOCK)
  533. /**
  534. * @}
  535. */
  536. /** @defgroup TIM_Break_Input_enable_disable TIM Break Input Enable Disable
  537. * @{
  538. */
  539. #define TIM_BREAK_ENABLE (TIM_BDTR_BKE)
  540. #define TIM_BREAK_DISABLE (0x0000U)
  541. /**
  542. * @}
  543. */
  544. /** @defgroup TIM_Break_Polarity TIM Break Input Polarity
  545. * @{
  546. */
  547. #define TIM_BREAKPOLARITY_LOW (0x0000U)
  548. #define TIM_BREAKPOLARITY_HIGH (TIM_BDTR_BKP)
  549. /**
  550. * @}
  551. */
  552. /** @defgroup TIM_AOE_Bit_Set_Reset TIM Automatic Output Enable
  553. * @{
  554. */
  555. #define TIM_AUTOMATICOUTPUT_ENABLE (TIM_BDTR_AOE)
  556. #define TIM_AUTOMATICOUTPUT_DISABLE (0x0000U)
  557. /**
  558. * @}
  559. */
  560. /** @defgroup TIM_Master_Mode_Selection TIM Master Mode Selection
  561. * @{
  562. */
  563. #define TIM_TRGO_RESET (0x0000U)
  564. #define TIM_TRGO_ENABLE (TIM_CR2_MMS_0)
  565. #define TIM_TRGO_UPDATE (TIM_CR2_MMS_1)
  566. #define TIM_TRGO_OC1 ((TIM_CR2_MMS_1 | TIM_CR2_MMS_0))
  567. #define TIM_TRGO_OC1REF (TIM_CR2_MMS_2)
  568. #define TIM_TRGO_OC2REF ((TIM_CR2_MMS_2 | TIM_CR2_MMS_0))
  569. #define TIM_TRGO_OC3REF ((TIM_CR2_MMS_2 | TIM_CR2_MMS_1))
  570. #define TIM_TRGO_OC4REF ((TIM_CR2_MMS_2 | TIM_CR2_MMS_1 | TIM_CR2_MMS_0))
  571. /**
  572. * @}
  573. */
  574. /** @defgroup TIM_Master_Slave_Mode TIM Master Slave Mode
  575. * @{
  576. */
  577. #define TIM_MASTERSLAVEMODE_ENABLE (0x0080U)
  578. #define TIM_MASTERSLAVEMODE_DISABLE (0x0000U)
  579. /**
  580. * @}
  581. */
  582. /** @defgroup TIM_Trigger_Selection TIM Trigger Selection
  583. * @{
  584. */
  585. #define TIM_TS_ITR0 (0x0000U)
  586. #define TIM_TS_ITR1 (0x0010U)
  587. #define TIM_TS_ITR2 (0x0020U)
  588. #define TIM_TS_ITR3 (0x0030U)
  589. #define TIM_TS_TI1F_ED (0x0040U)
  590. #define TIM_TS_TI1FP1 (0x0050U)
  591. #define TIM_TS_TI2FP2 (0x0060U)
  592. #define TIM_TS_ETRF (0x0070U)
  593. #define TIM_TS_NONE (0xFFFFU)
  594. /**
  595. * @}
  596. */
  597. /** @defgroup TIM_Trigger_Polarity TIM Trigger Polarity
  598. * @{
  599. */
  600. #define TIM_TRIGGERPOLARITY_INVERTED TIM_ETRPOLARITY_INVERTED /*!< Polarity for ETRx trigger sources */
  601. #define TIM_TRIGGERPOLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED /*!< Polarity for ETRx trigger sources */
  602. #define TIM_TRIGGERPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING /*!< Polarity for TIxFPx or TI1_ED trigger sources */
  603. #define TIM_TRIGGERPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING /*!< Polarity for TIxFPx or TI1_ED trigger sources */
  604. #define TIM_TRIGGERPOLARITY_BOTHEDGE TIM_INPUTCHANNELPOLARITY_BOTHEDGE /*!< Polarity for TIxFPx or TI1_ED trigger sources */
  605. /**
  606. * @}
  607. */
  608. /** @defgroup TIM_Trigger_Prescaler TIM Trigger Prescaler
  609. * @{
  610. */
  611. #define TIM_TRIGGERPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1 /*!< No prescaler is used */
  612. #define TIM_TRIGGERPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2 /*!< Prescaler for External ETR Trigger: Capture performed once every 2 events. */
  613. #define TIM_TRIGGERPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4 /*!< Prescaler for External ETR Trigger: Capture performed once every 4 events. */
  614. #define TIM_TRIGGERPRESCALER_DIV8 TIM_ETRPRESCALER_DIV8 /*!< Prescaler for External ETR Trigger: Capture performed once every 8 events. */
  615. /**
  616. * @}
  617. */
  618. /** @defgroup TIM_TI1_Selection TIM TI1 Input Selection
  619. * @{
  620. */
  621. #define TIM_TI1SELECTION_CH1 (0x0000U)
  622. #define TIM_TI1SELECTION_XORCOMBINATION (TIM_CR2_TI1S)
  623. /**
  624. * @}
  625. */
  626. /** @defgroup TIM_DMA_Burst_Length TIM DMA Burst Length
  627. * @{
  628. */
  629. #define TIM_DMABURSTLENGTH_1TRANSFER (0x00000000U)
  630. #define TIM_DMABURSTLENGTH_2TRANSFERS (0x00000100U)
  631. #define TIM_DMABURSTLENGTH_3TRANSFERS (0x00000200U)
  632. #define TIM_DMABURSTLENGTH_4TRANSFERS (0x00000300U)
  633. #define TIM_DMABURSTLENGTH_5TRANSFERS (0x00000400U)
  634. #define TIM_DMABURSTLENGTH_6TRANSFERS (0x00000500U)
  635. #define TIM_DMABURSTLENGTH_7TRANSFERS (0x00000600U)
  636. #define TIM_DMABURSTLENGTH_8TRANSFERS (0x00000700U)
  637. #define TIM_DMABURSTLENGTH_9TRANSFERS (0x00000800U)
  638. #define TIM_DMABURSTLENGTH_10TRANSFERS (0x00000900U)
  639. #define TIM_DMABURSTLENGTH_11TRANSFERS (0x00000A00U)
  640. #define TIM_DMABURSTLENGTH_12TRANSFERS (0x00000B00U)
  641. #define TIM_DMABURSTLENGTH_13TRANSFERS (0x00000C00U)
  642. #define TIM_DMABURSTLENGTH_14TRANSFERS (0x00000D00U)
  643. #define TIM_DMABURSTLENGTH_15TRANSFERS (0x00000E00U)
  644. #define TIM_DMABURSTLENGTH_16TRANSFERS (0x00000F00U)
  645. #define TIM_DMABURSTLENGTH_17TRANSFERS (0x00001000U)
  646. #define TIM_DMABURSTLENGTH_18TRANSFERS (0x00001100U)
  647. /**
  648. * @}
  649. */
  650. /** @defgroup TIM_DMA_Handle_index TIM DMA Handle Index
  651. * @{
  652. */
  653. #define TIM_DMA_ID_UPDATE ((uint16_t) 0x0U) /*!< Index of the DMA handle used for Update DMA requests */
  654. #define TIM_DMA_ID_CC1 ((uint16_t) 0x1U) /*!< Index of the DMA handle used for Capture/Compare 1 DMA requests */
  655. #define TIM_DMA_ID_CC2 ((uint16_t) 0x2U) /*!< Index of the DMA handle used for Capture/Compare 2 DMA requests */
  656. #define TIM_DMA_ID_CC3 ((uint16_t) 0x3U) /*!< Index of the DMA handle used for Capture/Compare 3 DMA requests */
  657. #define TIM_DMA_ID_CC4 ((uint16_t) 0x4U) /*!< Index of the DMA handle used for Capture/Compare 4 DMA requests */
  658. #define TIM_DMA_ID_COMMUTATION ((uint16_t) 0x5U) /*!< Index of the DMA handle used for Commutation DMA requests */
  659. #define TIM_DMA_ID_TRIGGER ((uint16_t) 0x6U) /*!< Index of the DMA handle used for Trigger DMA requests */
  660. /**
  661. * @}
  662. */
  663. /** @defgroup TIM_Channel_CC_State TIM Capture/Compare Channel State
  664. * @{
  665. */
  666. #define TIM_CCx_ENABLE (0x0001U)
  667. #define TIM_CCx_DISABLE (0x0000U)
  668. #define TIM_CCxN_ENABLE (0x0004U)
  669. #define TIM_CCxN_DISABLE (0x0000U)
  670. /**
  671. * @}
  672. */
  673. /**
  674. * @}
  675. */
  676. /* End of exported constants -------------------------------------------------*/
  677. /* Exported macros -----------------------------------------------------------*/
  678. /** @defgroup TIM_Exported_Macros TIM Exported Macros
  679. * @{
  680. */
  681. /** @brief Reset TIM handle state
  682. * @param __HANDLE__ TIM handle.
  683. * @retval None
  684. */
  685. #define __HAL_TIM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_TIM_STATE_RESET)
  686. /**
  687. * @brief Enable the TIM peripheral.
  688. * @param __HANDLE__ TIM handle
  689. * @retval None
  690. */
  691. #define __HAL_TIM_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1|=(TIM_CR1_CEN))
  692. /**
  693. * @brief Enable the TIM main Output.
  694. * @param __HANDLE__ TIM handle
  695. * @retval None
  696. */
  697. #define __HAL_TIM_MOE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->BDTR|=(TIM_BDTR_MOE))
  698. /**
  699. * @brief Disable the TIM peripheral.
  700. * @param __HANDLE__ TIM handle
  701. * @retval None
  702. */
  703. #define __HAL_TIM_DISABLE(__HANDLE__) \
  704. do { \
  705. if (((__HANDLE__)->Instance->CCER & TIM_CCER_CCxE_MASK) == 0U) \
  706. { \
  707. if(((__HANDLE__)->Instance->CCER & TIM_CCER_CCxNE_MASK) == 0U) \
  708. { \
  709. (__HANDLE__)->Instance->CR1 &= ~(TIM_CR1_CEN); \
  710. } \
  711. } \
  712. } while(0U)
  713. /* The Main Output Enable of a timer instance is disabled only if all the CCx and CCxN
  714. channels have been disabled */
  715. /**
  716. * @brief Disable the TIM main Output.
  717. * @param __HANDLE__ TIM handle
  718. * @retval None
  719. * @note The Main Output Enable of a timer instance is disabled only if all the CCx and CCxN channels have been disabled
  720. */
  721. #define __HAL_TIM_MOE_DISABLE(__HANDLE__) \
  722. do { \
  723. if (((__HANDLE__)->Instance->CCER & TIM_CCER_CCxE_MASK) == 0U) \
  724. { \
  725. if(((__HANDLE__)->Instance->CCER & TIM_CCER_CCxNE_MASK) == 0U) \
  726. { \
  727. (__HANDLE__)->Instance->BDTR &= ~(TIM_BDTR_MOE); \
  728. } \
  729. } \
  730. } while(0U)
  731. /* The Main Output Enable of a timer instance is disabled unconditionally */
  732. /**
  733. * @brief Disable the TIM main Output.
  734. * @param __HANDLE__ TIM handle
  735. * @retval None
  736. * @note The Main Output Enable of a timer instance is disabled uncondiotionally
  737. */
  738. #define __HAL_TIM_MOE_DISABLE_UNCONDITIONALLY(__HANDLE__) (__HANDLE__)->Instance->BDTR &= ~(TIM_BDTR_MOE)
  739. /**
  740. * @brief Enables the specified TIM interrupt.
  741. * @param __HANDLE__ specifies the TIM Handle.
  742. * @param __INTERRUPT__ specifies the TIM interrupt source to enable.
  743. * This parameter can be one of the following values:
  744. * @arg TIM_IT_UPDATE: Update interrupt
  745. * @arg TIM_IT_CC1: Capture/Compare 1 interrupt
  746. * @arg TIM_IT_CC2: Capture/Compare 2 interrupt
  747. * @arg TIM_IT_CC3: Capture/Compare 3 interrupt
  748. * @arg TIM_IT_CC4: Capture/Compare 4 interrupt
  749. * @arg TIM_IT_COM: Commutation interrupt
  750. * @arg TIM_IT_TRIGGER: Trigger interrupt
  751. * @arg TIM_IT_BREAK: Break interrupt
  752. * @retval None
  753. */
  754. #define __HAL_TIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DIER |= (__INTERRUPT__))
  755. /**
  756. * @brief Disables the specified TIM interrupt.
  757. * @param __HANDLE__ specifies the TIM Handle.
  758. * @param __INTERRUPT__ specifies the TIM interrupt source to disable.
  759. * This parameter can be one of the following values:
  760. * @arg TIM_IT_UPDATE: Update interrupt
  761. * @arg TIM_IT_CC1: Capture/Compare 1 interrupt
  762. * @arg TIM_IT_CC2: Capture/Compare 2 interrupt
  763. * @arg TIM_IT_CC3: Capture/Compare 3 interrupt
  764. * @arg TIM_IT_CC4: Capture/Compare 4 interrupt
  765. * @arg TIM_IT_COM: Commutation interrupt
  766. * @arg TIM_IT_TRIGGER: Trigger interrupt
  767. * @arg TIM_IT_BREAK: Break interrupt
  768. * @retval None
  769. */
  770. #define __HAL_TIM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DIER &= ~(__INTERRUPT__))
  771. /**
  772. * @brief Enables the specified DMA request.
  773. * @param __HANDLE__ specifies the TIM Handle.
  774. * @param __DMA__ specifies the TIM DMA request to enable.
  775. * This parameter can be one of the following values:
  776. * @arg TIM_DMA_UPDATE: Update DMA request
  777. * @arg TIM_DMA_CC1: Capture/Compare 1 DMA request
  778. * @arg TIM_DMA_CC2: Capture/Compare 2 DMA request
  779. * @arg TIM_DMA_CC3: Capture/Compare 3 DMA request
  780. * @arg TIM_DMA_CC4: Capture/Compare 4 DMA request
  781. * @arg TIM_DMA_COM: Commutation DMA request
  782. * @arg TIM_DMA_TRIGGER: Trigger DMA request
  783. * @retval None
  784. */
  785. #define __HAL_TIM_ENABLE_DMA(__HANDLE__, __DMA__) ((__HANDLE__)->Instance->DIER |= (__DMA__))
  786. /**
  787. * @brief Disables the specified DMA request.
  788. * @param __HANDLE__ specifies the TIM Handle.
  789. * @param __DMA__ specifies the TIM DMA request to disable.
  790. * This parameter can be one of the following values:
  791. * @arg TIM_DMA_UPDATE: Update DMA request
  792. * @arg TIM_DMA_CC1: Capture/Compare 1 DMA request
  793. * @arg TIM_DMA_CC2: Capture/Compare 2 DMA request
  794. * @arg TIM_DMA_CC3: Capture/Compare 3 DMA request
  795. * @arg TIM_DMA_CC4: Capture/Compare 4 DMA request
  796. * @arg TIM_DMA_COM: Commutation DMA request
  797. * @arg TIM_DMA_TRIGGER: Trigger DMA request
  798. * @retval None
  799. */
  800. #define __HAL_TIM_DISABLE_DMA(__HANDLE__, __DMA__) ((__HANDLE__)->Instance->DIER &= ~(__DMA__))
  801. /**
  802. * @brief Checks whether the specified TIM interrupt flag is set or not.
  803. * @param __HANDLE__ specifies the TIM Handle.
  804. * @param __FLAG__ specifies the TIM interrupt flag to check.
  805. * This parameter can be one of the following values:
  806. * @arg TIM_FLAG_UPDATE: Update interrupt flag
  807. * @arg TIM_FLAG_CC1: Capture/Compare 1 interrupt flag
  808. * @arg TIM_FLAG_CC2: Capture/Compare 2 interrupt flag
  809. * @arg TIM_FLAG_CC3: Capture/Compare 3 interrupt flag
  810. * @arg TIM_FLAG_CC4: Capture/Compare 4 interrupt flag
  811. * @arg TIM_FLAG_COM: Commutation interrupt flag
  812. * @arg TIM_FLAG_TRIGGER: Trigger interrupt flag
  813. * @arg TIM_FLAG_BREAK: Break interrupt flag
  814. * @arg TIM_FLAG_CC1OF: Capture/Compare 1 overcapture flag
  815. * @arg TIM_FLAG_CC2OF: Capture/Compare 2 overcapture flag
  816. * @arg TIM_FLAG_CC3OF: Capture/Compare 3 overcapture flag
  817. * @arg TIM_FLAG_CC4OF: Capture/Compare 4 overcapture flag
  818. * @retval The new state of __FLAG__ (TRUE or FALSE).
  819. */
  820. #define __HAL_TIM_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR &(__FLAG__)) == (__FLAG__))
  821. /**
  822. * @brief Clears the specified TIM interrupt flag.
  823. * @param __HANDLE__ specifies the TIM Handle.
  824. * @param __FLAG__ specifies the TIM interrupt flag to clear.
  825. * This parameter can be one of the following values:
  826. * @arg TIM_FLAG_UPDATE: Update interrupt flag
  827. * @arg TIM_FLAG_CC1: Capture/Compare 1 interrupt flag
  828. * @arg TIM_FLAG_CC2: Capture/Compare 2 interrupt flag
  829. * @arg TIM_FLAG_CC3: Capture/Compare 3 interrupt flag
  830. * @arg TIM_FLAG_CC4: Capture/Compare 4 interrupt flag
  831. * @arg TIM_FLAG_COM: Commutation interrupt flag
  832. * @arg TIM_FLAG_TRIGGER: Trigger interrupt flag
  833. * @arg TIM_FLAG_BREAK: Break interrupt flag
  834. * @arg TIM_FLAG_CC1OF: Capture/Compare 1 overcapture flag
  835. * @arg TIM_FLAG_CC2OF: Capture/Compare 2 overcapture flag
  836. * @arg TIM_FLAG_CC3OF: Capture/Compare 3 overcapture flag
  837. * @arg TIM_FLAG_CC4OF: Capture/Compare 4 overcapture flag
  838. * @retval The new state of __FLAG__ (TRUE or FALSE).
  839. */
  840. #define __HAL_TIM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
  841. /**
  842. * @brief Checks whether the specified TIM interrupt has occurred or not.
  843. * @param __HANDLE__ TIM handle
  844. * @param __INTERRUPT__ specifies the TIM interrupt source to check.
  845. * @retval The state of TIM_IT (SET or RESET).
  846. */
  847. #define __HAL_TIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->DIER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
  848. /**
  849. * @brief Clear the TIM interrupt pending bits
  850. * @param __HANDLE__ TIM handle
  851. * @param __INTERRUPT__ specifies the interrupt pending bit to clear.
  852. * @retval None
  853. */
  854. #define __HAL_TIM_CLEAR_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->SR = ~(__INTERRUPT__))
  855. /**
  856. * @brief Indicates whether or not the TIM Counter is used as downcounter
  857. * @param __HANDLE__ TIM handle.
  858. * @retval False (Counter used as upcounter) or True (Counter used as downcounter)
  859. * @note This macro is particularly usefull to get the counting mode when the timer operates in Center-aligned mode or Encoder mode.
  860. */
  861. #define __HAL_TIM_IS_TIM_COUNTING_DOWN(__HANDLE__) (((__HANDLE__)->Instance->CR1 &(TIM_CR1_DIR)) == (TIM_CR1_DIR))
  862. /**
  863. * @brief Sets the TIM active prescaler register value on update event.
  864. * @param __HANDLE__ TIM handle.
  865. * @param __PRESC__ specifies the active prescaler register new value.
  866. * @retval None
  867. */
  868. #define __HAL_TIM_SET_PRESCALER(__HANDLE__, __PRESC__) ((__HANDLE__)->Instance->PSC = (__PRESC__))
  869. /**
  870. * @brief Sets the TIM Counter Register value on runtime.
  871. * @param __HANDLE__ TIM handle.
  872. * @param __COUNTER__ specifies the Counter register new value.
  873. * @retval None
  874. */
  875. #define __HAL_TIM_SET_COUNTER(__HANDLE__, __COUNTER__) ((__HANDLE__)->Instance->CNT = (__COUNTER__))
  876. /**
  877. * @brief Gets the TIM Counter Register value on runtime.
  878. * @param __HANDLE__ TIM handle.
  879. * @retval 16-bit or 32-bit value of the timer counter register (TIMx_CNT)
  880. */
  881. #define __HAL_TIM_GET_COUNTER(__HANDLE__) \
  882. ((__HANDLE__)->Instance->CNT)
  883. /**
  884. * @brief Sets the TIM Autoreload Register value on runtime without calling
  885. * another time any Init function.
  886. * @param __HANDLE__ TIM handle.
  887. * @param __AUTORELOAD__ specifies the Counter register new value.
  888. * @retval None
  889. */
  890. #define __HAL_TIM_SET_AUTORELOAD(__HANDLE__, __AUTORELOAD__) \
  891. do{ \
  892. (__HANDLE__)->Instance->ARR = (__AUTORELOAD__); \
  893. (__HANDLE__)->Init.Period = (__AUTORELOAD__); \
  894. } while(0U)
  895. /**
  896. * @brief Gets the TIM Autoreload Register value on runtime
  897. * @param __HANDLE__ TIM handle.
  898. * @retval 16-bit or 32-bit value of the timer auto-reload register(TIMx_ARR)
  899. */
  900. #define __HAL_TIM_GET_AUTORELOAD(__HANDLE__) \
  901. ((__HANDLE__)->Instance->ARR)
  902. /**
  903. * @brief Sets the TIM Clock Division value on runtime without calling
  904. * another time any Init function.
  905. * @param __HANDLE__ TIM handle.
  906. * @param __CKD__ specifies the clock division value.
  907. * This parameter can be one of the following value:
  908. * @arg TIM_CLOCKDIVISION_DIV1: tDTS=tCK_INT
  909. * @arg TIM_CLOCKDIVISION_DIV2: tDTS=2*tCK_INT
  910. * @arg TIM_CLOCKDIVISION_DIV4: tDTS=4*tCK_INT
  911. * @retval None
  912. */
  913. #define __HAL_TIM_SET_CLOCKDIVISION(__HANDLE__, __CKD__) \
  914. do{ \
  915. (__HANDLE__)->Instance->CR1 &= (uint16_t)(~TIM_CR1_CKD); \
  916. (__HANDLE__)->Instance->CR1 |= (__CKD__); \
  917. (__HANDLE__)->Init.ClockDivision = (__CKD__); \
  918. } while(0U)
  919. /**
  920. * @brief Gets the TIM Clock Division value on runtime
  921. * @param __HANDLE__ TIM handle.
  922. * @retval The clock division can be one of the following values:
  923. * @arg TIM_CLOCKDIVISION_DIV1: tDTS=tCK_INT
  924. * @arg TIM_CLOCKDIVISION_DIV2: tDTS=2*tCK_INT
  925. * @arg TIM_CLOCKDIVISION_DIV4: tDTS=4*tCK_INT
  926. */
  927. #define __HAL_TIM_GET_CLOCKDIVISION(__HANDLE__) \
  928. ((__HANDLE__)->Instance->CR1 & TIM_CR1_CKD)
  929. /**
  930. * @brief Sets the TIM Input Capture prescaler on runtime without calling
  931. * another time HAL_TIM_IC_ConfigChannel() function.
  932. * @param __HANDLE__ TIM handle.
  933. * @param __CHANNEL__ TIM Channels to be configured.
  934. * This parameter can be one of the following values:
  935. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  936. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  937. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  938. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  939. * @param __ICPSC__ specifies the Input Capture4 prescaler new value.
  940. * This parameter can be one of the following values:
  941. * @arg TIM_ICPSC_DIV1: no prescaler
  942. * @arg TIM_ICPSC_DIV2: capture is done once every 2 events
  943. * @arg TIM_ICPSC_DIV4: capture is done once every 4 events
  944. * @arg TIM_ICPSC_DIV8: capture is done once every 8 events
  945. * @retval None
  946. */
  947. #define __HAL_TIM_SET_ICPRESCALER(__HANDLE__, __CHANNEL__, __ICPSC__) \
  948. do{ \
  949. TIM_RESET_ICPRESCALERVALUE((__HANDLE__), (__CHANNEL__)); \
  950. TIM_SET_ICPRESCALERVALUE((__HANDLE__), (__CHANNEL__), (__ICPSC__)); \
  951. } while(0U)
  952. /**
  953. * @brief Gets the TIM Input Capture prescaler on runtime
  954. * @param __HANDLE__ TIM handle.
  955. * @param __CHANNEL__ TIM Channels to be configured.
  956. * This parameter can be one of the following values:
  957. * @arg TIM_CHANNEL_1: get input capture 1 prescaler value
  958. * @arg TIM_CHANNEL_2: get input capture 2 prescaler value
  959. * @arg TIM_CHANNEL_3: get input capture 3 prescaler value
  960. * @arg TIM_CHANNEL_4: get input capture 4 prescaler value
  961. * @retval The input capture prescaler can be one of the following values:
  962. * @arg TIM_ICPSC_DIV1: no prescaler
  963. * @arg TIM_ICPSC_DIV2: capture is done once every 2 events
  964. * @arg TIM_ICPSC_DIV4: capture is done once every 4 events
  965. * @arg TIM_ICPSC_DIV8: capture is done once every 8 events
  966. */
  967. #define __HAL_TIM_GET_ICPRESCALER(__HANDLE__, __CHANNEL__) \
  968. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 & TIM_CCMR1_IC1PSC) :\
  969. ((__CHANNEL__) == TIM_CHANNEL_2) ? (((__HANDLE__)->Instance->CCMR1 & TIM_CCMR1_IC2PSC) >> 8U) :\
  970. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 & TIM_CCMR2_IC3PSC) :\
  971. (((__HANDLE__)->Instance->CCMR2 & TIM_CCMR2_IC4PSC)) >> 8U)
  972. /**
  973. * @brief Set the Update Request Source (URS) bit of the TIMx_CR1 register
  974. * @param __HANDLE__ TIM handle.
  975. * @note When the USR bit of the TIMx_CR1 register is set, only counter
  976. * overflow/underflow generates an update interrupt or DMA request (if
  977. * enabled)
  978. * @retval None
  979. */
  980. #define __HAL_TIM_URS_ENABLE(__HANDLE__) \
  981. ((__HANDLE__)->Instance->CR1|= (TIM_CR1_URS))
  982. /**
  983. * @brief Reset the Update Request Source (URS) bit of the TIMx_CR1 register
  984. * @param __HANDLE__ TIM handle.
  985. * @note When the USR bit of the TIMx_CR1 register is reset, any of the
  986. * following events generate an update interrupt or DMA request (if
  987. * enabled):
  988. * (+) Counter overflow/underflow
  989. * (+) Setting the UG bit
  990. * (+) Update generation through the slave mode controller
  991. * @retval None
  992. */
  993. #define __HAL_TIM_URS_DISABLE(__HANDLE__) \
  994. ((__HANDLE__)->Instance->CR1&=~(TIM_CR1_URS))
  995. /**
  996. * @brief Sets the TIM Capture x input polarity on runtime.
  997. * @param __HANDLE__ TIM handle.
  998. * @param __CHANNEL__ TIM Channels to be configured.
  999. * This parameter can be one of the following values:
  1000. * @arg TIM_CHANNEL_1: TIM Channel 1 selected
  1001. * @arg TIM_CHANNEL_2: TIM Channel 2 selected
  1002. * @arg TIM_CHANNEL_3: TIM Channel 3 selected
  1003. * @arg TIM_CHANNEL_4: TIM Channel 4 selected
  1004. * @param __POLARITY__ Polarity for TIx source
  1005. * @arg TIM_INPUTCHANNELPOLARITY_RISING: Rising Edge
  1006. * @arg TIM_INPUTCHANNELPOLARITY_FALLING: Falling Edge
  1007. * @arg TIM_INPUTCHANNELPOLARITY_BOTHEDGE: Rising and Falling Edge
  1008. * @retval None
  1009. */
  1010. #define __HAL_TIM_SET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__, __POLARITY__) \
  1011. do{ \
  1012. TIM_RESET_CAPTUREPOLARITY((__HANDLE__), (__CHANNEL__)); \
  1013. TIM_SET_CAPTUREPOLARITY((__HANDLE__), (__CHANNEL__), (__POLARITY__)); \
  1014. }while(0U)
  1015. /**
  1016. * @}
  1017. */
  1018. /* End of exported macros ----------------------------------------------------*/
  1019. /* Private Constants -----------------------------------------------------------*/
  1020. /** @defgroup TIM_Private_Constants TIM Private Constants
  1021. * @{
  1022. */
  1023. /* The counter of a timer instance is disabled only if all the CCx and CCxN
  1024. channels have been disabled */
  1025. #define TIM_CCER_CCxE_MASK ((uint32_t)(TIM_CCER_CC1E | TIM_CCER_CC2E | TIM_CCER_CC3E | TIM_CCER_CC4E))
  1026. #define TIM_CCER_CCxNE_MASK ((uint32_t)(TIM_CCER_CC1NE | TIM_CCER_CC2NE | TIM_CCER_CC3NE))
  1027. /**
  1028. * @}
  1029. */
  1030. /* End of private constants --------------------------------------------------*/
  1031. /* Private Macros -----------------------------------------------------------*/
  1032. /** @defgroup TIM_Private_Macros TIM Private Macros
  1033. * @{
  1034. */
  1035. #define IS_TIM_COUNTER_MODE(MODE) (((MODE) == TIM_COUNTERMODE_UP) || \
  1036. ((MODE) == TIM_COUNTERMODE_DOWN) || \
  1037. ((MODE) == TIM_COUNTERMODE_CENTERALIGNED1) || \
  1038. ((MODE) == TIM_COUNTERMODE_CENTERALIGNED2) || \
  1039. ((MODE) == TIM_COUNTERMODE_CENTERALIGNED3))
  1040. #define IS_TIM_CLOCKDIVISION_DIV(DIV) (((DIV) == TIM_CLOCKDIVISION_DIV1) || \
  1041. ((DIV) == TIM_CLOCKDIVISION_DIV2) || \
  1042. ((DIV) == TIM_CLOCKDIVISION_DIV4))
  1043. #define IS_TIM_AUTORELOAD_PRELOAD(PRELOAD) (((PRELOAD) == TIM_AUTORELOAD_PRELOAD_DISABLE) || \
  1044. ((PRELOAD) == TIM_AUTORELOAD_PRELOAD_ENABLE))
  1045. #define IS_TIM_FAST_STATE(STATE) (((STATE) == TIM_OCFAST_DISABLE) || \
  1046. ((STATE) == TIM_OCFAST_ENABLE))
  1047. #define IS_TIM_OC_POLARITY(POLARITY) (((POLARITY) == TIM_OCPOLARITY_HIGH) || \
  1048. ((POLARITY) == TIM_OCPOLARITY_LOW))
  1049. #define IS_TIM_OCN_POLARITY(POLARITY) (((POLARITY) == TIM_OCNPOLARITY_HIGH) || \
  1050. ((POLARITY) == TIM_OCNPOLARITY_LOW))
  1051. #define IS_TIM_OCIDLE_STATE(STATE) (((STATE) == TIM_OCIDLESTATE_SET) || \
  1052. ((STATE) == TIM_OCIDLESTATE_RESET))
  1053. #define IS_TIM_OCNIDLE_STATE(STATE) (((STATE) == TIM_OCNIDLESTATE_SET) || \
  1054. ((STATE) == TIM_OCNIDLESTATE_RESET))
  1055. #define IS_TIM_IC_POLARITY(POLARITY) (((POLARITY) == TIM_ICPOLARITY_RISING) || \
  1056. ((POLARITY) == TIM_ICPOLARITY_FALLING) || \
  1057. ((POLARITY) == TIM_ICPOLARITY_BOTHEDGE))
  1058. #define IS_TIM_IC_SELECTION(SELECTION) (((SELECTION) == TIM_ICSELECTION_DIRECTTI) || \
  1059. ((SELECTION) == TIM_ICSELECTION_INDIRECTTI) || \
  1060. ((SELECTION) == TIM_ICSELECTION_TRC))
  1061. #define IS_TIM_IC_PRESCALER(PRESCALER) (((PRESCALER) == TIM_ICPSC_DIV1) || \
  1062. ((PRESCALER) == TIM_ICPSC_DIV2) || \
  1063. ((PRESCALER) == TIM_ICPSC_DIV4) || \
  1064. ((PRESCALER) == TIM_ICPSC_DIV8))
  1065. #define IS_TIM_OPM_MODE(MODE) (((MODE) == TIM_OPMODE_SINGLE) || \
  1066. ((MODE) == TIM_OPMODE_REPETITIVE))
  1067. #define IS_TIM_ENCODER_MODE(MODE) (((MODE) == TIM_ENCODERMODE_TI1) || \
  1068. ((MODE) == TIM_ENCODERMODE_TI2) || \
  1069. ((MODE) == TIM_ENCODERMODE_TI12))
  1070. #define IS_TIM_DMA_SOURCE(SOURCE) ((((SOURCE) & 0xFFFF80FFU) == 0x00000000U) && ((SOURCE) != 0x00000000U))
  1071. #define IS_TIM_CLOCKSOURCE(CLOCK) (((CLOCK) == TIM_CLOCKSOURCE_INTERNAL) || \
  1072. ((CLOCK) == TIM_CLOCKSOURCE_ETRMODE2) || \
  1073. ((CLOCK) == TIM_CLOCKSOURCE_ITR0) || \
  1074. ((CLOCK) == TIM_CLOCKSOURCE_ITR1) || \
  1075. ((CLOCK) == TIM_CLOCKSOURCE_ITR2) || \
  1076. ((CLOCK) == TIM_CLOCKSOURCE_ITR3) || \
  1077. ((CLOCK) == TIM_CLOCKSOURCE_TI1ED) || \
  1078. ((CLOCK) == TIM_CLOCKSOURCE_TI1) || \
  1079. ((CLOCK) == TIM_CLOCKSOURCE_TI2) || \
  1080. ((CLOCK) == TIM_CLOCKSOURCE_ETRMODE1))
  1081. #define IS_TIM_CLOCKPOLARITY(POLARITY) (((POLARITY) == TIM_CLOCKPOLARITY_INVERTED) || \
  1082. ((POLARITY) == TIM_CLOCKPOLARITY_NONINVERTED) || \
  1083. ((POLARITY) == TIM_CLOCKPOLARITY_RISING) || \
  1084. ((POLARITY) == TIM_CLOCKPOLARITY_FALLING) || \
  1085. ((POLARITY) == TIM_CLOCKPOLARITY_BOTHEDGE))
  1086. #define IS_TIM_CLOCKPRESCALER(PRESCALER) (((PRESCALER) == TIM_CLOCKPRESCALER_DIV1) || \
  1087. ((PRESCALER) == TIM_CLOCKPRESCALER_DIV2) || \
  1088. ((PRESCALER) == TIM_CLOCKPRESCALER_DIV4) || \
  1089. ((PRESCALER) == TIM_CLOCKPRESCALER_DIV8))
  1090. #define IS_TIM_CLOCKFILTER(ICFILTER) ((ICFILTER) <= 0xFU)
  1091. #define IS_TIM_CLEARINPUT_POLARITY(POLARITY) (((POLARITY) == TIM_CLEARINPUTPOLARITY_INVERTED) || \
  1092. ((POLARITY) == TIM_CLEARINPUTPOLARITY_NONINVERTED))
  1093. #define IS_TIM_CLEARINPUT_PRESCALER(PRESCALER) (((PRESCALER) == TIM_CLEARINPUTPRESCALER_DIV1) || \
  1094. ((PRESCALER) == TIM_CLEARINPUTPRESCALER_DIV2) || \
  1095. ((PRESCALER) == TIM_CLEARINPUTPRESCALER_DIV4) || \
  1096. ((PRESCALER) == TIM_CLEARINPUTPRESCALER_DIV8))
  1097. #define IS_TIM_CLEARINPUT_FILTER(ICFILTER) ((ICFILTER) <= 0xFU)
  1098. #define IS_TIM_OSSR_STATE(STATE) (((STATE) == TIM_OSSR_ENABLE) || \
  1099. ((STATE) == TIM_OSSR_DISABLE))
  1100. #define IS_TIM_OSSI_STATE(STATE) (((STATE) == TIM_OSSI_ENABLE) || \
  1101. ((STATE) == TIM_OSSI_DISABLE))
  1102. #define IS_TIM_LOCK_LEVEL(LEVEL) (((LEVEL) == TIM_LOCKLEVEL_OFF) || \
  1103. ((LEVEL) == TIM_LOCKLEVEL_1) || \
  1104. ((LEVEL) == TIM_LOCKLEVEL_2) || \
  1105. ((LEVEL) == TIM_LOCKLEVEL_3))
  1106. #define IS_TIM_BREAK_STATE(STATE) (((STATE) == TIM_BREAK_ENABLE) || \
  1107. ((STATE) == TIM_BREAK_DISABLE))
  1108. #define IS_TIM_BREAK_POLARITY(POLARITY) (((POLARITY) == TIM_BREAKPOLARITY_LOW) || \
  1109. ((POLARITY) == TIM_BREAKPOLARITY_HIGH))
  1110. #define IS_TIM_AUTOMATIC_OUTPUT_STATE(STATE) (((STATE) == TIM_AUTOMATICOUTPUT_ENABLE) || \
  1111. ((STATE) == TIM_AUTOMATICOUTPUT_DISABLE))
  1112. #define IS_TIM_TRGO_SOURCE(SOURCE) (((SOURCE) == TIM_TRGO_RESET) || \
  1113. ((SOURCE) == TIM_TRGO_ENABLE) || \
  1114. ((SOURCE) == TIM_TRGO_UPDATE) || \
  1115. ((SOURCE) == TIM_TRGO_OC1) || \
  1116. ((SOURCE) == TIM_TRGO_OC1REF) || \
  1117. ((SOURCE) == TIM_TRGO_OC2REF) || \
  1118. ((SOURCE) == TIM_TRGO_OC3REF) || \
  1119. ((SOURCE) == TIM_TRGO_OC4REF))
  1120. #define IS_TIM_MSM_STATE(STATE) (((STATE) == TIM_MASTERSLAVEMODE_ENABLE) || \
  1121. ((STATE) == TIM_MASTERSLAVEMODE_DISABLE))
  1122. #define IS_TIM_TRIGGER_SELECTION(SELECTION) (((SELECTION) == TIM_TS_ITR0) || \
  1123. ((SELECTION) == TIM_TS_ITR1) || \
  1124. ((SELECTION) == TIM_TS_ITR2) || \
  1125. ((SELECTION) == TIM_TS_ITR3) || \
  1126. ((SELECTION) == TIM_TS_TI1F_ED) || \
  1127. ((SELECTION) == TIM_TS_TI1FP1) || \
  1128. ((SELECTION) == TIM_TS_TI2FP2) || \
  1129. ((SELECTION) == TIM_TS_ETRF))
  1130. #define IS_TIM_INTERNAL_TRIGGEREVENT_SELECTION(SELECTION) (((SELECTION) == TIM_TS_ITR0) || \
  1131. ((SELECTION) == TIM_TS_ITR1) || \
  1132. ((SELECTION) == TIM_TS_ITR2) || \
  1133. ((SELECTION) == TIM_TS_ITR3) || \
  1134. ((SELECTION) == TIM_TS_NONE))
  1135. #define IS_TIM_TRIGGERPOLARITY(POLARITY) (((POLARITY) == TIM_TRIGGERPOLARITY_INVERTED ) || \
  1136. ((POLARITY) == TIM_TRIGGERPOLARITY_NONINVERTED) || \
  1137. ((POLARITY) == TIM_TRIGGERPOLARITY_RISING ) || \
  1138. ((POLARITY) == TIM_TRIGGERPOLARITY_FALLING ) || \
  1139. ((POLARITY) == TIM_TRIGGERPOLARITY_BOTHEDGE ))
  1140. #define IS_TIM_TRIGGERPRESCALER(PRESCALER) (((PRESCALER) == TIM_TRIGGERPRESCALER_DIV1) || \
  1141. ((PRESCALER) == TIM_TRIGGERPRESCALER_DIV2) || \
  1142. ((PRESCALER) == TIM_TRIGGERPRESCALER_DIV4) || \
  1143. ((PRESCALER) == TIM_TRIGGERPRESCALER_DIV8))
  1144. #define IS_TIM_TRIGGERFILTER(ICFILTER) ((ICFILTER) <= 0xFU)
  1145. #define IS_TIM_TI1SELECTION(TI1SELECTION) (((TI1SELECTION) == TIM_TI1SELECTION_CH1) || \
  1146. ((TI1SELECTION) == TIM_TI1SELECTION_XORCOMBINATION))
  1147. #define IS_TIM_DMA_LENGTH(LENGTH) (((LENGTH) == TIM_DMABURSTLENGTH_1TRANSFER) || \
  1148. ((LENGTH) == TIM_DMABURSTLENGTH_2TRANSFERS) || \
  1149. ((LENGTH) == TIM_DMABURSTLENGTH_3TRANSFERS) || \
  1150. ((LENGTH) == TIM_DMABURSTLENGTH_4TRANSFERS) || \
  1151. ((LENGTH) == TIM_DMABURSTLENGTH_5TRANSFERS) || \
  1152. ((LENGTH) == TIM_DMABURSTLENGTH_6TRANSFERS) || \
  1153. ((LENGTH) == TIM_DMABURSTLENGTH_7TRANSFERS) || \
  1154. ((LENGTH) == TIM_DMABURSTLENGTH_8TRANSFERS) || \
  1155. ((LENGTH) == TIM_DMABURSTLENGTH_9TRANSFERS) || \
  1156. ((LENGTH) == TIM_DMABURSTLENGTH_10TRANSFERS) || \
  1157. ((LENGTH) == TIM_DMABURSTLENGTH_11TRANSFERS) || \
  1158. ((LENGTH) == TIM_DMABURSTLENGTH_12TRANSFERS) || \
  1159. ((LENGTH) == TIM_DMABURSTLENGTH_13TRANSFERS) || \
  1160. ((LENGTH) == TIM_DMABURSTLENGTH_14TRANSFERS) || \
  1161. ((LENGTH) == TIM_DMABURSTLENGTH_15TRANSFERS) || \
  1162. ((LENGTH) == TIM_DMABURSTLENGTH_16TRANSFERS) || \
  1163. ((LENGTH) == TIM_DMABURSTLENGTH_17TRANSFERS) || \
  1164. ((LENGTH) == TIM_DMABURSTLENGTH_18TRANSFERS))
  1165. #define IS_TIM_DMA_DATA_LENGTH(LENGTH) (((LENGTH) >= 0x1U) && ((LENGTH) < 0x10000U))
  1166. #define IS_TIM_IC_FILTER(ICFILTER) ((ICFILTER) <= 0xFU)
  1167. /** @brief Set TIM IC prescaler
  1168. * @param __HANDLE__ TIM handle
  1169. * @param __CHANNEL__ specifies TIM Channel
  1170. * @param __ICPSC__ specifies the prescaler value.
  1171. * @retval None
  1172. */
  1173. #define TIM_SET_ICPRESCALERVALUE(__HANDLE__, __CHANNEL__, __ICPSC__) \
  1174. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 |= (__ICPSC__)) :\
  1175. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 |= ((__ICPSC__) << 8U)) :\
  1176. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 |= (__ICPSC__)) :\
  1177. ((__HANDLE__)->Instance->CCMR2 |= ((__ICPSC__) << 8U)))
  1178. /** @brief Reset TIM IC prescaler
  1179. * @param __HANDLE__ TIM handle
  1180. * @param __CHANNEL__ specifies TIM Channel
  1181. * @retval None
  1182. */
  1183. #define TIM_RESET_ICPRESCALERVALUE(__HANDLE__, __CHANNEL__) \
  1184. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 &= (uint16_t)~TIM_CCMR1_IC1PSC) :\
  1185. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 &= (uint16_t)~TIM_CCMR1_IC2PSC) :\
  1186. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 &= (uint16_t)~TIM_CCMR2_IC3PSC) :\
  1187. ((__HANDLE__)->Instance->CCMR2 &= (uint16_t)~TIM_CCMR2_IC4PSC))
  1188. /** @brief Set TIM IC polarity
  1189. * @param __HANDLE__ TIM handle
  1190. * @param __CHANNEL__ specifies TIM Channel
  1191. * @param __POLARITY__ specifies TIM Channel Polarity
  1192. * @retval None
  1193. */
  1194. #define TIM_SET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__, __POLARITY__) \
  1195. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCER |= (__POLARITY__)) :\
  1196. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCER |= ((__POLARITY__) << 4U)) :\
  1197. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCER |= ((__POLARITY__) << 8U)) :\
  1198. ((__HANDLE__)->Instance->CCER |= (((__POLARITY__) << 12U))))
  1199. /** @brief Reset TIM IC polarity
  1200. * @param __HANDLE__ TIM handle
  1201. * @param __CHANNEL__ specifies TIM Channel
  1202. * @retval None
  1203. */
  1204. #define TIM_RESET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__) \
  1205. (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCER &= (uint16_t)~(TIM_CCER_CC1P | TIM_CCER_CC1NP)) :\
  1206. ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCER &= (uint16_t)~(TIM_CCER_CC2P | TIM_CCER_CC2NP)) :\
  1207. ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCER &= (uint16_t)~(TIM_CCER_CC3P | TIM_CCER_CC3NP)) :\
  1208. ((__HANDLE__)->Instance->CCER &= (uint16_t)~(TIM_CCER_CC4P | TIM_CCER_CC4NP)))
  1209. /**
  1210. * @}
  1211. */
  1212. /* End of private macros -----------------------------------------------------*/
  1213. /* Include TIM HAL Extended module */
  1214. #include "stm32f3xx_hal_tim_ex.h"
  1215. /* Exported functions --------------------------------------------------------*/
  1216. /** @addtogroup TIM_Exported_Functions
  1217. * @{
  1218. */
  1219. /** @addtogroup TIM_Exported_Functions_Group1
  1220. * @{
  1221. */
  1222. /* Time Base functions ********************************************************/
  1223. HAL_StatusTypeDef HAL_TIM_Base_Init(TIM_HandleTypeDef *htim);
  1224. HAL_StatusTypeDef HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim);
  1225. void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim);
  1226. void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim);
  1227. /* Blocking mode: Polling */
  1228. HAL_StatusTypeDef HAL_TIM_Base_Start(TIM_HandleTypeDef *htim);
  1229. HAL_StatusTypeDef HAL_TIM_Base_Stop(TIM_HandleTypeDef *htim);
  1230. /* Non-Blocking mode: Interrupt */
  1231. HAL_StatusTypeDef HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim);
  1232. HAL_StatusTypeDef HAL_TIM_Base_Stop_IT(TIM_HandleTypeDef *htim);
  1233. /* Non-Blocking mode: DMA */
  1234. HAL_StatusTypeDef HAL_TIM_Base_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
  1235. HAL_StatusTypeDef HAL_TIM_Base_Stop_DMA(TIM_HandleTypeDef *htim);
  1236. /**
  1237. * @}
  1238. */
  1239. /** @addtogroup TIM_Exported_Functions_Group2
  1240. * @{
  1241. */
  1242. /* Timer Output Compare functions **********************************************/
  1243. HAL_StatusTypeDef HAL_TIM_OC_Init(TIM_HandleTypeDef *htim);
  1244. HAL_StatusTypeDef HAL_TIM_OC_DeInit(TIM_HandleTypeDef *htim);
  1245. void HAL_TIM_OC_MspInit(TIM_HandleTypeDef *htim);
  1246. void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef *htim);
  1247. /* Blocking mode: Polling */
  1248. HAL_StatusTypeDef HAL_TIM_OC_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  1249. HAL_StatusTypeDef HAL_TIM_OC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  1250. /* Non-Blocking mode: Interrupt */
  1251. HAL_StatusTypeDef HAL_TIM_OC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1252. HAL_StatusTypeDef HAL_TIM_OC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1253. /* Non-Blocking mode: DMA */
  1254. HAL_StatusTypeDef HAL_TIM_OC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  1255. HAL_StatusTypeDef HAL_TIM_OC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  1256. /**
  1257. * @}
  1258. */
  1259. /** @addtogroup TIM_Exported_Functions_Group3
  1260. * @{
  1261. */
  1262. /* Timer PWM functions *********************************************************/
  1263. HAL_StatusTypeDef HAL_TIM_PWM_Init(TIM_HandleTypeDef *htim);
  1264. HAL_StatusTypeDef HAL_TIM_PWM_DeInit(TIM_HandleTypeDef *htim);
  1265. void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim);
  1266. void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef *htim);
  1267. /* Blocking mode: Polling */
  1268. HAL_StatusTypeDef HAL_TIM_PWM_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  1269. HAL_StatusTypeDef HAL_TIM_PWM_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  1270. /* Non-Blocking mode: Interrupt */
  1271. HAL_StatusTypeDef HAL_TIM_PWM_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1272. HAL_StatusTypeDef HAL_TIM_PWM_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1273. /* Non-Blocking mode: DMA */
  1274. HAL_StatusTypeDef HAL_TIM_PWM_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  1275. HAL_StatusTypeDef HAL_TIM_PWM_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  1276. /**
  1277. * @}
  1278. */
  1279. /** @addtogroup TIM_Exported_Functions_Group4
  1280. * @{
  1281. */
  1282. /* Timer Input Capture functions ***********************************************/
  1283. HAL_StatusTypeDef HAL_TIM_IC_Init(TIM_HandleTypeDef *htim);
  1284. HAL_StatusTypeDef HAL_TIM_IC_DeInit(TIM_HandleTypeDef *htim);
  1285. void HAL_TIM_IC_MspInit(TIM_HandleTypeDef *htim);
  1286. void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef *htim);
  1287. /* Blocking mode: Polling */
  1288. HAL_StatusTypeDef HAL_TIM_IC_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  1289. HAL_StatusTypeDef HAL_TIM_IC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  1290. /* Non-Blocking mode: Interrupt */
  1291. HAL_StatusTypeDef HAL_TIM_IC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1292. HAL_StatusTypeDef HAL_TIM_IC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1293. /* Non-Blocking mode: DMA */
  1294. HAL_StatusTypeDef HAL_TIM_IC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  1295. HAL_StatusTypeDef HAL_TIM_IC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  1296. /**
  1297. * @}
  1298. */
  1299. /** @addtogroup TIM_Exported_Functions_Group5
  1300. * @{
  1301. */
  1302. /* Timer One Pulse functions ***************************************************/
  1303. HAL_StatusTypeDef HAL_TIM_OnePulse_Init(TIM_HandleTypeDef *htim, uint32_t OnePulseMode);
  1304. HAL_StatusTypeDef HAL_TIM_OnePulse_DeInit(TIM_HandleTypeDef *htim);
  1305. void HAL_TIM_OnePulse_MspInit(TIM_HandleTypeDef *htim);
  1306. void HAL_TIM_OnePulse_MspDeInit(TIM_HandleTypeDef *htim);
  1307. /* Blocking mode: Polling */
  1308. HAL_StatusTypeDef HAL_TIM_OnePulse_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  1309. HAL_StatusTypeDef HAL_TIM_OnePulse_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  1310. /* Non-Blocking mode: Interrupt */
  1311. HAL_StatusTypeDef HAL_TIM_OnePulse_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  1312. HAL_StatusTypeDef HAL_TIM_OnePulse_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  1313. /**
  1314. * @}
  1315. */
  1316. /** @addtogroup TIM_Exported_Functions_Group6
  1317. * @{
  1318. */
  1319. /* Timer Encoder functions *****************************************************/
  1320. HAL_StatusTypeDef HAL_TIM_Encoder_Init(TIM_HandleTypeDef *htim, TIM_Encoder_InitTypeDef* sConfig);
  1321. HAL_StatusTypeDef HAL_TIM_Encoder_DeInit(TIM_HandleTypeDef *htim);
  1322. void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim);
  1323. void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef *htim);
  1324. /* Blocking mode: Polling */
  1325. HAL_StatusTypeDef HAL_TIM_Encoder_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  1326. HAL_StatusTypeDef HAL_TIM_Encoder_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  1327. /* Non-Blocking mode: Interrupt */
  1328. HAL_StatusTypeDef HAL_TIM_Encoder_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1329. HAL_StatusTypeDef HAL_TIM_Encoder_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  1330. /* Non-Blocking mode: DMA */
  1331. HAL_StatusTypeDef HAL_TIM_Encoder_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData1, uint32_t *pData2, uint16_t Length);
  1332. HAL_StatusTypeDef HAL_TIM_Encoder_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  1333. /**
  1334. * @}
  1335. */
  1336. /** @addtogroup TIM_Exported_Functions_Group7
  1337. * @{
  1338. */
  1339. /* Interrupt Handler functions **********************************************/
  1340. void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim);
  1341. /**
  1342. * @}
  1343. */
  1344. /** @addtogroup TIM_Exported_Functions_Group8
  1345. * @{
  1346. */
  1347. /* Control functions *********************************************************/
  1348. HAL_StatusTypeDef HAL_TIM_OC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OC_InitTypeDef* sConfig, uint32_t Channel);
  1349. HAL_StatusTypeDef HAL_TIM_PWM_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OC_InitTypeDef* sConfig, uint32_t Channel);
  1350. HAL_StatusTypeDef HAL_TIM_IC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_IC_InitTypeDef* sConfig, uint32_t Channel);
  1351. HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OnePulse_InitTypeDef* sConfig, uint32_t OutputChannel, uint32_t InputChannel);
  1352. HAL_StatusTypeDef HAL_TIM_ConfigOCrefClear(TIM_HandleTypeDef *htim, TIM_ClearInputConfigTypeDef * sClearInputConfig, uint32_t Channel);
  1353. HAL_StatusTypeDef HAL_TIM_ConfigClockSource(TIM_HandleTypeDef *htim, TIM_ClockConfigTypeDef * sClockSourceConfig);
  1354. HAL_StatusTypeDef HAL_TIM_ConfigTI1Input(TIM_HandleTypeDef *htim, uint32_t TI1_Selection);
  1355. HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchronization(TIM_HandleTypeDef *htim, TIM_SlaveConfigTypeDef * sSlaveConfig);
  1356. HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchronization_IT(TIM_HandleTypeDef *htim, TIM_SlaveConfigTypeDef * sSlaveConfig);
  1357. HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc, \
  1358. uint32_t *BurstBuffer, uint32_t BurstLength);
  1359. HAL_StatusTypeDef HAL_TIM_DMABurst_MultiWriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc, \
  1360. uint32_t *BurstBuffer, uint32_t BurstLength, uint32_t DataLength);
  1361. HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc);
  1362. HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc, \
  1363. uint32_t *BurstBuffer, uint32_t BurstLength);
  1364. HAL_StatusTypeDef HAL_TIM_DMABurst_MultiReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc, \
  1365. uint32_t *BurstBuffer, uint32_t BurstLength, uint32_t DataLength);
  1366. HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc);
  1367. HAL_StatusTypeDef HAL_TIM_GenerateEvent(TIM_HandleTypeDef *htim, uint32_t EventSource);
  1368. uint32_t HAL_TIM_ReadCapturedValue(TIM_HandleTypeDef *htim, uint32_t Channel);
  1369. /**
  1370. * @}
  1371. */
  1372. /** @addtogroup TIM_Exported_Functions_Group9
  1373. * @{
  1374. */
  1375. /* Callback in non blocking modes (Interrupt and DMA) *************************/
  1376. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim);
  1377. void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim);
  1378. void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim);
  1379. void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim);
  1380. void HAL_TIM_TriggerCallback(TIM_HandleTypeDef *htim);
  1381. void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim);
  1382. /**
  1383. * @}
  1384. */
  1385. /** @addtogroup TIM_Exported_Functions_Group10
  1386. * @{
  1387. */
  1388. /* Peripheral State functions **************************************************/
  1389. HAL_TIM_StateTypeDef HAL_TIM_Base_GetState(TIM_HandleTypeDef *htim);
  1390. HAL_TIM_StateTypeDef HAL_TIM_OC_GetState(TIM_HandleTypeDef *htim);
  1391. HAL_TIM_StateTypeDef HAL_TIM_PWM_GetState(TIM_HandleTypeDef *htim);
  1392. HAL_TIM_StateTypeDef HAL_TIM_IC_GetState(TIM_HandleTypeDef *htim);
  1393. HAL_TIM_StateTypeDef HAL_TIM_OnePulse_GetState(TIM_HandleTypeDef *htim);
  1394. HAL_TIM_StateTypeDef HAL_TIM_Encoder_GetState(TIM_HandleTypeDef *htim);
  1395. /**
  1396. * @}
  1397. */
  1398. /**
  1399. * @}
  1400. */
  1401. /* End of exported functions -------------------------------------------------*/
  1402. /* Private Functions --------------------------------------------------------*/
  1403. /** @addtogroup TIM_Private_Functions
  1404. * @{
  1405. */
  1406. void TIM_Base_SetConfig(TIM_TypeDef *TIMx, TIM_Base_InitTypeDef *Structure);
  1407. void TIM_TI1_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, uint32_t TIM_ICFilter);
  1408. void TIM_OC1_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config);
  1409. void TIM_OC2_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config);
  1410. void TIM_OC3_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config);
  1411. void TIM_OC4_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config);
  1412. void TIM_ETR_SetConfig(TIM_TypeDef* TIMx, uint32_t TIM_ExtTRGPrescaler,
  1413. uint32_t TIM_ExtTRGPolarity, uint32_t ExtTRGFilter);
  1414. void TIM_DMADelayPulseCplt(DMA_HandleTypeDef *hdma);
  1415. void TIM_DMAError(DMA_HandleTypeDef *hdma);
  1416. void TIM_DMACaptureCplt(DMA_HandleTypeDef *hdma);
  1417. void TIM_CCxChannelCmd(TIM_TypeDef* TIMx, uint32_t Channel, uint32_t ChannelState);
  1418. /**
  1419. * @}
  1420. */
  1421. /* End of private functions --------------------------------------------------*/
  1422. /**
  1423. * @}
  1424. */
  1425. /**
  1426. * @}
  1427. */
  1428. #ifdef __cplusplus
  1429. }
  1430. #endif
  1431. #endif /* __STM32F3xx_HAL_TIM_H */
  1432. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/