You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

4929 lines
222 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_ll_tim.h
  4. * @author MCD Application Team
  5. * @brief Header file of TIM LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef __STM32H7xx_LL_TIM_H
  21. #define __STM32H7xx_LL_TIM_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32h7xx.h"
  27. /** @addtogroup STM32H7xx_LL_Driver
  28. * @{
  29. */
  30. #if defined (TIM1) || defined (TIM2) || defined (TIM3) || defined (TIM4) || defined (TIM5) || defined (TIM6) || defined (TIM7) || defined (TIM8) || defined (TIM12) || defined (TIM13) || defined (TIM14) || defined (TIM15) || defined (TIM16) || defined (TIM17)
  31. /** @defgroup TIM_LL TIM
  32. * @{
  33. */
  34. /* Private types -------------------------------------------------------------*/
  35. /* Private variables ---------------------------------------------------------*/
  36. /** @defgroup TIM_LL_Private_Variables TIM Private Variables
  37. * @{
  38. */
  39. static const uint8_t OFFSET_TAB_CCMRx[] =
  40. {
  41. 0x00U, /* 0: TIMx_CH1 */
  42. 0x00U, /* 1: TIMx_CH1N */
  43. 0x00U, /* 2: TIMx_CH2 */
  44. 0x00U, /* 3: TIMx_CH2N */
  45. 0x04U, /* 4: TIMx_CH3 */
  46. 0x04U, /* 5: TIMx_CH3N */
  47. 0x04U, /* 6: TIMx_CH4 */
  48. 0x3CU, /* 7: TIMx_CH5 */
  49. 0x3CU /* 8: TIMx_CH6 */
  50. };
  51. static const uint8_t SHIFT_TAB_OCxx[] =
  52. {
  53. 0U, /* 0: OC1M, OC1FE, OC1PE */
  54. 0U, /* 1: - NA */
  55. 8U, /* 2: OC2M, OC2FE, OC2PE */
  56. 0U, /* 3: - NA */
  57. 0U, /* 4: OC3M, OC3FE, OC3PE */
  58. 0U, /* 5: - NA */
  59. 8U, /* 6: OC4M, OC4FE, OC4PE */
  60. 0U, /* 7: OC5M, OC5FE, OC5PE */
  61. 8U /* 8: OC6M, OC6FE, OC6PE */
  62. };
  63. static const uint8_t SHIFT_TAB_ICxx[] =
  64. {
  65. 0U, /* 0: CC1S, IC1PSC, IC1F */
  66. 0U, /* 1: - NA */
  67. 8U, /* 2: CC2S, IC2PSC, IC2F */
  68. 0U, /* 3: - NA */
  69. 0U, /* 4: CC3S, IC3PSC, IC3F */
  70. 0U, /* 5: - NA */
  71. 8U, /* 6: CC4S, IC4PSC, IC4F */
  72. 0U, /* 7: - NA */
  73. 0U /* 8: - NA */
  74. };
  75. static const uint8_t SHIFT_TAB_CCxP[] =
  76. {
  77. 0U, /* 0: CC1P */
  78. 2U, /* 1: CC1NP */
  79. 4U, /* 2: CC2P */
  80. 6U, /* 3: CC2NP */
  81. 8U, /* 4: CC3P */
  82. 10U, /* 5: CC3NP */
  83. 12U, /* 6: CC4P */
  84. 16U, /* 7: CC5P */
  85. 20U /* 8: CC6P */
  86. };
  87. static const uint8_t SHIFT_TAB_OISx[] =
  88. {
  89. 0U, /* 0: OIS1 */
  90. 1U, /* 1: OIS1N */
  91. 2U, /* 2: OIS2 */
  92. 3U, /* 3: OIS2N */
  93. 4U, /* 4: OIS3 */
  94. 5U, /* 5: OIS3N */
  95. 6U, /* 6: OIS4 */
  96. 8U, /* 7: OIS5 */
  97. 10U /* 8: OIS6 */
  98. };
  99. /**
  100. * @}
  101. */
  102. /* Private constants ---------------------------------------------------------*/
  103. /** @defgroup TIM_LL_Private_Constants TIM Private Constants
  104. * @{
  105. */
  106. #if defined(TIM_BREAK_INPUT_SUPPORT)
  107. /* Defines used for the bit position in the register and perform offsets */
  108. #define TIM_POSITION_BRK_SOURCE (POSITION_VAL(Source) & 0x1FUL)
  109. /* Generic bit definitions for TIMx_AF1 register */
  110. #define TIMx_AF1_BKINP TIM1_AF1_BKINP /*!< BRK BKIN input polarity */
  111. #define TIMx_AF1_ETRSEL TIM1_AF1_ETRSEL /*!< TIMx ETR source selection */
  112. #endif /* TIM_BREAK_INPUT_SUPPORT */
  113. /* Mask used to set the TDG[x:0] of the DTG bits of the TIMx_BDTR register */
  114. #define DT_DELAY_1 ((uint8_t)0x7F)
  115. #define DT_DELAY_2 ((uint8_t)0x3F)
  116. #define DT_DELAY_3 ((uint8_t)0x1F)
  117. #define DT_DELAY_4 ((uint8_t)0x1F)
  118. /* Mask used to set the DTG[7:5] bits of the DTG bits of the TIMx_BDTR register */
  119. #define DT_RANGE_1 ((uint8_t)0x00)
  120. #define DT_RANGE_2 ((uint8_t)0x80)
  121. #define DT_RANGE_3 ((uint8_t)0xC0)
  122. #define DT_RANGE_4 ((uint8_t)0xE0)
  123. /**
  124. * @}
  125. */
  126. /* Private macros ------------------------------------------------------------*/
  127. /** @defgroup TIM_LL_Private_Macros TIM Private Macros
  128. * @{
  129. */
  130. /** @brief Convert channel id into channel index.
  131. * @param __CHANNEL__ This parameter can be one of the following values:
  132. * @arg @ref LL_TIM_CHANNEL_CH1
  133. * @arg @ref LL_TIM_CHANNEL_CH1N
  134. * @arg @ref LL_TIM_CHANNEL_CH2
  135. * @arg @ref LL_TIM_CHANNEL_CH2N
  136. * @arg @ref LL_TIM_CHANNEL_CH3
  137. * @arg @ref LL_TIM_CHANNEL_CH3N
  138. * @arg @ref LL_TIM_CHANNEL_CH4
  139. * @arg @ref LL_TIM_CHANNEL_CH5
  140. * @arg @ref LL_TIM_CHANNEL_CH6
  141. * @retval none
  142. */
  143. #define TIM_GET_CHANNEL_INDEX( __CHANNEL__) \
  144. (((__CHANNEL__) == LL_TIM_CHANNEL_CH1) ? 0U :\
  145. ((__CHANNEL__) == LL_TIM_CHANNEL_CH1N) ? 1U :\
  146. ((__CHANNEL__) == LL_TIM_CHANNEL_CH2) ? 2U :\
  147. ((__CHANNEL__) == LL_TIM_CHANNEL_CH2N) ? 3U :\
  148. ((__CHANNEL__) == LL_TIM_CHANNEL_CH3) ? 4U :\
  149. ((__CHANNEL__) == LL_TIM_CHANNEL_CH3N) ? 5U :\
  150. ((__CHANNEL__) == LL_TIM_CHANNEL_CH4) ? 6U :\
  151. ((__CHANNEL__) == LL_TIM_CHANNEL_CH5) ? 7U : 8U)
  152. /** @brief Calculate the deadtime sampling period(in ps).
  153. * @param __TIMCLK__ timer input clock frequency (in Hz).
  154. * @param __CKD__ This parameter can be one of the following values:
  155. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  156. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  157. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  158. * @retval none
  159. */
  160. #define TIM_CALC_DTS(__TIMCLK__, __CKD__) \
  161. (((__CKD__) == LL_TIM_CLOCKDIVISION_DIV1) ? ((uint64_t)1000000000000U/(__TIMCLK__)) : \
  162. ((__CKD__) == LL_TIM_CLOCKDIVISION_DIV2) ? ((uint64_t)1000000000000U/((__TIMCLK__) >> 1U)) : \
  163. ((uint64_t)1000000000000U/((__TIMCLK__) >> 2U)))
  164. /**
  165. * @}
  166. */
  167. /* Exported types ------------------------------------------------------------*/
  168. #if defined(USE_FULL_LL_DRIVER)
  169. /** @defgroup TIM_LL_ES_INIT TIM Exported Init structure
  170. * @{
  171. */
  172. /**
  173. * @brief TIM Time Base configuration structure definition.
  174. */
  175. typedef struct
  176. {
  177. uint16_t Prescaler; /*!< Specifies the prescaler value used to divide the TIM clock.
  178. This parameter can be a number between Min_Data=0x0000 and Max_Data=0xFFFF.
  179. This feature can be modified afterwards using unitary function @ref LL_TIM_SetPrescaler().*/
  180. uint32_t CounterMode; /*!< Specifies the counter mode.
  181. This parameter can be a value of @ref TIM_LL_EC_COUNTERMODE.
  182. This feature can be modified afterwards using unitary function @ref LL_TIM_SetCounterMode().*/
  183. uint32_t Autoreload; /*!< Specifies the auto reload value to be loaded into the active
  184. Auto-Reload Register at the next update event.
  185. This parameter must be a number between Min_Data=0x0000 and Max_Data=0xFFFF.
  186. Some timer instances may support 32 bits counters. In that case this parameter must be a number between 0x0000 and 0xFFFFFFFF.
  187. This feature can be modified afterwards using unitary function @ref LL_TIM_SetAutoReload().*/
  188. uint32_t ClockDivision; /*!< Specifies the clock division.
  189. This parameter can be a value of @ref TIM_LL_EC_CLOCKDIVISION.
  190. This feature can be modified afterwards using unitary function @ref LL_TIM_SetClockDivision().*/
  191. uint8_t RepetitionCounter; /*!< Specifies the repetition counter value. Each time the RCR downcounter
  192. reaches zero, an update event is generated and counting restarts
  193. from the RCR value (N).
  194. This means in PWM mode that (N+1) corresponds to:
  195. - the number of PWM periods in edge-aligned mode
  196. - the number of half PWM period in center-aligned mode
  197. This parameter must be a number between 0x00 and 0xFF.
  198. This feature can be modified afterwards using unitary function @ref LL_TIM_SetRepetitionCounter().*/
  199. } LL_TIM_InitTypeDef;
  200. /**
  201. * @brief TIM Output Compare configuration structure definition.
  202. */
  203. typedef struct
  204. {
  205. uint32_t OCMode; /*!< Specifies the output mode.
  206. This parameter can be a value of @ref TIM_LL_EC_OCMODE.
  207. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetMode().*/
  208. uint32_t OCState; /*!< Specifies the TIM Output Compare state.
  209. This parameter can be a value of @ref TIM_LL_EC_OCSTATE.
  210. This feature can be modified afterwards using unitary functions @ref LL_TIM_CC_EnableChannel() or @ref LL_TIM_CC_DisableChannel().*/
  211. uint32_t OCNState; /*!< Specifies the TIM complementary Output Compare state.
  212. This parameter can be a value of @ref TIM_LL_EC_OCSTATE.
  213. This feature can be modified afterwards using unitary functions @ref LL_TIM_CC_EnableChannel() or @ref LL_TIM_CC_DisableChannel().*/
  214. uint32_t CompareValue; /*!< Specifies the Compare value to be loaded into the Capture Compare Register.
  215. This parameter can be a number between Min_Data=0x0000 and Max_Data=0xFFFF.
  216. This feature can be modified afterwards using unitary function LL_TIM_OC_SetCompareCHx (x=1..6).*/
  217. uint32_t OCPolarity; /*!< Specifies the output polarity.
  218. This parameter can be a value of @ref TIM_LL_EC_OCPOLARITY.
  219. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetPolarity().*/
  220. uint32_t OCNPolarity; /*!< Specifies the complementary output polarity.
  221. This parameter can be a value of @ref TIM_LL_EC_OCPOLARITY.
  222. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetPolarity().*/
  223. uint32_t OCIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
  224. This parameter can be a value of @ref TIM_LL_EC_OCIDLESTATE.
  225. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetIdleState().*/
  226. uint32_t OCNIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
  227. This parameter can be a value of @ref TIM_LL_EC_OCIDLESTATE.
  228. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetIdleState().*/
  229. } LL_TIM_OC_InitTypeDef;
  230. /**
  231. * @brief TIM Input Capture configuration structure definition.
  232. */
  233. typedef struct
  234. {
  235. uint32_t ICPolarity; /*!< Specifies the active edge of the input signal.
  236. This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
  237. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
  238. uint32_t ICActiveInput; /*!< Specifies the input.
  239. This parameter can be a value of @ref TIM_LL_EC_ACTIVEINPUT.
  240. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetActiveInput().*/
  241. uint32_t ICPrescaler; /*!< Specifies the Input Capture Prescaler.
  242. This parameter can be a value of @ref TIM_LL_EC_ICPSC.
  243. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
  244. uint32_t ICFilter; /*!< Specifies the input capture filter.
  245. This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
  246. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
  247. } LL_TIM_IC_InitTypeDef;
  248. /**
  249. * @brief TIM Encoder interface configuration structure definition.
  250. */
  251. typedef struct
  252. {
  253. uint32_t EncoderMode; /*!< Specifies the encoder resolution (x2 or x4).
  254. This parameter can be a value of @ref TIM_LL_EC_ENCODERMODE.
  255. This feature can be modified afterwards using unitary function @ref LL_TIM_SetEncoderMode().*/
  256. uint32_t IC1Polarity; /*!< Specifies the active edge of TI1 input.
  257. This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
  258. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
  259. uint32_t IC1ActiveInput; /*!< Specifies the TI1 input source
  260. This parameter can be a value of @ref TIM_LL_EC_ACTIVEINPUT.
  261. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetActiveInput().*/
  262. uint32_t IC1Prescaler; /*!< Specifies the TI1 input prescaler value.
  263. This parameter can be a value of @ref TIM_LL_EC_ICPSC.
  264. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
  265. uint32_t IC1Filter; /*!< Specifies the TI1 input filter.
  266. This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
  267. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
  268. uint32_t IC2Polarity; /*!< Specifies the active edge of TI2 input.
  269. This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
  270. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
  271. uint32_t IC2ActiveInput; /*!< Specifies the TI2 input source
  272. This parameter can be a value of @ref TIM_LL_EC_ACTIVEINPUT.
  273. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetActiveInput().*/
  274. uint32_t IC2Prescaler; /*!< Specifies the TI2 input prescaler value.
  275. This parameter can be a value of @ref TIM_LL_EC_ICPSC.
  276. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
  277. uint32_t IC2Filter; /*!< Specifies the TI2 input filter.
  278. This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
  279. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
  280. } LL_TIM_ENCODER_InitTypeDef;
  281. /**
  282. * @brief TIM Hall sensor interface configuration structure definition.
  283. */
  284. typedef struct
  285. {
  286. uint32_t IC1Polarity; /*!< Specifies the active edge of TI1 input.
  287. This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
  288. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
  289. uint32_t IC1Prescaler; /*!< Specifies the TI1 input prescaler value.
  290. Prescaler must be set to get a maximum counter period longer than the
  291. time interval between 2 consecutive changes on the Hall inputs.
  292. This parameter can be a value of @ref TIM_LL_EC_ICPSC.
  293. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
  294. uint32_t IC1Filter; /*!< Specifies the TI1 input filter.
  295. This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
  296. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
  297. uint32_t CommutationDelay; /*!< Specifies the compare value to be loaded into the Capture Compare Register.
  298. A positive pulse (TRGO event) is generated with a programmable delay every time
  299. a change occurs on the Hall inputs.
  300. This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF.
  301. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetCompareCH2().*/
  302. } LL_TIM_HALLSENSOR_InitTypeDef;
  303. /**
  304. * @brief BDTR (Break and Dead Time) structure definition
  305. */
  306. typedef struct
  307. {
  308. uint32_t OSSRState; /*!< Specifies the Off-State selection used in Run mode.
  309. This parameter can be a value of @ref TIM_LL_EC_OSSR
  310. This feature can be modified afterwards using unitary function @ref LL_TIM_SetOffStates()
  311. @note This bit-field cannot be modified as long as LOCK level 2 has been programmed. */
  312. uint32_t OSSIState; /*!< Specifies the Off-State used in Idle state.
  313. This parameter can be a value of @ref TIM_LL_EC_OSSI
  314. This feature can be modified afterwards using unitary function @ref LL_TIM_SetOffStates()
  315. @note This bit-field cannot be modified as long as LOCK level 2 has been programmed. */
  316. uint32_t LockLevel; /*!< Specifies the LOCK level parameters.
  317. This parameter can be a value of @ref TIM_LL_EC_LOCKLEVEL
  318. @note The LOCK bits can be written only once after the reset. Once the TIMx_BDTR register
  319. has been written, their content is frozen until the next reset.*/
  320. uint8_t DeadTime; /*!< Specifies the delay time between the switching-off and the
  321. switching-on of the outputs.
  322. This parameter can be a number between Min_Data = 0x00 and Max_Data = 0xFF.
  323. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetDeadTime()
  324. @note This bit-field can not be modified as long as LOCK level 1, 2 or 3 has been programmed. */
  325. uint16_t BreakState; /*!< Specifies whether the TIM Break input is enabled or not.
  326. This parameter can be a value of @ref TIM_LL_EC_BREAK_ENABLE
  327. This feature can be modified afterwards using unitary functions @ref LL_TIM_EnableBRK() or @ref LL_TIM_DisableBRK()
  328. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  329. uint32_t BreakPolarity; /*!< Specifies the TIM Break Input pin polarity.
  330. This parameter can be a value of @ref TIM_LL_EC_BREAK_POLARITY
  331. This feature can be modified afterwards using unitary function @ref LL_TIM_ConfigBRK()
  332. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  333. uint32_t BreakFilter; /*!< Specifies the TIM Break Filter.
  334. This parameter can be a value of @ref TIM_LL_EC_BREAK_FILTER
  335. This feature can be modified afterwards using unitary function @ref LL_TIM_ConfigBRK()
  336. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  337. uint32_t Break2State; /*!< Specifies whether the TIM Break2 input is enabled or not.
  338. This parameter can be a value of @ref TIM_LL_EC_BREAK2_ENABLE
  339. This feature can be modified afterwards using unitary functions @ref LL_TIM_EnableBRK2() or @ref LL_TIM_DisableBRK2()
  340. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  341. uint32_t Break2Polarity; /*!< Specifies the TIM Break2 Input pin polarity.
  342. This parameter can be a value of @ref TIM_LL_EC_BREAK2_POLARITY
  343. This feature can be modified afterwards using unitary function @ref LL_TIM_ConfigBRK2()
  344. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  345. uint32_t Break2Filter; /*!< Specifies the TIM Break2 Filter.
  346. This parameter can be a value of @ref TIM_LL_EC_BREAK2_FILTER
  347. This feature can be modified afterwards using unitary function @ref LL_TIM_ConfigBRK2()
  348. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  349. uint32_t AutomaticOutput; /*!< Specifies whether the TIM Automatic Output feature is enabled or not.
  350. This parameter can be a value of @ref TIM_LL_EC_AUTOMATICOUTPUT_ENABLE
  351. This feature can be modified afterwards using unitary functions @ref LL_TIM_EnableAutomaticOutput() or @ref LL_TIM_DisableAutomaticOutput()
  352. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  353. } LL_TIM_BDTR_InitTypeDef;
  354. /**
  355. * @}
  356. */
  357. #endif /* USE_FULL_LL_DRIVER */
  358. /* Exported constants --------------------------------------------------------*/
  359. /** @defgroup TIM_LL_Exported_Constants TIM Exported Constants
  360. * @{
  361. */
  362. /** @defgroup TIM_LL_EC_GET_FLAG Get Flags Defines
  363. * @brief Flags defines which can be used with LL_TIM_ReadReg function.
  364. * @{
  365. */
  366. #define LL_TIM_SR_UIF TIM_SR_UIF /*!< Update interrupt flag */
  367. #define LL_TIM_SR_CC1IF TIM_SR_CC1IF /*!< Capture/compare 1 interrupt flag */
  368. #define LL_TIM_SR_CC2IF TIM_SR_CC2IF /*!< Capture/compare 2 interrupt flag */
  369. #define LL_TIM_SR_CC3IF TIM_SR_CC3IF /*!< Capture/compare 3 interrupt flag */
  370. #define LL_TIM_SR_CC4IF TIM_SR_CC4IF /*!< Capture/compare 4 interrupt flag */
  371. #define LL_TIM_SR_CC5IF TIM_SR_CC5IF /*!< Capture/compare 5 interrupt flag */
  372. #define LL_TIM_SR_CC6IF TIM_SR_CC6IF /*!< Capture/compare 6 interrupt flag */
  373. #define LL_TIM_SR_COMIF TIM_SR_COMIF /*!< COM interrupt flag */
  374. #define LL_TIM_SR_TIF TIM_SR_TIF /*!< Trigger interrupt flag */
  375. #define LL_TIM_SR_BIF TIM_SR_BIF /*!< Break interrupt flag */
  376. #define LL_TIM_SR_B2IF TIM_SR_B2IF /*!< Second break interrupt flag */
  377. #define LL_TIM_SR_CC1OF TIM_SR_CC1OF /*!< Capture/Compare 1 overcapture flag */
  378. #define LL_TIM_SR_CC2OF TIM_SR_CC2OF /*!< Capture/Compare 2 overcapture flag */
  379. #define LL_TIM_SR_CC3OF TIM_SR_CC3OF /*!< Capture/Compare 3 overcapture flag */
  380. #define LL_TIM_SR_CC4OF TIM_SR_CC4OF /*!< Capture/Compare 4 overcapture flag */
  381. #define LL_TIM_SR_SBIF TIM_SR_SBIF /*!< System Break interrupt flag */
  382. /**
  383. * @}
  384. */
  385. #if defined(USE_FULL_LL_DRIVER)
  386. /** @defgroup TIM_LL_EC_BREAK_ENABLE Break Enable
  387. * @{
  388. */
  389. #define LL_TIM_BREAK_DISABLE 0x00000000U /*!< Break function disabled */
  390. #define LL_TIM_BREAK_ENABLE TIM_BDTR_BKE /*!< Break function enabled */
  391. /**
  392. * @}
  393. */
  394. /** @defgroup TIM_LL_EC_BREAK2_ENABLE Break2 Enable
  395. * @{
  396. */
  397. #define LL_TIM_BREAK2_DISABLE 0x00000000U /*!< Break2 function disabled */
  398. #define LL_TIM_BREAK2_ENABLE TIM_BDTR_BK2E /*!< Break2 function enabled */
  399. /**
  400. * @}
  401. */
  402. /** @defgroup TIM_LL_EC_AUTOMATICOUTPUT_ENABLE Automatic output enable
  403. * @{
  404. */
  405. #define LL_TIM_AUTOMATICOUTPUT_DISABLE 0x00000000U /*!< MOE can be set only by software */
  406. #define LL_TIM_AUTOMATICOUTPUT_ENABLE TIM_BDTR_AOE /*!< MOE can be set by software or automatically at the next update event */
  407. /**
  408. * @}
  409. */
  410. #endif /* USE_FULL_LL_DRIVER */
  411. /** @defgroup TIM_LL_EC_IT IT Defines
  412. * @brief IT defines which can be used with LL_TIM_ReadReg and LL_TIM_WriteReg functions.
  413. * @{
  414. */
  415. #define LL_TIM_DIER_UIE TIM_DIER_UIE /*!< Update interrupt enable */
  416. #define LL_TIM_DIER_CC1IE TIM_DIER_CC1IE /*!< Capture/compare 1 interrupt enable */
  417. #define LL_TIM_DIER_CC2IE TIM_DIER_CC2IE /*!< Capture/compare 2 interrupt enable */
  418. #define LL_TIM_DIER_CC3IE TIM_DIER_CC3IE /*!< Capture/compare 3 interrupt enable */
  419. #define LL_TIM_DIER_CC4IE TIM_DIER_CC4IE /*!< Capture/compare 4 interrupt enable */
  420. #define LL_TIM_DIER_COMIE TIM_DIER_COMIE /*!< COM interrupt enable */
  421. #define LL_TIM_DIER_TIE TIM_DIER_TIE /*!< Trigger interrupt enable */
  422. #define LL_TIM_DIER_BIE TIM_DIER_BIE /*!< Break interrupt enable */
  423. /**
  424. * @}
  425. */
  426. /** @defgroup TIM_LL_EC_UPDATESOURCE Update Source
  427. * @{
  428. */
  429. #define LL_TIM_UPDATESOURCE_REGULAR 0x00000000U /*!< Counter overflow/underflow, Setting the UG bit or Update generation through the slave mode controller generates an update request */
  430. #define LL_TIM_UPDATESOURCE_COUNTER TIM_CR1_URS /*!< Only counter overflow/underflow generates an update request */
  431. /**
  432. * @}
  433. */
  434. /** @defgroup TIM_LL_EC_ONEPULSEMODE One Pulse Mode
  435. * @{
  436. */
  437. #define LL_TIM_ONEPULSEMODE_SINGLE TIM_CR1_OPM /*!< Counter is not stopped at update event */
  438. #define LL_TIM_ONEPULSEMODE_REPETITIVE 0x00000000U /*!< Counter stops counting at the next update event */
  439. /**
  440. * @}
  441. */
  442. /** @defgroup TIM_LL_EC_COUNTERMODE Counter Mode
  443. * @{
  444. */
  445. #define LL_TIM_COUNTERMODE_UP 0x00000000U /*!<Counter used as upcounter */
  446. #define LL_TIM_COUNTERMODE_DOWN TIM_CR1_DIR /*!< Counter used as downcounter */
  447. #define LL_TIM_COUNTERMODE_CENTER_UP TIM_CR1_CMS_0 /*!< The counter counts up and down alternatively. Output compare interrupt flags of output channels are set only when the counter is counting down. */
  448. #define LL_TIM_COUNTERMODE_CENTER_DOWN TIM_CR1_CMS_1 /*!<The counter counts up and down alternatively. Output compare interrupt flags of output channels are set only when the counter is counting up */
  449. #define LL_TIM_COUNTERMODE_CENTER_UP_DOWN TIM_CR1_CMS /*!< The counter counts up and down alternatively. Output compare interrupt flags of output channels are set only when the counter is counting up or down. */
  450. /**
  451. * @}
  452. */
  453. /** @defgroup TIM_LL_EC_CLOCKDIVISION Clock Division
  454. * @{
  455. */
  456. #define LL_TIM_CLOCKDIVISION_DIV1 0x00000000U /*!< tDTS=tCK_INT */
  457. #define LL_TIM_CLOCKDIVISION_DIV2 TIM_CR1_CKD_0 /*!< tDTS=2*tCK_INT */
  458. #define LL_TIM_CLOCKDIVISION_DIV4 TIM_CR1_CKD_1 /*!< tDTS=4*tCK_INT */
  459. /**
  460. * @}
  461. */
  462. /** @defgroup TIM_LL_EC_COUNTERDIRECTION Counter Direction
  463. * @{
  464. */
  465. #define LL_TIM_COUNTERDIRECTION_UP 0x00000000U /*!< Timer counter counts up */
  466. #define LL_TIM_COUNTERDIRECTION_DOWN TIM_CR1_DIR /*!< Timer counter counts down */
  467. /**
  468. * @}
  469. */
  470. /** @defgroup TIM_LL_EC_CCUPDATESOURCE Capture Compare Update Source
  471. * @{
  472. */
  473. #define LL_TIM_CCUPDATESOURCE_COMG_ONLY 0x00000000U /*!< Capture/compare control bits are updated by setting the COMG bit only */
  474. #define LL_TIM_CCUPDATESOURCE_COMG_AND_TRGI TIM_CR2_CCUS /*!< Capture/compare control bits are updated by setting the COMG bit or when a rising edge occurs on trigger input (TRGI) */
  475. /**
  476. * @}
  477. */
  478. /** @defgroup TIM_LL_EC_CCDMAREQUEST Capture Compare DMA Request
  479. * @{
  480. */
  481. #define LL_TIM_CCDMAREQUEST_CC 0x00000000U /*!< CCx DMA request sent when CCx event occurs */
  482. #define LL_TIM_CCDMAREQUEST_UPDATE TIM_CR2_CCDS /*!< CCx DMA requests sent when update event occurs */
  483. /**
  484. * @}
  485. */
  486. /** @defgroup TIM_LL_EC_LOCKLEVEL Lock Level
  487. * @{
  488. */
  489. #define LL_TIM_LOCKLEVEL_OFF 0x00000000U /*!< LOCK OFF - No bit is write protected */
  490. #define LL_TIM_LOCKLEVEL_1 TIM_BDTR_LOCK_0 /*!< LOCK Level 1 */
  491. #define LL_TIM_LOCKLEVEL_2 TIM_BDTR_LOCK_1 /*!< LOCK Level 2 */
  492. #define LL_TIM_LOCKLEVEL_3 TIM_BDTR_LOCK /*!< LOCK Level 3 */
  493. /**
  494. * @}
  495. */
  496. /** @defgroup TIM_LL_EC_CHANNEL Channel
  497. * @{
  498. */
  499. #define LL_TIM_CHANNEL_CH1 TIM_CCER_CC1E /*!< Timer input/output channel 1 */
  500. #define LL_TIM_CHANNEL_CH1N TIM_CCER_CC1NE /*!< Timer complementary output channel 1 */
  501. #define LL_TIM_CHANNEL_CH2 TIM_CCER_CC2E /*!< Timer input/output channel 2 */
  502. #define LL_TIM_CHANNEL_CH2N TIM_CCER_CC2NE /*!< Timer complementary output channel 2 */
  503. #define LL_TIM_CHANNEL_CH3 TIM_CCER_CC3E /*!< Timer input/output channel 3 */
  504. #define LL_TIM_CHANNEL_CH3N TIM_CCER_CC3NE /*!< Timer complementary output channel 3 */
  505. #define LL_TIM_CHANNEL_CH4 TIM_CCER_CC4E /*!< Timer input/output channel 4 */
  506. #define LL_TIM_CHANNEL_CH5 TIM_CCER_CC5E /*!< Timer output channel 5 */
  507. #define LL_TIM_CHANNEL_CH6 TIM_CCER_CC6E /*!< Timer output channel 6 */
  508. /**
  509. * @}
  510. */
  511. #if defined(USE_FULL_LL_DRIVER)
  512. /** @defgroup TIM_LL_EC_OCSTATE Output Configuration State
  513. * @{
  514. */
  515. #define LL_TIM_OCSTATE_DISABLE 0x00000000U /*!< OCx is not active */
  516. #define LL_TIM_OCSTATE_ENABLE TIM_CCER_CC1E /*!< OCx signal is output on the corresponding output pin */
  517. /**
  518. * @}
  519. */
  520. #endif /* USE_FULL_LL_DRIVER */
  521. /** @defgroup TIM_LL_EC_OCMODE Output Configuration Mode
  522. * @{
  523. */
  524. #define LL_TIM_OCMODE_FROZEN 0x00000000U /*!<The comparison between the output compare register TIMx_CCRy and the counter TIMx_CNT has no effect on the output channel level */
  525. #define LL_TIM_OCMODE_ACTIVE TIM_CCMR1_OC1M_0 /*!<OCyREF is forced high on compare match*/
  526. #define LL_TIM_OCMODE_INACTIVE TIM_CCMR1_OC1M_1 /*!<OCyREF is forced low on compare match*/
  527. #define LL_TIM_OCMODE_TOGGLE (TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0) /*!<OCyREF toggles on compare match*/
  528. #define LL_TIM_OCMODE_FORCED_INACTIVE TIM_CCMR1_OC1M_2 /*!<OCyREF is forced low*/
  529. #define LL_TIM_OCMODE_FORCED_ACTIVE (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_0) /*!<OCyREF is forced high*/
  530. #define LL_TIM_OCMODE_PWM1 (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1) /*!<In upcounting, channel y is active as long as TIMx_CNT<TIMx_CCRy else inactive. In downcounting, channel y is inactive as long as TIMx_CNT>TIMx_CCRy else active.*/
  531. #define LL_TIM_OCMODE_PWM2 (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0) /*!<In upcounting, channel y is inactive as long as TIMx_CNT<TIMx_CCRy else active. In downcounting, channel y is active as long as TIMx_CNT>TIMx_CCRy else inactive*/
  532. #define LL_TIM_OCMODE_RETRIG_OPM1 TIM_CCMR1_OC1M_3 /*!<Retrigerrable OPM mode 1*/
  533. #define LL_TIM_OCMODE_RETRIG_OPM2 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_0) /*!<Retrigerrable OPM mode 2*/
  534. #define LL_TIM_OCMODE_COMBINED_PWM1 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_2) /*!<Combined PWM mode 1*/
  535. #define LL_TIM_OCMODE_COMBINED_PWM2 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_0 | TIM_CCMR1_OC1M_2) /*!<Combined PWM mode 2*/
  536. #define LL_TIM_OCMODE_ASSYMETRIC_PWM1 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2) /*!<Asymmetric PWM mode 1*/
  537. #define LL_TIM_OCMODE_ASSYMETRIC_PWM2 (TIM_CCMR1_OC1M_3 | TIM_CCMR1_OC1M) /*!<Asymmetric PWM mode 2*/
  538. /**
  539. * @}
  540. */
  541. /** @defgroup TIM_LL_EC_OCPOLARITY Output Configuration Polarity
  542. * @{
  543. */
  544. #define LL_TIM_OCPOLARITY_HIGH 0x00000000U /*!< OCxactive high*/
  545. #define LL_TIM_OCPOLARITY_LOW TIM_CCER_CC1P /*!< OCxactive low*/
  546. /**
  547. * @}
  548. */
  549. /** @defgroup TIM_LL_EC_OCIDLESTATE Output Configuration Idle State
  550. * @{
  551. */
  552. #define LL_TIM_OCIDLESTATE_LOW 0x00000000U /*!<OCx=0 (after a dead-time if OC is implemented) when MOE=0*/
  553. #define LL_TIM_OCIDLESTATE_HIGH TIM_CR2_OIS1 /*!<OCx=1 (after a dead-time if OC is implemented) when MOE=0*/
  554. /**
  555. * @}
  556. */
  557. /** @defgroup TIM_LL_EC_GROUPCH5 GROUPCH5
  558. * @{
  559. */
  560. #define LL_TIM_GROUPCH5_NONE 0x00000000U /*!< No effect of OC5REF on OC1REFC, OC2REFC and OC3REFC */
  561. #define LL_TIM_GROUPCH5_OC1REFC TIM_CCR5_GC5C1 /*!< OC1REFC is the logical AND of OC1REFC and OC5REF */
  562. #define LL_TIM_GROUPCH5_OC2REFC TIM_CCR5_GC5C2 /*!< OC2REFC is the logical AND of OC2REFC and OC5REF */
  563. #define LL_TIM_GROUPCH5_OC3REFC TIM_CCR5_GC5C3 /*!< OC3REFC is the logical AND of OC3REFC and OC5REF */
  564. /**
  565. * @}
  566. */
  567. /** @defgroup TIM_LL_EC_ACTIVEINPUT Active Input Selection
  568. * @{
  569. */
  570. #define LL_TIM_ACTIVEINPUT_DIRECTTI (TIM_CCMR1_CC1S_0 << 16U) /*!< ICx is mapped on TIx */
  571. #define LL_TIM_ACTIVEINPUT_INDIRECTTI (TIM_CCMR1_CC1S_1 << 16U) /*!< ICx is mapped on TIy */
  572. #define LL_TIM_ACTIVEINPUT_TRC (TIM_CCMR1_CC1S << 16U) /*!< ICx is mapped on TRC */
  573. /**
  574. * @}
  575. */
  576. /** @defgroup TIM_LL_EC_ICPSC Input Configuration Prescaler
  577. * @{
  578. */
  579. #define LL_TIM_ICPSC_DIV1 0x00000000U /*!< No prescaler, capture is done each time an edge is detected on the capture input */
  580. #define LL_TIM_ICPSC_DIV2 (TIM_CCMR1_IC1PSC_0 << 16U) /*!< Capture is done once every 2 events */
  581. #define LL_TIM_ICPSC_DIV4 (TIM_CCMR1_IC1PSC_1 << 16U) /*!< Capture is done once every 4 events */
  582. #define LL_TIM_ICPSC_DIV8 (TIM_CCMR1_IC1PSC << 16U) /*!< Capture is done once every 8 events */
  583. /**
  584. * @}
  585. */
  586. /** @defgroup TIM_LL_EC_IC_FILTER Input Configuration Filter
  587. * @{
  588. */
  589. #define LL_TIM_IC_FILTER_FDIV1 0x00000000U /*!< No filter, sampling is done at fDTS */
  590. #define LL_TIM_IC_FILTER_FDIV1_N2 (TIM_CCMR1_IC1F_0 << 16U) /*!< fSAMPLING=fCK_INT, N=2 */
  591. #define LL_TIM_IC_FILTER_FDIV1_N4 (TIM_CCMR1_IC1F_1 << 16U) /*!< fSAMPLING=fCK_INT, N=4 */
  592. #define LL_TIM_IC_FILTER_FDIV1_N8 ((TIM_CCMR1_IC1F_1 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fCK_INT, N=8 */
  593. #define LL_TIM_IC_FILTER_FDIV2_N6 (TIM_CCMR1_IC1F_2 << 16U) /*!< fSAMPLING=fDTS/2, N=6 */
  594. #define LL_TIM_IC_FILTER_FDIV2_N8 ((TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/2, N=8 */
  595. #define LL_TIM_IC_FILTER_FDIV4_N6 ((TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_1) << 16U) /*!< fSAMPLING=fDTS/4, N=6 */
  596. #define LL_TIM_IC_FILTER_FDIV4_N8 ((TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_1 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/4, N=8 */
  597. #define LL_TIM_IC_FILTER_FDIV8_N6 (TIM_CCMR1_IC1F_3 << 16U) /*!< fSAMPLING=fDTS/8, N=6 */
  598. #define LL_TIM_IC_FILTER_FDIV8_N8 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/8, N=8 */
  599. #define LL_TIM_IC_FILTER_FDIV16_N5 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_1) << 16U) /*!< fSAMPLING=fDTS/16, N=5 */
  600. #define LL_TIM_IC_FILTER_FDIV16_N6 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_1 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/16, N=6 */
  601. #define LL_TIM_IC_FILTER_FDIV16_N8 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_2) << 16U) /*!< fSAMPLING=fDTS/16, N=8 */
  602. #define LL_TIM_IC_FILTER_FDIV32_N5 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/32, N=5 */
  603. #define LL_TIM_IC_FILTER_FDIV32_N6 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_1) << 16U) /*!< fSAMPLING=fDTS/32, N=6 */
  604. #define LL_TIM_IC_FILTER_FDIV32_N8 (TIM_CCMR1_IC1F << 16U) /*!< fSAMPLING=fDTS/32, N=8 */
  605. /**
  606. * @}
  607. */
  608. /** @defgroup TIM_LL_EC_IC_POLARITY Input Configuration Polarity
  609. * @{
  610. */
  611. #define LL_TIM_IC_POLARITY_RISING 0x00000000U /*!< The circuit is sensitive to TIxFP1 rising edge, TIxFP1 is not inverted */
  612. #define LL_TIM_IC_POLARITY_FALLING TIM_CCER_CC1P /*!< The circuit is sensitive to TIxFP1 falling edge, TIxFP1 is inverted */
  613. #define LL_TIM_IC_POLARITY_BOTHEDGE (TIM_CCER_CC1P | TIM_CCER_CC1NP) /*!< The circuit is sensitive to both TIxFP1 rising and falling edges, TIxFP1 is not inverted */
  614. /**
  615. * @}
  616. */
  617. /** @defgroup TIM_LL_EC_CLOCKSOURCE Clock Source
  618. * @{
  619. */
  620. #define LL_TIM_CLOCKSOURCE_INTERNAL 0x00000000U /*!< The timer is clocked by the internal clock provided from the RCC */
  621. #define LL_TIM_CLOCKSOURCE_EXT_MODE1 (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0) /*!< Counter counts at each rising or falling edge on a selected input*/
  622. #define LL_TIM_CLOCKSOURCE_EXT_MODE2 TIM_SMCR_ECE /*!< Counter counts at each rising or falling edge on the external trigger input ETR */
  623. /**
  624. * @}
  625. */
  626. /** @defgroup TIM_LL_EC_ENCODERMODE Encoder Mode
  627. * @{
  628. */
  629. #define LL_TIM_ENCODERMODE_X2_TI1 TIM_SMCR_SMS_0 /*!< Quadrature encoder mode 1, x2 mode - Counter counts up/down on TI1FP1 edge depending on TI2FP2 level */
  630. #define LL_TIM_ENCODERMODE_X2_TI2 TIM_SMCR_SMS_1 /*!< Quadrature encoder mode 2, x2 mode - Counter counts up/down on TI2FP2 edge depending on TI1FP1 level */
  631. #define LL_TIM_ENCODERMODE_X4_TI12 (TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0) /*!< Quadrature encoder mode 3, x4 mode - Counter counts up/down on both TI1FP1 and TI2FP2 edges depending on the level of the other input */
  632. /**
  633. * @}
  634. */
  635. /** @defgroup TIM_LL_EC_TRGO Trigger Output
  636. * @{
  637. */
  638. #define LL_TIM_TRGO_RESET 0x00000000U /*!< UG bit from the TIMx_EGR register is used as trigger output */
  639. #define LL_TIM_TRGO_ENABLE TIM_CR2_MMS_0 /*!< Counter Enable signal (CNT_EN) is used as trigger output */
  640. #define LL_TIM_TRGO_UPDATE TIM_CR2_MMS_1 /*!< Update event is used as trigger output */
  641. #define LL_TIM_TRGO_CC1IF (TIM_CR2_MMS_1 | TIM_CR2_MMS_0) /*!< CC1 capture or a compare match is used as trigger output */
  642. #define LL_TIM_TRGO_OC1REF TIM_CR2_MMS_2 /*!< OC1REF signal is used as trigger output */
  643. #define LL_TIM_TRGO_OC2REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_0) /*!< OC2REF signal is used as trigger output */
  644. #define LL_TIM_TRGO_OC3REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_1) /*!< OC3REF signal is used as trigger output */
  645. #define LL_TIM_TRGO_OC4REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_1 | TIM_CR2_MMS_0) /*!< OC4REF signal is used as trigger output */
  646. /**
  647. * @}
  648. */
  649. /** @defgroup TIM_LL_EC_TRGO2 Trigger Output 2
  650. * @{
  651. */
  652. #define LL_TIM_TRGO2_RESET 0x00000000U /*!< UG bit from the TIMx_EGR register is used as trigger output 2 */
  653. #define LL_TIM_TRGO2_ENABLE TIM_CR2_MMS2_0 /*!< Counter Enable signal (CNT_EN) is used as trigger output 2 */
  654. #define LL_TIM_TRGO2_UPDATE TIM_CR2_MMS2_1 /*!< Update event is used as trigger output 2 */
  655. #define LL_TIM_TRGO2_CC1F (TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< CC1 capture or a compare match is used as trigger output 2 */
  656. #define LL_TIM_TRGO2_OC1 TIM_CR2_MMS2_2 /*!< OC1REF signal is used as trigger output 2 */
  657. #define LL_TIM_TRGO2_OC2 (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_0) /*!< OC2REF signal is used as trigger output 2 */
  658. #define LL_TIM_TRGO2_OC3 (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1) /*!< OC3REF signal is used as trigger output 2 */
  659. #define LL_TIM_TRGO2_OC4 (TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< OC4REF signal is used as trigger output 2 */
  660. #define LL_TIM_TRGO2_OC5 TIM_CR2_MMS2_3 /*!< OC5REF signal is used as trigger output 2 */
  661. #define LL_TIM_TRGO2_OC6 (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_0) /*!< OC6REF signal is used as trigger output 2 */
  662. #define LL_TIM_TRGO2_OC4_RISINGFALLING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_1) /*!< OC4REF rising or falling edges are used as trigger output 2 */
  663. #define LL_TIM_TRGO2_OC6_RISINGFALLING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< OC6REF rising or falling edges are used as trigger output 2 */
  664. #define LL_TIM_TRGO2_OC4_RISING_OC6_RISING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2) /*!< OC4REF or OC6REF rising edges are used as trigger output 2 */
  665. #define LL_TIM_TRGO2_OC4_RISING_OC6_FALLING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2 | TIM_CR2_MMS2_0) /*!< OC4REF rising or OC6REF falling edges are used as trigger output 2 */
  666. #define LL_TIM_TRGO2_OC5_RISING_OC6_RISING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2 |TIM_CR2_MMS2_1) /*!< OC5REF or OC6REF rising edges are used as trigger output 2 */
  667. #define LL_TIM_TRGO2_OC5_RISING_OC6_FALLING (TIM_CR2_MMS2_3 | TIM_CR2_MMS2_2 | TIM_CR2_MMS2_1 | TIM_CR2_MMS2_0) /*!< OC5REF rising or OC6REF falling edges are used as trigger output 2 */
  668. /**
  669. * @}
  670. */
  671. /** @defgroup TIM_LL_EC_SLAVEMODE Slave Mode
  672. * @{
  673. */
  674. #define LL_TIM_SLAVEMODE_DISABLED 0x00000000U /*!< Slave mode disabled */
  675. #define LL_TIM_SLAVEMODE_RESET TIM_SMCR_SMS_2 /*!< Reset Mode - Rising edge of the selected trigger input (TRGI) reinitializes the counter */
  676. #define LL_TIM_SLAVEMODE_GATED (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_0) /*!< Gated Mode - The counter clock is enabled when the trigger input (TRGI) is high */
  677. #define LL_TIM_SLAVEMODE_TRIGGER (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1) /*!< Trigger Mode - The counter starts at a rising edge of the trigger TRGI */
  678. #define LL_TIM_SLAVEMODE_COMBINED_RESETTRIGGER TIM_SMCR_SMS_3 /*!< Combined reset + trigger mode - Rising edge of the selected trigger input (TRGI) reinitializes the counter, generates an update of the registers and starts the counter */
  679. /**
  680. * @}
  681. */
  682. /** @defgroup TIM_LL_EC_TS Trigger Selection
  683. * @{
  684. */
  685. #define LL_TIM_TS_ITR0 0x00000000U /*!< Internal Trigger 0 (ITR0) is used as trigger input */
  686. #define LL_TIM_TS_ITR1 TIM_SMCR_TS_0 /*!< Internal Trigger 1 (ITR1) is used as trigger input */
  687. #define LL_TIM_TS_ITR2 TIM_SMCR_TS_1 /*!< Internal Trigger 2 (ITR2) is used as trigger input */
  688. #define LL_TIM_TS_ITR3 (TIM_SMCR_TS_0 | TIM_SMCR_TS_1) /*!< Internal Trigger 3 (ITR3) is used as trigger input */
  689. #define LL_TIM_TS_TI1F_ED TIM_SMCR_TS_2 /*!< TI1 Edge Detector (TI1F_ED) is used as trigger input */
  690. #define LL_TIM_TS_TI1FP1 (TIM_SMCR_TS_2 | TIM_SMCR_TS_0) /*!< Filtered Timer Input 1 (TI1FP1) is used as trigger input */
  691. #define LL_TIM_TS_TI2FP2 (TIM_SMCR_TS_2 | TIM_SMCR_TS_1) /*!< Filtered Timer Input 2 (TI12P2) is used as trigger input */
  692. #define LL_TIM_TS_ETRF (TIM_SMCR_TS_2 | TIM_SMCR_TS_1 | TIM_SMCR_TS_0) /*!< Filtered external Trigger (ETRF) is used as trigger input */
  693. #define LL_TIM_TS_ITR4 (TIM_SMCR_TS_3) /*!< Internal Trigger 4 (ITR4) is used as trigger input */
  694. #define LL_TIM_TS_ITR5 (TIM_SMCR_TS_0 | TIM_SMCR_TS_3) /*!< Internal Trigger 5 (ITR5) is used as trigger input */
  695. #define LL_TIM_TS_ITR6 (TIM_SMCR_TS_1 | TIM_SMCR_TS_3) /*!< Internal Trigger 6 (ITR6) is used as trigger input */
  696. #define LL_TIM_TS_ITR7 (TIM_SMCR_TS_0 | TIM_SMCR_TS_1 | TIM_SMCR_TS_3) /*!< Internal Trigger 7 (ITR7) is used as trigger input */
  697. #define LL_TIM_TS_ITR8 (TIM_SMCR_TS_2 | TIM_SMCR_TS_3) /*!< Internal Trigger 8 (ITR8) is used as trigger input */
  698. #define LL_TIM_TS_ITR9 (TIM_SMCR_TS_0 | TIM_SMCR_TS_2 | TIM_SMCR_TS_3) /*!< Internal Trigger 9 (ITR9) is used as trigger input */
  699. #define LL_TIM_TS_ITR10 (TIM_SMCR_TS_1 | TIM_SMCR_TS_2 | TIM_SMCR_TS_3) /*!< Internal Trigger 10 (ITR10) is used as trigger input */
  700. #define LL_TIM_TS_ITR11 (TIM_SMCR_TS_0 | TIM_SMCR_TS_1 | TIM_SMCR_TS_2 | TIM_SMCR_TS_3) /*!< Internal Trigger 11 (ITR11) is used as trigger input */
  701. #define LL_TIM_TS_ITR12 (TIM_SMCR_TS_4) /*!< Internal Trigger 12 (ITR12) is used as trigger input */
  702. #define LL_TIM_TS_ITR13 (TIM_SMCR_TS_0 | TIM_SMCR_TS_4) /*!< Internal Trigger 13 (ITR13) is used as trigger input */
  703. /**
  704. * @}
  705. */
  706. /** @defgroup TIM_LL_EC_ETR_POLARITY External Trigger Polarity
  707. * @{
  708. */
  709. #define LL_TIM_ETR_POLARITY_NONINVERTED 0x00000000U /*!< ETR is non-inverted, active at high level or rising edge */
  710. #define LL_TIM_ETR_POLARITY_INVERTED TIM_SMCR_ETP /*!< ETR is inverted, active at low level or falling edge */
  711. /**
  712. * @}
  713. */
  714. /** @defgroup TIM_LL_EC_ETR_PRESCALER External Trigger Prescaler
  715. * @{
  716. */
  717. #define LL_TIM_ETR_PRESCALER_DIV1 0x00000000U /*!< ETR prescaler OFF */
  718. #define LL_TIM_ETR_PRESCALER_DIV2 TIM_SMCR_ETPS_0 /*!< ETR frequency is divided by 2 */
  719. #define LL_TIM_ETR_PRESCALER_DIV4 TIM_SMCR_ETPS_1 /*!< ETR frequency is divided by 4 */
  720. #define LL_TIM_ETR_PRESCALER_DIV8 TIM_SMCR_ETPS /*!< ETR frequency is divided by 8 */
  721. /**
  722. * @}
  723. */
  724. /** @defgroup TIM_LL_EC_ETR_FILTER External Trigger Filter
  725. * @{
  726. */
  727. #define LL_TIM_ETR_FILTER_FDIV1 0x00000000U /*!< No filter, sampling is done at fDTS */
  728. #define LL_TIM_ETR_FILTER_FDIV1_N2 TIM_SMCR_ETF_0 /*!< fSAMPLING=fCK_INT, N=2 */
  729. #define LL_TIM_ETR_FILTER_FDIV1_N4 TIM_SMCR_ETF_1 /*!< fSAMPLING=fCK_INT, N=4 */
  730. #define LL_TIM_ETR_FILTER_FDIV1_N8 (TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fCK_INT, N=8 */
  731. #define LL_TIM_ETR_FILTER_FDIV2_N6 TIM_SMCR_ETF_2 /*!< fSAMPLING=fDTS/2, N=6 */
  732. #define LL_TIM_ETR_FILTER_FDIV2_N8 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/2, N=8 */
  733. #define LL_TIM_ETR_FILTER_FDIV4_N6 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/4, N=6 */
  734. #define LL_TIM_ETR_FILTER_FDIV4_N8 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/4, N=8 */
  735. #define LL_TIM_ETR_FILTER_FDIV8_N6 TIM_SMCR_ETF_3 /*!< fSAMPLING=fDTS/8, N=8 */
  736. #define LL_TIM_ETR_FILTER_FDIV8_N8 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/16, N=5 */
  737. #define LL_TIM_ETR_FILTER_FDIV16_N5 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/16, N=6 */
  738. #define LL_TIM_ETR_FILTER_FDIV16_N6 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/16, N=8 */
  739. #define LL_TIM_ETR_FILTER_FDIV16_N8 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2) /*!< fSAMPLING=fDTS/16, N=5 */
  740. #define LL_TIM_ETR_FILTER_FDIV32_N5 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/32, N=5 */
  741. #define LL_TIM_ETR_FILTER_FDIV32_N6 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/32, N=6 */
  742. #define LL_TIM_ETR_FILTER_FDIV32_N8 TIM_SMCR_ETF /*!< fSAMPLING=fDTS/32, N=8 */
  743. /**
  744. * @}
  745. */
  746. #define LL_TIM_TIM1_ETRSOURCE_GPIO 0x00000000U /* !< TIM1_ETR is connected to GPIO */
  747. #define LL_TIM_TIM1_ETRSOURCE_COMP1 TIM1_AF1_ETRSEL_0 /* !< TIM1_ETR is connected to COMP1 OUT */
  748. #define LL_TIM_TIM1_ETRSOURCE_COMP2 TIM1_AF1_ETRSEL_1 /* !< TIM1_ETR is connected to COMP2 OUT */
  749. #define LL_TIM_TIM1_ETRSOURCE_ADC1_AWD1 (TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /* !< TIM1_ETR is connected to ADC1 AWD1 */
  750. #define LL_TIM_TIM1_ETRSOURCE_ADC1_AWD2 (TIM1_AF1_ETRSEL_2) /* !< TIM1_ETR is connected to ADC1 AWD2 */
  751. #define LL_TIM_TIM1_ETRSOURCE_ADC1_AWD3 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_0) /* !< TIM1_ETR is connected to ADC1 AWD3 */
  752. #define LL_TIM_TIM1_ETRSOURCE_ADC3_AWD1 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1) /* !< TIM1_ETR is connected to ADC3 AWD1 */
  753. #define LL_TIM_TIM1_ETRSOURCE_ADC3_AWD2 (TIM1_AF1_ETRSEL_2 | TIM1_AF1_ETRSEL_1 | TIM1_AF1_ETRSEL_0) /* !< TIM1_ETR is connected to ADC3 AWD2 */
  754. #define LL_TIM_TIM1_ETRSOURCE_ADC3_AWD3 TIM1_AF1_ETRSEL_3 /* !< TIM1_ETR is connected to ADC3 AWD3 */
  755. #define LL_TIM_TIM8_ETRSOURCE_GPIO 0x00000000U /* !< TIM8_ETR is connected to GPIO */
  756. #define LL_TIM_TIM8_ETRSOURCE_COMP1 TIM8_AF1_ETRSEL_0 /* !< TIM8_ETR is connected to COMP1 OUT */
  757. #define LL_TIM_TIM8_ETRSOURCE_COMP2 TIM8_AF1_ETRSEL_1 /* !< TIM8_ETR is connected to COMP2 OUT */
  758. #define LL_TIM_TIM8_ETRSOURCE_ADC2_AWD1 (TIM8_AF1_ETRSEL_1 | TIM8_AF1_ETRSEL_0) /* !< TIM8_ETR is connected to ADC2 AWD1 */
  759. #define LL_TIM_TIM8_ETRSOURCE_ADC2_AWD2 (TIM8_AF1_ETRSEL_2) /* !< TIM8_ETR is connected to ADC2 AWD2 */
  760. #define LL_TIM_TIM8_ETRSOURCE_ADC2_AWD3 (TIM8_AF1_ETRSEL_2 | TIM8_AF1_ETRSEL_0) /* !< TIM8_ETR is connected to ADC2 AWD3 */
  761. #define LL_TIM_TIM8_ETRSOURCE_ADC3_AWD1 (TIM8_AF1_ETRSEL_2 | TIM8_AF1_ETRSEL_1) /* !< TIM8_ETR is connected to ADC3 AWD1 */
  762. #define LL_TIM_TIM8_ETRSOURCE_ADC3_AWD2 (TIM8_AF1_ETRSEL_2 | TIM8_AF1_ETRSEL_1 | TIM8_AF1_ETRSEL_0) /* !< TIM8_ETR is connected to ADC3 AWD2 */
  763. #define LL_TIM_TIM8_ETRSOURCE_ADC3_AWD3 TIM8_AF1_ETRSEL_3 /* !< TIM8_ETR is connected to ADC3 AWD3 */
  764. #define LL_TIM_TIM2_ETRSOURCE_GPIO 0x00000000U /* !< TIM2_ETR is connected to GPIO */
  765. #define LL_TIM_TIM2_ETRSOURCE_COMP1 (TIM2_AF1_ETRSEL_0) /* !< TIM2_ETR is connected to COMP1 OUT */
  766. #define LL_TIM_TIM2_ETRSOURCE_COMP2 (TIM2_AF1_ETRSEL_1) /* !< TIM2_ETR is connected to COMP2 OUT */
  767. #define LL_TIM_TIM2_ETRSOURCE_RCC_LSE (TIM2_AF1_ETRSEL_1 | TIM8_AF1_ETRSEL_0) /* !< TIM2_ETR is connected to RCC LSE */
  768. #define LL_TIM_TIM2_ETRSOURCE_SAI1_FSA TIM2_AF1_ETRSEL_2 /* !< TIM2_ETR is connected to SAI1 FS_A */
  769. #define LL_TIM_TIM2_ETRSOURCE_SAI1_FSB (TIM2_AF1_ETRSEL_2 | TIM8_AF1_ETRSEL_0) /* !< TIM2_ETR is connected to SAI1 FS_B */
  770. #define LL_TIM_TIM3_ETRSOURCE_GPIO 0x00000000U /* !< TIM3_ETR is connected to GPIO */
  771. #define LL_TIM_TIM3_ETRSOURCE_COMP1 TIM3_AF1_ETRSEL_0 /* !< TIM3_ETR is connected to COMP1 OUT */
  772. #define LL_TIM_TIM5_ETRSOURCE_GPIO 0x00000000U /* !< TIM5_ETR is connected to GPIO */
  773. #define LL_TIM_TIM5_ETRSOURCE_SAI2_FSA TIM5_AF1_ETRSEL_0 /* !< TIM5_ETR is connected to SAI2 FS_A */
  774. #define LL_TIM_TIM5_ETRSOURCE_SAI2_FSB TIM5_AF1_ETRSEL_1 /* !< TIM5_ETR is connected to SAI2 FS_B */
  775. #define LL_TIM_TIM5_ETRSOURCE_SAI4_FSA TIM5_AF1_ETRSEL_0 /* !< TIM5_ETR is connected to SAI4 FS_A */
  776. #define LL_TIM_TIM5_ETRSOURCE_SAI4_FSB TIM5_AF1_ETRSEL_1 /* !< TIM5_ETR is connected to SAI4 FS_B */
  777. #define LL_TIM_TIM23_ETRSOURCE_GPIO 0x00000000U /* !< TIM23_ETR is connected to GPIO */
  778. #define LL_TIM_TIM23_ETRSOURCE_COMP1 (TIM2_AF1_ETRSEL_0) /* !< TIM23_ETR is connected to COMP1 OUT */
  779. #define LL_TIM_TIM23_ETRSOURCE_COMP2 (TIM2_AF1_ETRSEL_1) /* !< TIM23_ETR is connected to COMP2 OUT */
  780. #define LL_TIM_TIM24_ETRSOURCE_GPIO 0x00000000U /* !< TIM24_ETR is connected to GPIO */
  781. #define LL_TIM_TIM24_ETRSOURCE_SAI4_FSA TIM5_AF1_ETRSEL_0 /* !< TIM24_ETR is connected to SAI4 FS_A */
  782. #define LL_TIM_TIM24_ETRSOURCE_SAI4_FSB TIM5_AF1_ETRSEL_1 /* !< TIM24_ETR is connected to SAI4 FS_B */
  783. #define LL_TIM_TIM24_ETRSOURCE_SAI1_FSA (TIM2_AF1_ETRSEL_1 | TIM8_AF1_ETRSEL_0) /* !< TIM24_ETR is connected to SAI1 FS_A */
  784. #define LL_TIM_TIM24_ETRSOURCE_SAI1_FSB TIM2_AF1_ETRSEL_2 /* !< TIM24_ETR is connected to SAI1 FS_B */
  785. /** @defgroup TIM_LL_EC_BREAK_POLARITY break polarity
  786. * @{
  787. */
  788. #define LL_TIM_BREAK_POLARITY_LOW 0x00000000U /*!< Break input BRK is active low */
  789. #define LL_TIM_BREAK_POLARITY_HIGH TIM_BDTR_BKP /*!< Break input BRK is active high */
  790. /**
  791. * @}
  792. */
  793. /** @defgroup TIM_LL_EC_BREAK_FILTER break filter
  794. * @{
  795. */
  796. #define LL_TIM_BREAK_FILTER_FDIV1 0x00000000U /*!< No filter, BRK acts asynchronously */
  797. #define LL_TIM_BREAK_FILTER_FDIV1_N2 0x00010000U /*!< fSAMPLING=fCK_INT, N=2 */
  798. #define LL_TIM_BREAK_FILTER_FDIV1_N4 0x00020000U /*!< fSAMPLING=fCK_INT, N=4 */
  799. #define LL_TIM_BREAK_FILTER_FDIV1_N8 0x00030000U /*!< fSAMPLING=fCK_INT, N=8 */
  800. #define LL_TIM_BREAK_FILTER_FDIV2_N6 0x00040000U /*!< fSAMPLING=fDTS/2, N=6 */
  801. #define LL_TIM_BREAK_FILTER_FDIV2_N8 0x00050000U /*!< fSAMPLING=fDTS/2, N=8 */
  802. #define LL_TIM_BREAK_FILTER_FDIV4_N6 0x00060000U /*!< fSAMPLING=fDTS/4, N=6 */
  803. #define LL_TIM_BREAK_FILTER_FDIV4_N8 0x00070000U /*!< fSAMPLING=fDTS/4, N=8 */
  804. #define LL_TIM_BREAK_FILTER_FDIV8_N6 0x00080000U /*!< fSAMPLING=fDTS/8, N=6 */
  805. #define LL_TIM_BREAK_FILTER_FDIV8_N8 0x00090000U /*!< fSAMPLING=fDTS/8, N=8 */
  806. #define LL_TIM_BREAK_FILTER_FDIV16_N5 0x000A0000U /*!< fSAMPLING=fDTS/16, N=5 */
  807. #define LL_TIM_BREAK_FILTER_FDIV16_N6 0x000B0000U /*!< fSAMPLING=fDTS/16, N=6 */
  808. #define LL_TIM_BREAK_FILTER_FDIV16_N8 0x000C0000U /*!< fSAMPLING=fDTS/16, N=8 */
  809. #define LL_TIM_BREAK_FILTER_FDIV32_N5 0x000D0000U /*!< fSAMPLING=fDTS/32, N=5 */
  810. #define LL_TIM_BREAK_FILTER_FDIV32_N6 0x000E0000U /*!< fSAMPLING=fDTS/32, N=6 */
  811. #define LL_TIM_BREAK_FILTER_FDIV32_N8 0x000F0000U /*!< fSAMPLING=fDTS/32, N=8 */
  812. /**
  813. * @}
  814. */
  815. /** @defgroup TIM_LL_EC_BREAK2_POLARITY BREAK2 POLARITY
  816. * @{
  817. */
  818. #define LL_TIM_BREAK2_POLARITY_LOW 0x00000000U /*!< Break input BRK2 is active low */
  819. #define LL_TIM_BREAK2_POLARITY_HIGH TIM_BDTR_BK2P /*!< Break input BRK2 is active high */
  820. /**
  821. * @}
  822. */
  823. /** @defgroup TIM_LL_EC_BREAK2_FILTER BREAK2 FILTER
  824. * @{
  825. */
  826. #define LL_TIM_BREAK2_FILTER_FDIV1 0x00000000U /*!< No filter, BRK acts asynchronously */
  827. #define LL_TIM_BREAK2_FILTER_FDIV1_N2 0x00100000U /*!< fSAMPLING=fCK_INT, N=2 */
  828. #define LL_TIM_BREAK2_FILTER_FDIV1_N4 0x00200000U /*!< fSAMPLING=fCK_INT, N=4 */
  829. #define LL_TIM_BREAK2_FILTER_FDIV1_N8 0x00300000U /*!< fSAMPLING=fCK_INT, N=8 */
  830. #define LL_TIM_BREAK2_FILTER_FDIV2_N6 0x00400000U /*!< fSAMPLING=fDTS/2, N=6 */
  831. #define LL_TIM_BREAK2_FILTER_FDIV2_N8 0x00500000U /*!< fSAMPLING=fDTS/2, N=8 */
  832. #define LL_TIM_BREAK2_FILTER_FDIV4_N6 0x00600000U /*!< fSAMPLING=fDTS/4, N=6 */
  833. #define LL_TIM_BREAK2_FILTER_FDIV4_N8 0x00700000U /*!< fSAMPLING=fDTS/4, N=8 */
  834. #define LL_TIM_BREAK2_FILTER_FDIV8_N6 0x00800000U /*!< fSAMPLING=fDTS/8, N=6 */
  835. #define LL_TIM_BREAK2_FILTER_FDIV8_N8 0x00900000U /*!< fSAMPLING=fDTS/8, N=8 */
  836. #define LL_TIM_BREAK2_FILTER_FDIV16_N5 0x00A00000U /*!< fSAMPLING=fDTS/16, N=5 */
  837. #define LL_TIM_BREAK2_FILTER_FDIV16_N6 0x00B00000U /*!< fSAMPLING=fDTS/16, N=6 */
  838. #define LL_TIM_BREAK2_FILTER_FDIV16_N8 0x00C00000U /*!< fSAMPLING=fDTS/16, N=8 */
  839. #define LL_TIM_BREAK2_FILTER_FDIV32_N5 0x00D00000U /*!< fSAMPLING=fDTS/32, N=5 */
  840. #define LL_TIM_BREAK2_FILTER_FDIV32_N6 0x00E00000U /*!< fSAMPLING=fDTS/32, N=6 */
  841. #define LL_TIM_BREAK2_FILTER_FDIV32_N8 0x00F00000U /*!< fSAMPLING=fDTS/32, N=8 */
  842. /**
  843. * @}
  844. */
  845. /** @defgroup TIM_LL_EC_OSSI OSSI
  846. * @{
  847. */
  848. #define LL_TIM_OSSI_DISABLE 0x00000000U /*!< When inactive, OCx/OCxN outputs are disabled */
  849. #define LL_TIM_OSSI_ENABLE TIM_BDTR_OSSI /*!< When inactive, OxC/OCxN outputs are first forced with their inactive level then forced to their idle level after the deadtime */
  850. /**
  851. * @}
  852. */
  853. /** @defgroup TIM_LL_EC_OSSR OSSR
  854. * @{
  855. */
  856. #define LL_TIM_OSSR_DISABLE 0x00000000U /*!< When inactive, OCx/OCxN outputs are disabled */
  857. #define LL_TIM_OSSR_ENABLE TIM_BDTR_OSSR /*!< When inactive, OC/OCN outputs are enabled with their inactive level as soon as CCxE=1 or CCxNE=1 */
  858. /**
  859. * @}
  860. */
  861. #if defined(TIM_BREAK_INPUT_SUPPORT)
  862. /** @defgroup TIM_LL_EC_BREAK_INPUT BREAK INPUT
  863. * @{
  864. */
  865. #define LL_TIM_BREAK_INPUT_BKIN 0x00000000U /*!< TIMx_BKIN input */
  866. #define LL_TIM_BREAK_INPUT_BKIN2 0x00000004U /*!< TIMx_BKIN2 input */
  867. /**
  868. * @}
  869. */
  870. /** @defgroup TIM_LL_EC_BKIN_SOURCE BKIN SOURCE
  871. * @{
  872. */
  873. #define LL_TIM_BKIN_SOURCE_BKIN TIM1_AF1_BKINE /*!< BKIN input from AF controller */
  874. #define LL_TIM_BKIN_SOURCE_BKCOMP1 TIM1_AF1_BKCMP1E /*!< internal signal: COMP1 output */
  875. #define LL_TIM_BKIN_SOURCE_BKCOMP2 TIM1_AF1_BKCMP2E /*!< internal signal: COMP2 output */
  876. #define LL_TIM_BKIN_SOURCE_DF1BK TIM1_AF1_BKDF1BK0E /*!< internal signal: DFSDM1 break output */
  877. /**
  878. * @}
  879. */
  880. /** @defgroup TIM_LL_EC_BKIN_POLARITY BKIN POLARITY
  881. * @{
  882. */
  883. #define LL_TIM_BKIN_POLARITY_LOW TIM1_AF1_BKINP /*!< BRK BKIN input is active low */
  884. #define LL_TIM_BKIN_POLARITY_HIGH 0x00000000U /*!< BRK BKIN input is active high */
  885. /**
  886. * @}
  887. */
  888. #endif /* TIM_BREAK_INPUT_SUPPORT */
  889. /** @defgroup TIM_LL_EC_DMABURST_BASEADDR DMA Burst Base Address
  890. * @{
  891. */
  892. #define LL_TIM_DMABURST_BASEADDR_CR1 0x00000000U /*!< TIMx_CR1 register is the DMA base address for DMA burst */
  893. #define LL_TIM_DMABURST_BASEADDR_CR2 TIM_DCR_DBA_0 /*!< TIMx_CR2 register is the DMA base address for DMA burst */
  894. #define LL_TIM_DMABURST_BASEADDR_SMCR TIM_DCR_DBA_1 /*!< TIMx_SMCR register is the DMA base address for DMA burst */
  895. #define LL_TIM_DMABURST_BASEADDR_DIER (TIM_DCR_DBA_1 | TIM_DCR_DBA_0) /*!< TIMx_DIER register is the DMA base address for DMA burst */
  896. #define LL_TIM_DMABURST_BASEADDR_SR TIM_DCR_DBA_2 /*!< TIMx_SR register is the DMA base address for DMA burst */
  897. #define LL_TIM_DMABURST_BASEADDR_EGR (TIM_DCR_DBA_2 | TIM_DCR_DBA_0) /*!< TIMx_EGR register is the DMA base address for DMA burst */
  898. #define LL_TIM_DMABURST_BASEADDR_CCMR1 (TIM_DCR_DBA_2 | TIM_DCR_DBA_1) /*!< TIMx_CCMR1 register is the DMA base address for DMA burst */
  899. #define LL_TIM_DMABURST_BASEADDR_CCMR2 (TIM_DCR_DBA_2 | TIM_DCR_DBA_1 | TIM_DCR_DBA_0) /*!< TIMx_CCMR2 register is the DMA base address for DMA burst */
  900. #define LL_TIM_DMABURST_BASEADDR_CCER TIM_DCR_DBA_3 /*!< TIMx_CCER register is the DMA base address for DMA burst */
  901. #define LL_TIM_DMABURST_BASEADDR_CNT (TIM_DCR_DBA_3 | TIM_DCR_DBA_0) /*!< TIMx_CNT register is the DMA base address for DMA burst */
  902. #define LL_TIM_DMABURST_BASEADDR_PSC (TIM_DCR_DBA_3 | TIM_DCR_DBA_1) /*!< TIMx_PSC register is the DMA base address for DMA burst */
  903. #define LL_TIM_DMABURST_BASEADDR_ARR (TIM_DCR_DBA_3 | TIM_DCR_DBA_1 | TIM_DCR_DBA_0) /*!< TIMx_ARR register is the DMA base address for DMA burst */
  904. #define LL_TIM_DMABURST_BASEADDR_RCR (TIM_DCR_DBA_3 | TIM_DCR_DBA_2) /*!< TIMx_RCR register is the DMA base address for DMA burst */
  905. #define LL_TIM_DMABURST_BASEADDR_CCR1 (TIM_DCR_DBA_3 | TIM_DCR_DBA_2 | TIM_DCR_DBA_0) /*!< TIMx_CCR1 register is the DMA base address for DMA burst */
  906. #define LL_TIM_DMABURST_BASEADDR_CCR2 (TIM_DCR_DBA_3 | TIM_DCR_DBA_2 | TIM_DCR_DBA_1) /*!< TIMx_CCR2 register is the DMA base address for DMA burst */
  907. #define LL_TIM_DMABURST_BASEADDR_CCR3 (TIM_DCR_DBA_3 | TIM_DCR_DBA_2 | TIM_DCR_DBA_1 | TIM_DCR_DBA_0) /*!< TIMx_CCR3 register is the DMA base address for DMA burst */
  908. #define LL_TIM_DMABURST_BASEADDR_CCR4 TIM_DCR_DBA_4 /*!< TIMx_CCR4 register is the DMA base address for DMA burst */
  909. #define LL_TIM_DMABURST_BASEADDR_BDTR (TIM_DCR_DBA_4 | TIM_DCR_DBA_0) /*!< TIMx_BDTR register is the DMA base address for DMA burst */
  910. #define LL_TIM_DMABURST_BASEADDR_CCMR3 (TIM_DCR_DBA_4 | TIM_DCR_DBA_2 | TIM_DCR_DBA_0) /*!< TIMx_CCMR3 register is the DMA base address for DMA burst */
  911. #define LL_TIM_DMABURST_BASEADDR_CCR5 (TIM_DCR_DBA_4 | TIM_DCR_DBA_2 | TIM_DCR_DBA_1) /*!< TIMx_CCR5 register is the DMA base address for DMA burst */
  912. #define LL_TIM_DMABURST_BASEADDR_CCR6 (TIM_DCR_DBA_4 | TIM_DCR_DBA_2 | TIM_DCR_DBA_1 | TIM_DCR_DBA_0) /*!< TIMx_CCR6 register is the DMA base address for DMA burst */
  913. #if defined(TIM_AF1_BKINE)&&defined(TIM_AF2_BKINE)
  914. #define LL_TIM_DMABURST_BASEADDR_AF1 (TIM_DCR_DBA_4 | TIM_DCR_DBA_3) /*!< TIMx_AF1 register is the DMA base address for DMA burst */
  915. #define LL_TIM_DMABURST_BASEADDR_AF2 (TIM_DCR_DBA_4 | TIM_DCR_DBA_3 | TIM_DCR_DBA_0) /*!< TIMx_AF2 register is the DMA base address for DMA burst */
  916. #endif /* TIM_AF1_BKINE && TIM_AF2_BKINE */
  917. #define LL_TIM_DMABURST_BASEADDR_TISEL (TIM_DCR_DBA_4 | TIM_DCR_DBA_3 | TIM_DCR_DBA_1) /*!< TIMx_TISEL register is the DMA base address for DMA burst */
  918. /**
  919. * @}
  920. */
  921. /** @defgroup TIM_LL_EC_DMABURST_LENGTH DMA Burst Length
  922. * @{
  923. */
  924. #define LL_TIM_DMABURST_LENGTH_1TRANSFER 0x00000000U /*!< Transfer is done to 1 register starting from the DMA burst base address */
  925. #define LL_TIM_DMABURST_LENGTH_2TRANSFERS TIM_DCR_DBL_0 /*!< Transfer is done to 2 registers starting from the DMA burst base address */
  926. #define LL_TIM_DMABURST_LENGTH_3TRANSFERS TIM_DCR_DBL_1 /*!< Transfer is done to 3 registers starting from the DMA burst base address */
  927. #define LL_TIM_DMABURST_LENGTH_4TRANSFERS (TIM_DCR_DBL_1 | TIM_DCR_DBL_0) /*!< Transfer is done to 4 registers starting from the DMA burst base address */
  928. #define LL_TIM_DMABURST_LENGTH_5TRANSFERS TIM_DCR_DBL_2 /*!< Transfer is done to 5 registers starting from the DMA burst base address */
  929. #define LL_TIM_DMABURST_LENGTH_6TRANSFERS (TIM_DCR_DBL_2 | TIM_DCR_DBL_0) /*!< Transfer is done to 6 registers starting from the DMA burst base address */
  930. #define LL_TIM_DMABURST_LENGTH_7TRANSFERS (TIM_DCR_DBL_2 | TIM_DCR_DBL_1) /*!< Transfer is done to 7 registers starting from the DMA burst base address */
  931. #define LL_TIM_DMABURST_LENGTH_8TRANSFERS (TIM_DCR_DBL_2 | TIM_DCR_DBL_1 | TIM_DCR_DBL_0) /*!< Transfer is done to 1 registers starting from the DMA burst base address */
  932. #define LL_TIM_DMABURST_LENGTH_9TRANSFERS TIM_DCR_DBL_3 /*!< Transfer is done to 9 registers starting from the DMA burst base address */
  933. #define LL_TIM_DMABURST_LENGTH_10TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_0) /*!< Transfer is done to 10 registers starting from the DMA burst base address */
  934. #define LL_TIM_DMABURST_LENGTH_11TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_1) /*!< Transfer is done to 11 registers starting from the DMA burst base address */
  935. #define LL_TIM_DMABURST_LENGTH_12TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_1 | TIM_DCR_DBL_0) /*!< Transfer is done to 12 registers starting from the DMA burst base address */
  936. #define LL_TIM_DMABURST_LENGTH_13TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_2) /*!< Transfer is done to 13 registers starting from the DMA burst base address */
  937. #define LL_TIM_DMABURST_LENGTH_14TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_2 | TIM_DCR_DBL_0) /*!< Transfer is done to 14 registers starting from the DMA burst base address */
  938. #define LL_TIM_DMABURST_LENGTH_15TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_2 | TIM_DCR_DBL_1) /*!< Transfer is done to 15 registers starting from the DMA burst base address */
  939. #define LL_TIM_DMABURST_LENGTH_16TRANSFERS (TIM_DCR_DBL_3 | TIM_DCR_DBL_2 | TIM_DCR_DBL_1 | TIM_DCR_DBL_0) /*!< Transfer is done to 16 registers starting from the DMA burst base address */
  940. #define LL_TIM_DMABURST_LENGTH_17TRANSFERS TIM_DCR_DBL_4 /*!< Transfer is done to 17 registers starting from the DMA burst base address */
  941. #define LL_TIM_DMABURST_LENGTH_18TRANSFERS (TIM_DCR_DBL_4 | TIM_DCR_DBL_0) /*!< Transfer is done to 18 registers starting from the DMA burst base address */
  942. /**
  943. * @}
  944. */
  945. /** @defgroup TIM_LL_EC_TIM1_TI1_RMP TIM1 Timer Input Ch1 Remap
  946. * @{
  947. */
  948. #define LL_TIM_TIM1_TI1_RMP_GPIO 0x00000000U /* !< TIM1 input 1 is connected to GPIO */
  949. #define LL_TIM_TIM1_TI1_RMP_COMP1 TIM_TISEL_TI1SEL_0 /* !< TIM1 input 1 is connected to COMP1 OUT */
  950. /**
  951. * @}
  952. */
  953. /** @defgroup TIM_LL_EC_TIM8_TI1_RMP TIM8 Timer Input Ch1 Remap
  954. * @{
  955. */
  956. #define LL_TIM_TIM8_TI1_RMP_GPIO 0x00000000U /* !< TIM8 input 1 is connected to GPIO */
  957. #define LL_TIM_TIM8_TI1_RMP_COMP2 TIM_TISEL_TI1SEL_0 /* !< TIM8 input 1 is connected to COMP2 OUT */
  958. /**
  959. * @}
  960. */
  961. /** @defgroup TIM_LL_EC_TIM2_TI4_RMP TIM2 Timer Input Ch4 Remap
  962. * @{
  963. */
  964. #define LL_TIM_TIM2_TI4_RMP_GPIO 0x00000000U /* !< TIM2 input 4 is connected to GPIO */
  965. #define LL_TIM_TIM2_TI4_RMP_COMP1 TIM_TISEL_TI4SEL_0 /* !< TIM2 input 4 is connected to COMP1 OUT */
  966. #define LL_TIM_TIM2_TI4_RMP_COMP2 TIM_TISEL_TI4SEL_1 /* !< TIM2 input 4 is connected to COMP2 OUT */
  967. #define LL_TIM_TIM2_TI4_RMP_COMP1_COMP2 (TIM_TISEL_TI4SEL_0 | TIM_TISEL_TI4SEL_1) /* !< TIM2 input 4 is connected to COMP2 OUT OR COMP2 OUT */
  968. /**
  969. * @}
  970. */
  971. /** @defgroup TIM_LL_EC_TIM3_TI1_RMP TIM3 Timer Input Ch1 Remap
  972. * @{
  973. */
  974. #define LL_TIM_TIM3_TI1_RMP_GPIO 0x00000000U /* !< TIM3 input 1 is connected to GPIO */
  975. #define LL_TIM_TIM3_TI1_RMP_COMP1 TIM_TISEL_TI1SEL_0 /* !< TIM3 input 1 is connected to COMP1 OUT */
  976. #define LL_TIM_TIM3_TI1_RMP_COMP2 TIM_TISEL_TI1SEL_1 /* !< TIM3 input 1 is connected to COMP2 OUT */
  977. #define LL_TIM_TIM3_TI1_RMP_COMP1_COMP2 (TIM_TISEL_TI1SEL_0 | TIM_TISEL_TI1SEL_1) /* !< TIM3 input 1 is connected to COMP1 OUT or COMP2 OUT */
  978. /**
  979. * @}
  980. */
  981. /** @defgroup TIM_LL_EC_TIM5_TI1_RMP TIM5 Timer Input Ch1 Remap
  982. * @{
  983. */
  984. #define LL_TIM_TIM5_TI1_RMP_GPIO 0x00000000U /* !< TIM5 input 1 is connected to GPIO */
  985. #define LL_TIM_TIM5_TI1_RMP_CAN_TMP TIM_TISEL_TI1SEL_0 /* !< TIM5 input 1 is connected to CAN TMP */
  986. #define LL_TIM_TIM5_TI1_RMP_CAN_RTP TIM_TISEL_TI1SEL_1 /* !< TIM5 input 1 is connected to CAN RTP */
  987. /**
  988. * @}
  989. */
  990. /** @defgroup TIM_LL_EC_TIM12_TI1_RMP TIM12 Timer Input Ch1 Remap
  991. * @{
  992. */
  993. #define LL_TIM_TIM12_TI1_RMP_GPIO 0x00000000U /* !< TIM12 input 1 is connected to GPIO */
  994. #define LL_TIM_TIM12_TI1_RMP_SPDIF_FS TIM_TISEL_TI1SEL_0 /* !< TIM12 input 1 is connected to SPDIF FS */
  995. /**
  996. * @}
  997. */
  998. /** @defgroup TIM_LL_EC_TIM15_TI1_RMP TIM15 Timer Input Ch1 Remap
  999. * @{
  1000. */
  1001. #define LL_TIM_TIM15_TI1_RMP_GPIO 0x00000000U /* !< TIM15 input 1 is connected to GPIO */
  1002. #define LL_TIM_TIM15_TI1_RMP_TIM2_CH1 TIM_TISEL_TI1SEL_0 /* !< TIM15 input 1 is connected to TIM2 CH1 */
  1003. #define LL_TIM_TIM15_TI1_RMP_TIM3_CH1 TIM_TISEL_TI1SEL_1 /* !< TIM15 input 1 is connected to TIM3 CH1 */
  1004. #define LL_TIM_TIM15_TI1_RMP_TIM4_CH1 (TIM_TISEL_TI1SEL_0 | TIM_TISEL_TI1SEL_1) /* !< TIM15 input 1 is connected to TIM4 CH1 */
  1005. #define LL_TIM_TIM15_TI1_RMP_RCC_LSE (TIM_TISEL_TI1SEL_2) /* !< TIM15 input 1 is connected to RCC LSE */
  1006. #define LL_TIM_TIM15_TI1_RMP_RCC_CSI (TIM_TISEL_TI1SEL_2 | TIM_TISEL_TI1SEL_0) /* !< TIM15 input 1 is connected to RCC CSI */
  1007. #define LL_TIM_TIM15_TI1_RMP_RCC_MCO2 (TIM_TISEL_TI1SEL_2 | TIM_TISEL_TI1SEL_1) /* !< TIM15 input 1 is connected to RCC MCO2 */
  1008. /**
  1009. * @}
  1010. */
  1011. /** @defgroup TIM_LL_EC_TIM15_TI2_RMP TIM15 Timer Input Ch2 Remap
  1012. * @{
  1013. */
  1014. #define LL_TIM_TIM15_TI2_RMP_GPIO 0x00000000U /* !< TIM15 input 2 is connected to GPIO */
  1015. #define LL_TIM_TIM15_TI2_RMP_TIM2_CH2 (TIM_TISEL_TI2SEL_0) /* !< TIM15 input 2 is connected to TIM2 CH2 */
  1016. #define LL_TIM_TIM15_TI2_RMP_TIM3_CH2 (TIM_TISEL_TI2SEL_1) /* !< TIM15 input 2 is connected to TIM3 CH2 */
  1017. #define LL_TIM_TIM15_TI2_RMP_TIM4_CH2 (TIM_TISEL_TI2SEL_0 | TIM_TISEL_TI2SEL_1) /* !< TIM15 input 2 is connected to TIM4 CH2 */
  1018. /**
  1019. * @}
  1020. */
  1021. /** @defgroup TIM_LL_EC_TIM16_TI1_RMP TIM16 Timer Input Ch1 Remap
  1022. * @{
  1023. */
  1024. #define LL_TIM_TIM16_TI1_RMP_GPIO 0x00000000U /* !< TIM16 input 1 is connected to GPIO */
  1025. #define LL_TIM_TIM16_TI1_RMP_RCC_LSI TIM_TISEL_TI1SEL_0 /* !< TIM16 input 1 is connected to RCC LSI */
  1026. #define LL_TIM_TIM16_TI1_RMP_RCC_LSE TIM_TISEL_TI1SEL_1 /* !< TIM16 input 1 is connected to RCC LSE */
  1027. #define LL_TIM_TIM16_TI1_RMP_WKUP_IT (TIM_TISEL_TI1SEL_0 | TIM_TISEL_TI1SEL_1) /* !< TIM16 input 1 is connected to WKUP_IT */
  1028. /**
  1029. * @}
  1030. */
  1031. /** @defgroup TIM_LL_EC_TIM17_TI1_RMP TIM17 Timer Input Ch1 Remap
  1032. * @{
  1033. */
  1034. #define LL_TIM_TIM17_TI1_RMP_GPIO 0x00000000U /* !< TIM17 input 1 is connected to GPIO */
  1035. #define LL_TIM_TIM17_TI1_RMP_SPDIF_FS TIM_TISEL_TI1SEL_0 /* !< TIM17 input 1 is connected to SPDIF FS */
  1036. #define LL_TIM_TIM17_TI1_RMP_RCC_HSE1MHZ TIM_TISEL_TI1SEL_1 /* !< TIM17 input 1 is connected to RCC HSE 1Mhz */
  1037. #define LL_TIM_TIM17_TI1_RMP_RCC_MCO1 (TIM_TISEL_TI1SEL_0 | TIM_TISEL_TI1SEL_1) /* !< TIM17 input 1 is connected to RCC MCO1 */
  1038. /**
  1039. * @}
  1040. */
  1041. /** @defgroup TIM_LL_EC_TIM23_TI4_RMP TIM23 Timer Input Ch4 Remap
  1042. * @{
  1043. */
  1044. #define LL_TIM_TIM23_TI4_RMP_GPIO 0x00000000U /* !< TIM23 input 4 is connected to GPIO */
  1045. #define LL_TIM_TIM23_TI4_RMP_COMP1 TIM_TISEL_TI4SEL_0 /* !< TIM23 input 4 is connected to COMP1 OUT */
  1046. #define LL_TIM_TIM23_TI4_RMP_COMP2 TIM_TISEL_TI4SEL_1 /* !< TIM23 input 4 is connected to COMP2 OUT */
  1047. #define LL_TIM_TIM23_TI4_RMP_COMP1_COMP2 (TIM_TISEL_TI4SEL_0 | TIM_TISEL_TI4SEL_1) /* !< TIM23 input 4 is connected to COMP1 OUT or COMP2 OUT */
  1048. /**
  1049. * @}
  1050. */
  1051. /** @defgroup TIM_LL_EC_TIM24_TI1_RMP TIM24 Timer Input Ch1 Remap
  1052. * @{
  1053. */
  1054. #define LL_TIM_TIM24_TI1_RMP_GPIO 0x00000000U /* !< TIM24 input 1 is connected to GPIO */
  1055. #define LL_TIM_TIM24_TI1_RMP_CAN_TMP TIM_TISEL_TI1SEL_0 /* !< TIM24 input 1 is connected to CAN TMP */
  1056. #define LL_TIM_TIM24_TI1_RMP_CAN_RTP TIM_TISEL_TI1SEL_1 /* !< TIM24 input 1 is connected to CAN RTP */
  1057. #define LL_TIM_TIM24_TI1_RMP_CAN_SOC (TIM_TISEL_TI4SEL_0 | TIM_TISEL_TI4SEL_1) /* !< TIM24 input 1 is connected to CAN SOC */
  1058. #if defined(TIM_BREAK_INPUT_SUPPORT)
  1059. /** Legacy definitions for compatibility purpose
  1060. @cond 0
  1061. */
  1062. #define LL_TIM_BKIN_SOURCE_DFBK LL_TIM_BKIN_SOURCE_DF1BK
  1063. /**
  1064. @endcond
  1065. */
  1066. #endif /* TIM_BREAK_INPUT_SUPPORT */
  1067. /**
  1068. * @}
  1069. */
  1070. /* Exported macro ------------------------------------------------------------*/
  1071. /** @defgroup TIM_LL_Exported_Macros TIM Exported Macros
  1072. * @{
  1073. */
  1074. /** @defgroup TIM_LL_EM_WRITE_READ Common Write and read registers Macros
  1075. * @{
  1076. */
  1077. /**
  1078. * @brief Write a value in TIM register.
  1079. * @param __INSTANCE__ TIM Instance
  1080. * @param __REG__ Register to be written
  1081. * @param __VALUE__ Value to be written in the register
  1082. * @retval None
  1083. */
  1084. #define LL_TIM_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG((__INSTANCE__)->__REG__, (__VALUE__))
  1085. /**
  1086. * @brief Read a value in TIM register.
  1087. * @param __INSTANCE__ TIM Instance
  1088. * @param __REG__ Register to be read
  1089. * @retval Register value
  1090. */
  1091. #define LL_TIM_ReadReg(__INSTANCE__, __REG__) READ_REG((__INSTANCE__)->__REG__)
  1092. /**
  1093. * @}
  1094. */
  1095. /** @defgroup TIM_LL_EM_Exported_Macros Exported_Macros
  1096. * @{
  1097. */
  1098. /**
  1099. * @brief HELPER macro retrieving the UIFCPY flag from the counter value.
  1100. * @note ex: @ref __LL_TIM_GETFLAG_UIFCPY (@ref LL_TIM_GetCounter ());
  1101. * @note Relevant only if UIF flag remapping has been enabled (UIF status bit is copied
  1102. * to TIMx_CNT register bit 31)
  1103. * @param __CNT__ Counter value
  1104. * @retval UIF status bit
  1105. */
  1106. #define __LL_TIM_GETFLAG_UIFCPY(__CNT__) \
  1107. (READ_BIT((__CNT__), TIM_CNT_UIFCPY) >> TIM_CNT_UIFCPY_Pos)
  1108. /**
  1109. * @brief HELPER macro calculating DTG[0:7] in the TIMx_BDTR register to achieve the requested dead time duration.
  1110. * @note ex: @ref __LL_TIM_CALC_DEADTIME (80000000, @ref LL_TIM_GetClockDivision (), 120);
  1111. * @param __TIMCLK__ timer input clock frequency (in Hz)
  1112. * @param __CKD__ This parameter can be one of the following values:
  1113. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  1114. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  1115. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  1116. * @param __DT__ deadtime duration (in ns)
  1117. * @retval DTG[0:7]
  1118. */
  1119. #define __LL_TIM_CALC_DEADTIME(__TIMCLK__, __CKD__, __DT__) \
  1120. ( (((uint64_t)((__DT__)*1000U)) < ((DT_DELAY_1+1U) * TIM_CALC_DTS((__TIMCLK__), (__CKD__)))) ? (uint8_t)(((uint64_t)((__DT__)*1000U) / TIM_CALC_DTS((__TIMCLK__), (__CKD__))) & DT_DELAY_1) : \
  1121. (((uint64_t)((__DT__)*1000U)) < ((64U + (DT_DELAY_2+1U)) * 2U * TIM_CALC_DTS((__TIMCLK__), (__CKD__)))) ? (uint8_t)(DT_RANGE_2 | ((uint8_t)((uint8_t)((((uint64_t)((__DT__)*1000U))/ TIM_CALC_DTS((__TIMCLK__), (__CKD__))) >> 1U) - (uint8_t) 64) & DT_DELAY_2)) :\
  1122. (((uint64_t)((__DT__)*1000U)) < ((32U + (DT_DELAY_3+1U)) * 8U * TIM_CALC_DTS((__TIMCLK__), (__CKD__)))) ? (uint8_t)(DT_RANGE_3 | ((uint8_t)((uint8_t)(((((uint64_t)(__DT__)*1000U))/ TIM_CALC_DTS((__TIMCLK__), (__CKD__))) >> 3U) - (uint8_t) 32) & DT_DELAY_3)) :\
  1123. (((uint64_t)((__DT__)*1000U)) < ((32U + (DT_DELAY_4+1U)) * 16U * TIM_CALC_DTS((__TIMCLK__), (__CKD__)))) ? (uint8_t)(DT_RANGE_4 | ((uint8_t)((uint8_t)(((((uint64_t)(__DT__)*1000U))/ TIM_CALC_DTS((__TIMCLK__), (__CKD__))) >> 4U) - (uint8_t) 32) & DT_DELAY_4)) :\
  1124. 0U)
  1125. /**
  1126. * @brief HELPER macro calculating the prescaler value to achieve the required counter clock frequency.
  1127. * @note ex: @ref __LL_TIM_CALC_PSC (80000000, 1000000);
  1128. * @param __TIMCLK__ timer input clock frequency (in Hz)
  1129. * @param __CNTCLK__ counter clock frequency (in Hz)
  1130. * @retval Prescaler value (between Min_Data=0 and Max_Data=65535)
  1131. */
  1132. #define __LL_TIM_CALC_PSC(__TIMCLK__, __CNTCLK__) \
  1133. (((__TIMCLK__) >= (__CNTCLK__)) ? (uint32_t)(((__TIMCLK__)/(__CNTCLK__)) - 1U) : 0U)
  1134. /**
  1135. * @brief HELPER macro calculating the auto-reload value to achieve the required output signal frequency.
  1136. * @note ex: @ref __LL_TIM_CALC_ARR (1000000, @ref LL_TIM_GetPrescaler (), 10000);
  1137. * @param __TIMCLK__ timer input clock frequency (in Hz)
  1138. * @param __PSC__ prescaler
  1139. * @param __FREQ__ output signal frequency (in Hz)
  1140. * @retval Auto-reload value (between Min_Data=0 and Max_Data=65535)
  1141. */
  1142. #define __LL_TIM_CALC_ARR(__TIMCLK__, __PSC__, __FREQ__) \
  1143. ((((__TIMCLK__)/((__PSC__) + 1U)) >= (__FREQ__)) ? (((__TIMCLK__)/((__FREQ__) * ((__PSC__) + 1U))) - 1U) : 0U)
  1144. /**
  1145. * @brief HELPER macro calculating the compare value required to achieve the required timer output compare active/inactive delay.
  1146. * @note ex: @ref __LL_TIM_CALC_DELAY (1000000, @ref LL_TIM_GetPrescaler (), 10);
  1147. * @param __TIMCLK__ timer input clock frequency (in Hz)
  1148. * @param __PSC__ prescaler
  1149. * @param __DELAY__ timer output compare active/inactive delay (in us)
  1150. * @retval Compare value (between Min_Data=0 and Max_Data=65535)
  1151. */
  1152. #define __LL_TIM_CALC_DELAY(__TIMCLK__, __PSC__, __DELAY__) \
  1153. ((uint32_t)(((uint64_t)(__TIMCLK__) * (uint64_t)(__DELAY__)) \
  1154. / ((uint64_t)1000000U * (uint64_t)((__PSC__) + 1U))))
  1155. /**
  1156. * @brief HELPER macro calculating the auto-reload value to achieve the required pulse duration (when the timer operates in one pulse mode).
  1157. * @note ex: @ref __LL_TIM_CALC_PULSE (1000000, @ref LL_TIM_GetPrescaler (), 10, 20);
  1158. * @param __TIMCLK__ timer input clock frequency (in Hz)
  1159. * @param __PSC__ prescaler
  1160. * @param __DELAY__ timer output compare active/inactive delay (in us)
  1161. * @param __PULSE__ pulse duration (in us)
  1162. * @retval Auto-reload value (between Min_Data=0 and Max_Data=65535)
  1163. */
  1164. #define __LL_TIM_CALC_PULSE(__TIMCLK__, __PSC__, __DELAY__, __PULSE__) \
  1165. ((uint32_t)(__LL_TIM_CALC_DELAY((__TIMCLK__), (__PSC__), (__PULSE__)) \
  1166. + __LL_TIM_CALC_DELAY((__TIMCLK__), (__PSC__), (__DELAY__))))
  1167. /**
  1168. * @brief HELPER macro retrieving the ratio of the input capture prescaler
  1169. * @note ex: @ref __LL_TIM_GET_ICPSC_RATIO (@ref LL_TIM_IC_GetPrescaler ());
  1170. * @param __ICPSC__ This parameter can be one of the following values:
  1171. * @arg @ref LL_TIM_ICPSC_DIV1
  1172. * @arg @ref LL_TIM_ICPSC_DIV2
  1173. * @arg @ref LL_TIM_ICPSC_DIV4
  1174. * @arg @ref LL_TIM_ICPSC_DIV8
  1175. * @retval Input capture prescaler ratio (1, 2, 4 or 8)
  1176. */
  1177. #define __LL_TIM_GET_ICPSC_RATIO(__ICPSC__) \
  1178. ((uint32_t)(0x01U << (((__ICPSC__) >> 16U) >> TIM_CCMR1_IC1PSC_Pos)))
  1179. /**
  1180. * @}
  1181. */
  1182. /**
  1183. * @}
  1184. */
  1185. /* Exported functions --------------------------------------------------------*/
  1186. /** @defgroup TIM_LL_Exported_Functions TIM Exported Functions
  1187. * @{
  1188. */
  1189. /** @defgroup TIM_LL_EF_Time_Base Time Base configuration
  1190. * @{
  1191. */
  1192. /**
  1193. * @brief Enable timer counter.
  1194. * @rmtoll CR1 CEN LL_TIM_EnableCounter
  1195. * @param TIMx Timer instance
  1196. * @retval None
  1197. */
  1198. __STATIC_INLINE void LL_TIM_EnableCounter(TIM_TypeDef *TIMx)
  1199. {
  1200. SET_BIT(TIMx->CR1, TIM_CR1_CEN);
  1201. }
  1202. /**
  1203. * @brief Disable timer counter.
  1204. * @rmtoll CR1 CEN LL_TIM_DisableCounter
  1205. * @param TIMx Timer instance
  1206. * @retval None
  1207. */
  1208. __STATIC_INLINE void LL_TIM_DisableCounter(TIM_TypeDef *TIMx)
  1209. {
  1210. CLEAR_BIT(TIMx->CR1, TIM_CR1_CEN);
  1211. }
  1212. /**
  1213. * @brief Indicates whether the timer counter is enabled.
  1214. * @rmtoll CR1 CEN LL_TIM_IsEnabledCounter
  1215. * @param TIMx Timer instance
  1216. * @retval State of bit (1 or 0).
  1217. */
  1218. __STATIC_INLINE uint32_t LL_TIM_IsEnabledCounter(TIM_TypeDef *TIMx)
  1219. {
  1220. return ((READ_BIT(TIMx->CR1, TIM_CR1_CEN) == (TIM_CR1_CEN)) ? 1UL : 0UL);
  1221. }
  1222. /**
  1223. * @brief Enable update event generation.
  1224. * @rmtoll CR1 UDIS LL_TIM_EnableUpdateEvent
  1225. * @param TIMx Timer instance
  1226. * @retval None
  1227. */
  1228. __STATIC_INLINE void LL_TIM_EnableUpdateEvent(TIM_TypeDef *TIMx)
  1229. {
  1230. CLEAR_BIT(TIMx->CR1, TIM_CR1_UDIS);
  1231. }
  1232. /**
  1233. * @brief Disable update event generation.
  1234. * @rmtoll CR1 UDIS LL_TIM_DisableUpdateEvent
  1235. * @param TIMx Timer instance
  1236. * @retval None
  1237. */
  1238. __STATIC_INLINE void LL_TIM_DisableUpdateEvent(TIM_TypeDef *TIMx)
  1239. {
  1240. SET_BIT(TIMx->CR1, TIM_CR1_UDIS);
  1241. }
  1242. /**
  1243. * @brief Indicates whether update event generation is enabled.
  1244. * @rmtoll CR1 UDIS LL_TIM_IsEnabledUpdateEvent
  1245. * @param TIMx Timer instance
  1246. * @retval Inverted state of bit (0 or 1).
  1247. */
  1248. __STATIC_INLINE uint32_t LL_TIM_IsEnabledUpdateEvent(TIM_TypeDef *TIMx)
  1249. {
  1250. return ((READ_BIT(TIMx->CR1, TIM_CR1_UDIS) == (uint32_t)RESET) ? 1UL : 0UL);
  1251. }
  1252. /**
  1253. * @brief Set update event source
  1254. * @note Update event source set to LL_TIM_UPDATESOURCE_REGULAR: any of the following events
  1255. * generate an update interrupt or DMA request if enabled:
  1256. * - Counter overflow/underflow
  1257. * - Setting the UG bit
  1258. * - Update generation through the slave mode controller
  1259. * @note Update event source set to LL_TIM_UPDATESOURCE_COUNTER: only counter
  1260. * overflow/underflow generates an update interrupt or DMA request if enabled.
  1261. * @rmtoll CR1 URS LL_TIM_SetUpdateSource
  1262. * @param TIMx Timer instance
  1263. * @param UpdateSource This parameter can be one of the following values:
  1264. * @arg @ref LL_TIM_UPDATESOURCE_REGULAR
  1265. * @arg @ref LL_TIM_UPDATESOURCE_COUNTER
  1266. * @retval None
  1267. */
  1268. __STATIC_INLINE void LL_TIM_SetUpdateSource(TIM_TypeDef *TIMx, uint32_t UpdateSource)
  1269. {
  1270. MODIFY_REG(TIMx->CR1, TIM_CR1_URS, UpdateSource);
  1271. }
  1272. /**
  1273. * @brief Get actual event update source
  1274. * @rmtoll CR1 URS LL_TIM_GetUpdateSource
  1275. * @param TIMx Timer instance
  1276. * @retval Returned value can be one of the following values:
  1277. * @arg @ref LL_TIM_UPDATESOURCE_REGULAR
  1278. * @arg @ref LL_TIM_UPDATESOURCE_COUNTER
  1279. */
  1280. __STATIC_INLINE uint32_t LL_TIM_GetUpdateSource(TIM_TypeDef *TIMx)
  1281. {
  1282. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_URS));
  1283. }
  1284. /**
  1285. * @brief Set one pulse mode (one shot v.s. repetitive).
  1286. * @rmtoll CR1 OPM LL_TIM_SetOnePulseMode
  1287. * @param TIMx Timer instance
  1288. * @param OnePulseMode This parameter can be one of the following values:
  1289. * @arg @ref LL_TIM_ONEPULSEMODE_SINGLE
  1290. * @arg @ref LL_TIM_ONEPULSEMODE_REPETITIVE
  1291. * @retval None
  1292. */
  1293. __STATIC_INLINE void LL_TIM_SetOnePulseMode(TIM_TypeDef *TIMx, uint32_t OnePulseMode)
  1294. {
  1295. MODIFY_REG(TIMx->CR1, TIM_CR1_OPM, OnePulseMode);
  1296. }
  1297. /**
  1298. * @brief Get actual one pulse mode.
  1299. * @rmtoll CR1 OPM LL_TIM_GetOnePulseMode
  1300. * @param TIMx Timer instance
  1301. * @retval Returned value can be one of the following values:
  1302. * @arg @ref LL_TIM_ONEPULSEMODE_SINGLE
  1303. * @arg @ref LL_TIM_ONEPULSEMODE_REPETITIVE
  1304. */
  1305. __STATIC_INLINE uint32_t LL_TIM_GetOnePulseMode(TIM_TypeDef *TIMx)
  1306. {
  1307. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_OPM));
  1308. }
  1309. /**
  1310. * @brief Set the timer counter counting mode.
  1311. * @note Macro IS_TIM_COUNTER_MODE_SELECT_INSTANCE(TIMx) can be used to
  1312. * check whether or not the counter mode selection feature is supported
  1313. * by a timer instance.
  1314. * @note Switching from Center Aligned counter mode to Edge counter mode (or reverse)
  1315. * requires a timer reset to avoid unexpected direction
  1316. * due to DIR bit readonly in center aligned mode.
  1317. * @rmtoll CR1 DIR LL_TIM_SetCounterMode\n
  1318. * CR1 CMS LL_TIM_SetCounterMode
  1319. * @param TIMx Timer instance
  1320. * @param CounterMode This parameter can be one of the following values:
  1321. * @arg @ref LL_TIM_COUNTERMODE_UP
  1322. * @arg @ref LL_TIM_COUNTERMODE_DOWN
  1323. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP
  1324. * @arg @ref LL_TIM_COUNTERMODE_CENTER_DOWN
  1325. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP_DOWN
  1326. * @retval None
  1327. */
  1328. __STATIC_INLINE void LL_TIM_SetCounterMode(TIM_TypeDef *TIMx, uint32_t CounterMode)
  1329. {
  1330. MODIFY_REG(TIMx->CR1, (TIM_CR1_DIR | TIM_CR1_CMS), CounterMode);
  1331. }
  1332. /**
  1333. * @brief Get actual counter mode.
  1334. * @note Macro IS_TIM_COUNTER_MODE_SELECT_INSTANCE(TIMx) can be used to
  1335. * check whether or not the counter mode selection feature is supported
  1336. * by a timer instance.
  1337. * @rmtoll CR1 DIR LL_TIM_GetCounterMode\n
  1338. * CR1 CMS LL_TIM_GetCounterMode
  1339. * @param TIMx Timer instance
  1340. * @retval Returned value can be one of the following values:
  1341. * @arg @ref LL_TIM_COUNTERMODE_UP
  1342. * @arg @ref LL_TIM_COUNTERMODE_DOWN
  1343. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP
  1344. * @arg @ref LL_TIM_COUNTERMODE_CENTER_DOWN
  1345. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP_DOWN
  1346. */
  1347. __STATIC_INLINE uint32_t LL_TIM_GetCounterMode(TIM_TypeDef *TIMx)
  1348. {
  1349. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_DIR | TIM_CR1_CMS));
  1350. }
  1351. /**
  1352. * @brief Enable auto-reload (ARR) preload.
  1353. * @rmtoll CR1 ARPE LL_TIM_EnableARRPreload
  1354. * @param TIMx Timer instance
  1355. * @retval None
  1356. */
  1357. __STATIC_INLINE void LL_TIM_EnableARRPreload(TIM_TypeDef *TIMx)
  1358. {
  1359. SET_BIT(TIMx->CR1, TIM_CR1_ARPE);
  1360. }
  1361. /**
  1362. * @brief Disable auto-reload (ARR) preload.
  1363. * @rmtoll CR1 ARPE LL_TIM_DisableARRPreload
  1364. * @param TIMx Timer instance
  1365. * @retval None
  1366. */
  1367. __STATIC_INLINE void LL_TIM_DisableARRPreload(TIM_TypeDef *TIMx)
  1368. {
  1369. CLEAR_BIT(TIMx->CR1, TIM_CR1_ARPE);
  1370. }
  1371. /**
  1372. * @brief Indicates whether auto-reload (ARR) preload is enabled.
  1373. * @rmtoll CR1 ARPE LL_TIM_IsEnabledARRPreload
  1374. * @param TIMx Timer instance
  1375. * @retval State of bit (1 or 0).
  1376. */
  1377. __STATIC_INLINE uint32_t LL_TIM_IsEnabledARRPreload(TIM_TypeDef *TIMx)
  1378. {
  1379. return ((READ_BIT(TIMx->CR1, TIM_CR1_ARPE) == (TIM_CR1_ARPE)) ? 1UL : 0UL);
  1380. }
  1381. /**
  1382. * @brief Set the division ratio between the timer clock and the sampling clock used by the dead-time generators (when supported) and the digital filters.
  1383. * @note Macro IS_TIM_CLOCK_DIVISION_INSTANCE(TIMx) can be used to check
  1384. * whether or not the clock division feature is supported by the timer
  1385. * instance.
  1386. * @rmtoll CR1 CKD LL_TIM_SetClockDivision
  1387. * @param TIMx Timer instance
  1388. * @param ClockDivision This parameter can be one of the following values:
  1389. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  1390. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  1391. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  1392. * @retval None
  1393. */
  1394. __STATIC_INLINE void LL_TIM_SetClockDivision(TIM_TypeDef *TIMx, uint32_t ClockDivision)
  1395. {
  1396. MODIFY_REG(TIMx->CR1, TIM_CR1_CKD, ClockDivision);
  1397. }
  1398. /**
  1399. * @brief Get the actual division ratio between the timer clock and the sampling clock used by the dead-time generators (when supported) and the digital filters.
  1400. * @note Macro IS_TIM_CLOCK_DIVISION_INSTANCE(TIMx) can be used to check
  1401. * whether or not the clock division feature is supported by the timer
  1402. * instance.
  1403. * @rmtoll CR1 CKD LL_TIM_GetClockDivision
  1404. * @param TIMx Timer instance
  1405. * @retval Returned value can be one of the following values:
  1406. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  1407. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  1408. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  1409. */
  1410. __STATIC_INLINE uint32_t LL_TIM_GetClockDivision(TIM_TypeDef *TIMx)
  1411. {
  1412. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_CKD));
  1413. }
  1414. /**
  1415. * @brief Set the counter value.
  1416. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1417. * whether or not a timer instance supports a 32 bits counter.
  1418. * @rmtoll CNT CNT LL_TIM_SetCounter
  1419. * @param TIMx Timer instance
  1420. * @param Counter Counter value (between Min_Data=0 and Max_Data=0xFFFF or 0xFFFFFFFF)
  1421. * @retval None
  1422. */
  1423. __STATIC_INLINE void LL_TIM_SetCounter(TIM_TypeDef *TIMx, uint32_t Counter)
  1424. {
  1425. WRITE_REG(TIMx->CNT, Counter);
  1426. }
  1427. /**
  1428. * @brief Get the counter value.
  1429. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1430. * whether or not a timer instance supports a 32 bits counter.
  1431. * @rmtoll CNT CNT LL_TIM_GetCounter
  1432. * @param TIMx Timer instance
  1433. * @retval Counter value (between Min_Data=0 and Max_Data=0xFFFF or 0xFFFFFFFF)
  1434. */
  1435. __STATIC_INLINE uint32_t LL_TIM_GetCounter(TIM_TypeDef *TIMx)
  1436. {
  1437. return (uint32_t)(READ_REG(TIMx->CNT));
  1438. }
  1439. /**
  1440. * @brief Get the current direction of the counter
  1441. * @rmtoll CR1 DIR LL_TIM_GetDirection
  1442. * @param TIMx Timer instance
  1443. * @retval Returned value can be one of the following values:
  1444. * @arg @ref LL_TIM_COUNTERDIRECTION_UP
  1445. * @arg @ref LL_TIM_COUNTERDIRECTION_DOWN
  1446. */
  1447. __STATIC_INLINE uint32_t LL_TIM_GetDirection(TIM_TypeDef *TIMx)
  1448. {
  1449. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_DIR));
  1450. }
  1451. /**
  1452. * @brief Set the prescaler value.
  1453. * @note The counter clock frequency CK_CNT is equal to fCK_PSC / (PSC[15:0] + 1).
  1454. * @note The prescaler can be changed on the fly as this control register is buffered. The new
  1455. * prescaler ratio is taken into account at the next update event.
  1456. * @note Helper macro @ref __LL_TIM_CALC_PSC can be used to calculate the Prescaler parameter
  1457. * @rmtoll PSC PSC LL_TIM_SetPrescaler
  1458. * @param TIMx Timer instance
  1459. * @param Prescaler between Min_Data=0 and Max_Data=65535
  1460. * @retval None
  1461. */
  1462. __STATIC_INLINE void LL_TIM_SetPrescaler(TIM_TypeDef *TIMx, uint32_t Prescaler)
  1463. {
  1464. WRITE_REG(TIMx->PSC, Prescaler);
  1465. }
  1466. /**
  1467. * @brief Get the prescaler value.
  1468. * @rmtoll PSC PSC LL_TIM_GetPrescaler
  1469. * @param TIMx Timer instance
  1470. * @retval Prescaler value between Min_Data=0 and Max_Data=65535
  1471. */
  1472. __STATIC_INLINE uint32_t LL_TIM_GetPrescaler(TIM_TypeDef *TIMx)
  1473. {
  1474. return (uint32_t)(READ_REG(TIMx->PSC));
  1475. }
  1476. /**
  1477. * @brief Set the auto-reload value.
  1478. * @note The counter is blocked while the auto-reload value is null.
  1479. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1480. * whether or not a timer instance supports a 32 bits counter.
  1481. * @note Helper macro @ref __LL_TIM_CALC_ARR can be used to calculate the AutoReload parameter
  1482. * @rmtoll ARR ARR LL_TIM_SetAutoReload
  1483. * @param TIMx Timer instance
  1484. * @param AutoReload between Min_Data=0 and Max_Data=65535
  1485. * @retval None
  1486. */
  1487. __STATIC_INLINE void LL_TIM_SetAutoReload(TIM_TypeDef *TIMx, uint32_t AutoReload)
  1488. {
  1489. WRITE_REG(TIMx->ARR, AutoReload);
  1490. }
  1491. /**
  1492. * @brief Get the auto-reload value.
  1493. * @rmtoll ARR ARR LL_TIM_GetAutoReload
  1494. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1495. * whether or not a timer instance supports a 32 bits counter.
  1496. * @param TIMx Timer instance
  1497. * @retval Auto-reload value
  1498. */
  1499. __STATIC_INLINE uint32_t LL_TIM_GetAutoReload(TIM_TypeDef *TIMx)
  1500. {
  1501. return (uint32_t)(READ_REG(TIMx->ARR));
  1502. }
  1503. /**
  1504. * @brief Set the repetition counter value.
  1505. * @note For advanced timer instances RepetitionCounter can be up to 65535.
  1506. * @note Macro IS_TIM_REPETITION_COUNTER_INSTANCE(TIMx) can be used to check
  1507. * whether or not a timer instance supports a repetition counter.
  1508. * @rmtoll RCR REP LL_TIM_SetRepetitionCounter
  1509. * @param TIMx Timer instance
  1510. * @param RepetitionCounter between Min_Data=0 and Max_Data=255
  1511. * @retval None
  1512. */
  1513. __STATIC_INLINE void LL_TIM_SetRepetitionCounter(TIM_TypeDef *TIMx, uint32_t RepetitionCounter)
  1514. {
  1515. WRITE_REG(TIMx->RCR, RepetitionCounter);
  1516. }
  1517. /**
  1518. * @brief Get the repetition counter value.
  1519. * @note Macro IS_TIM_REPETITION_COUNTER_INSTANCE(TIMx) can be used to check
  1520. * whether or not a timer instance supports a repetition counter.
  1521. * @rmtoll RCR REP LL_TIM_GetRepetitionCounter
  1522. * @param TIMx Timer instance
  1523. * @retval Repetition counter value
  1524. */
  1525. __STATIC_INLINE uint32_t LL_TIM_GetRepetitionCounter(TIM_TypeDef *TIMx)
  1526. {
  1527. return (uint32_t)(READ_REG(TIMx->RCR));
  1528. }
  1529. /**
  1530. * @brief Force a continuous copy of the update interrupt flag (UIF) into the timer counter register (bit 31).
  1531. * @note This allows both the counter value and a potential roll-over condition signalled by the UIFCPY flag to be read in an atomic way.
  1532. * @rmtoll CR1 UIFREMAP LL_TIM_EnableUIFRemap
  1533. * @param TIMx Timer instance
  1534. * @retval None
  1535. */
  1536. __STATIC_INLINE void LL_TIM_EnableUIFRemap(TIM_TypeDef *TIMx)
  1537. {
  1538. SET_BIT(TIMx->CR1, TIM_CR1_UIFREMAP);
  1539. }
  1540. /**
  1541. * @brief Disable update interrupt flag (UIF) remapping.
  1542. * @rmtoll CR1 UIFREMAP LL_TIM_DisableUIFRemap
  1543. * @param TIMx Timer instance
  1544. * @retval None
  1545. */
  1546. __STATIC_INLINE void LL_TIM_DisableUIFRemap(TIM_TypeDef *TIMx)
  1547. {
  1548. CLEAR_BIT(TIMx->CR1, TIM_CR1_UIFREMAP);
  1549. }
  1550. /**
  1551. * @brief Indicate whether update interrupt flag (UIF) copy is set.
  1552. * @param Counter Counter value
  1553. * @retval State of bit (1 or 0).
  1554. */
  1555. __STATIC_INLINE uint32_t LL_TIM_IsActiveUIFCPY(uint32_t Counter)
  1556. {
  1557. return (((Counter & TIM_CNT_UIFCPY) == (TIM_CNT_UIFCPY)) ? 1UL : 0UL);
  1558. }
  1559. /**
  1560. * @}
  1561. */
  1562. /** @defgroup TIM_LL_EF_Capture_Compare Capture Compare configuration
  1563. * @{
  1564. */
  1565. /**
  1566. * @brief Enable the capture/compare control bits (CCxE, CCxNE and OCxM) preload.
  1567. * @note CCxE, CCxNE and OCxM bits are preloaded, after having been written,
  1568. * they are updated only when a commutation event (COM) occurs.
  1569. * @note Only on channels that have a complementary output.
  1570. * @note Macro IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
  1571. * whether or not a timer instance is able to generate a commutation event.
  1572. * @rmtoll CR2 CCPC LL_TIM_CC_EnablePreload
  1573. * @param TIMx Timer instance
  1574. * @retval None
  1575. */
  1576. __STATIC_INLINE void LL_TIM_CC_EnablePreload(TIM_TypeDef *TIMx)
  1577. {
  1578. SET_BIT(TIMx->CR2, TIM_CR2_CCPC);
  1579. }
  1580. /**
  1581. * @brief Disable the capture/compare control bits (CCxE, CCxNE and OCxM) preload.
  1582. * @note Macro IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
  1583. * whether or not a timer instance is able to generate a commutation event.
  1584. * @rmtoll CR2 CCPC LL_TIM_CC_DisablePreload
  1585. * @param TIMx Timer instance
  1586. * @retval None
  1587. */
  1588. __STATIC_INLINE void LL_TIM_CC_DisablePreload(TIM_TypeDef *TIMx)
  1589. {
  1590. CLEAR_BIT(TIMx->CR2, TIM_CR2_CCPC);
  1591. }
  1592. /**
  1593. * @brief Set the updated source of the capture/compare control bits (CCxE, CCxNE and OCxM).
  1594. * @note Macro IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
  1595. * whether or not a timer instance is able to generate a commutation event.
  1596. * @rmtoll CR2 CCUS LL_TIM_CC_SetUpdate
  1597. * @param TIMx Timer instance
  1598. * @param CCUpdateSource This parameter can be one of the following values:
  1599. * @arg @ref LL_TIM_CCUPDATESOURCE_COMG_ONLY
  1600. * @arg @ref LL_TIM_CCUPDATESOURCE_COMG_AND_TRGI
  1601. * @retval None
  1602. */
  1603. __STATIC_INLINE void LL_TIM_CC_SetUpdate(TIM_TypeDef *TIMx, uint32_t CCUpdateSource)
  1604. {
  1605. MODIFY_REG(TIMx->CR2, TIM_CR2_CCUS, CCUpdateSource);
  1606. }
  1607. /**
  1608. * @brief Set the trigger of the capture/compare DMA request.
  1609. * @rmtoll CR2 CCDS LL_TIM_CC_SetDMAReqTrigger
  1610. * @param TIMx Timer instance
  1611. * @param DMAReqTrigger This parameter can be one of the following values:
  1612. * @arg @ref LL_TIM_CCDMAREQUEST_CC
  1613. * @arg @ref LL_TIM_CCDMAREQUEST_UPDATE
  1614. * @retval None
  1615. */
  1616. __STATIC_INLINE void LL_TIM_CC_SetDMAReqTrigger(TIM_TypeDef *TIMx, uint32_t DMAReqTrigger)
  1617. {
  1618. MODIFY_REG(TIMx->CR2, TIM_CR2_CCDS, DMAReqTrigger);
  1619. }
  1620. /**
  1621. * @brief Get actual trigger of the capture/compare DMA request.
  1622. * @rmtoll CR2 CCDS LL_TIM_CC_GetDMAReqTrigger
  1623. * @param TIMx Timer instance
  1624. * @retval Returned value can be one of the following values:
  1625. * @arg @ref LL_TIM_CCDMAREQUEST_CC
  1626. * @arg @ref LL_TIM_CCDMAREQUEST_UPDATE
  1627. */
  1628. __STATIC_INLINE uint32_t LL_TIM_CC_GetDMAReqTrigger(TIM_TypeDef *TIMx)
  1629. {
  1630. return (uint32_t)(READ_BIT(TIMx->CR2, TIM_CR2_CCDS));
  1631. }
  1632. /**
  1633. * @brief Set the lock level to freeze the
  1634. * configuration of several capture/compare parameters.
  1635. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  1636. * the lock mechanism is supported by a timer instance.
  1637. * @rmtoll BDTR LOCK LL_TIM_CC_SetLockLevel
  1638. * @param TIMx Timer instance
  1639. * @param LockLevel This parameter can be one of the following values:
  1640. * @arg @ref LL_TIM_LOCKLEVEL_OFF
  1641. * @arg @ref LL_TIM_LOCKLEVEL_1
  1642. * @arg @ref LL_TIM_LOCKLEVEL_2
  1643. * @arg @ref LL_TIM_LOCKLEVEL_3
  1644. * @retval None
  1645. */
  1646. __STATIC_INLINE void LL_TIM_CC_SetLockLevel(TIM_TypeDef *TIMx, uint32_t LockLevel)
  1647. {
  1648. MODIFY_REG(TIMx->BDTR, TIM_BDTR_LOCK, LockLevel);
  1649. }
  1650. /**
  1651. * @brief Enable capture/compare channels.
  1652. * @rmtoll CCER CC1E LL_TIM_CC_EnableChannel\n
  1653. * CCER CC1NE LL_TIM_CC_EnableChannel\n
  1654. * CCER CC2E LL_TIM_CC_EnableChannel\n
  1655. * CCER CC2NE LL_TIM_CC_EnableChannel\n
  1656. * CCER CC3E LL_TIM_CC_EnableChannel\n
  1657. * CCER CC3NE LL_TIM_CC_EnableChannel\n
  1658. * CCER CC4E LL_TIM_CC_EnableChannel\n
  1659. * CCER CC5E LL_TIM_CC_EnableChannel\n
  1660. * CCER CC6E LL_TIM_CC_EnableChannel
  1661. * @param TIMx Timer instance
  1662. * @param Channels This parameter can be a combination of the following values:
  1663. * @arg @ref LL_TIM_CHANNEL_CH1
  1664. * @arg @ref LL_TIM_CHANNEL_CH1N
  1665. * @arg @ref LL_TIM_CHANNEL_CH2
  1666. * @arg @ref LL_TIM_CHANNEL_CH2N
  1667. * @arg @ref LL_TIM_CHANNEL_CH3
  1668. * @arg @ref LL_TIM_CHANNEL_CH3N
  1669. * @arg @ref LL_TIM_CHANNEL_CH4
  1670. * @arg @ref LL_TIM_CHANNEL_CH5
  1671. * @arg @ref LL_TIM_CHANNEL_CH6
  1672. * @retval None
  1673. */
  1674. __STATIC_INLINE void LL_TIM_CC_EnableChannel(TIM_TypeDef *TIMx, uint32_t Channels)
  1675. {
  1676. SET_BIT(TIMx->CCER, Channels);
  1677. }
  1678. /**
  1679. * @brief Disable capture/compare channels.
  1680. * @rmtoll CCER CC1E LL_TIM_CC_DisableChannel\n
  1681. * CCER CC1NE LL_TIM_CC_DisableChannel\n
  1682. * CCER CC2E LL_TIM_CC_DisableChannel\n
  1683. * CCER CC2NE LL_TIM_CC_DisableChannel\n
  1684. * CCER CC3E LL_TIM_CC_DisableChannel\n
  1685. * CCER CC3NE LL_TIM_CC_DisableChannel\n
  1686. * CCER CC4E LL_TIM_CC_DisableChannel\n
  1687. * CCER CC5E LL_TIM_CC_DisableChannel\n
  1688. * CCER CC6E LL_TIM_CC_DisableChannel
  1689. * @param TIMx Timer instance
  1690. * @param Channels This parameter can be a combination of the following values:
  1691. * @arg @ref LL_TIM_CHANNEL_CH1
  1692. * @arg @ref LL_TIM_CHANNEL_CH1N
  1693. * @arg @ref LL_TIM_CHANNEL_CH2
  1694. * @arg @ref LL_TIM_CHANNEL_CH2N
  1695. * @arg @ref LL_TIM_CHANNEL_CH3
  1696. * @arg @ref LL_TIM_CHANNEL_CH3N
  1697. * @arg @ref LL_TIM_CHANNEL_CH4
  1698. * @arg @ref LL_TIM_CHANNEL_CH5
  1699. * @arg @ref LL_TIM_CHANNEL_CH6
  1700. * @retval None
  1701. */
  1702. __STATIC_INLINE void LL_TIM_CC_DisableChannel(TIM_TypeDef *TIMx, uint32_t Channels)
  1703. {
  1704. CLEAR_BIT(TIMx->CCER, Channels);
  1705. }
  1706. /**
  1707. * @brief Indicate whether channel(s) is(are) enabled.
  1708. * @rmtoll CCER CC1E LL_TIM_CC_IsEnabledChannel\n
  1709. * CCER CC1NE LL_TIM_CC_IsEnabledChannel\n
  1710. * CCER CC2E LL_TIM_CC_IsEnabledChannel\n
  1711. * CCER CC2NE LL_TIM_CC_IsEnabledChannel\n
  1712. * CCER CC3E LL_TIM_CC_IsEnabledChannel\n
  1713. * CCER CC3NE LL_TIM_CC_IsEnabledChannel\n
  1714. * CCER CC4E LL_TIM_CC_IsEnabledChannel\n
  1715. * CCER CC5E LL_TIM_CC_IsEnabledChannel\n
  1716. * CCER CC6E LL_TIM_CC_IsEnabledChannel
  1717. * @param TIMx Timer instance
  1718. * @param Channels This parameter can be a combination of the following values:
  1719. * @arg @ref LL_TIM_CHANNEL_CH1
  1720. * @arg @ref LL_TIM_CHANNEL_CH1N
  1721. * @arg @ref LL_TIM_CHANNEL_CH2
  1722. * @arg @ref LL_TIM_CHANNEL_CH2N
  1723. * @arg @ref LL_TIM_CHANNEL_CH3
  1724. * @arg @ref LL_TIM_CHANNEL_CH3N
  1725. * @arg @ref LL_TIM_CHANNEL_CH4
  1726. * @arg @ref LL_TIM_CHANNEL_CH5
  1727. * @arg @ref LL_TIM_CHANNEL_CH6
  1728. * @retval State of bit (1 or 0).
  1729. */
  1730. __STATIC_INLINE uint32_t LL_TIM_CC_IsEnabledChannel(TIM_TypeDef *TIMx, uint32_t Channels)
  1731. {
  1732. return ((READ_BIT(TIMx->CCER, Channels) == (Channels)) ? 1UL : 0UL);
  1733. }
  1734. /**
  1735. * @}
  1736. */
  1737. /** @defgroup TIM_LL_EF_Output_Channel Output channel configuration
  1738. * @{
  1739. */
  1740. /**
  1741. * @brief Configure an output channel.
  1742. * @rmtoll CCMR1 CC1S LL_TIM_OC_ConfigOutput\n
  1743. * CCMR1 CC2S LL_TIM_OC_ConfigOutput\n
  1744. * CCMR2 CC3S LL_TIM_OC_ConfigOutput\n
  1745. * CCMR2 CC4S LL_TIM_OC_ConfigOutput\n
  1746. * CCMR3 CC5S LL_TIM_OC_ConfigOutput\n
  1747. * CCMR3 CC6S LL_TIM_OC_ConfigOutput\n
  1748. * CCER CC1P LL_TIM_OC_ConfigOutput\n
  1749. * CCER CC2P LL_TIM_OC_ConfigOutput\n
  1750. * CCER CC3P LL_TIM_OC_ConfigOutput\n
  1751. * CCER CC4P LL_TIM_OC_ConfigOutput\n
  1752. * CCER CC5P LL_TIM_OC_ConfigOutput\n
  1753. * CCER CC6P LL_TIM_OC_ConfigOutput\n
  1754. * CR2 OIS1 LL_TIM_OC_ConfigOutput\n
  1755. * CR2 OIS2 LL_TIM_OC_ConfigOutput\n
  1756. * CR2 OIS3 LL_TIM_OC_ConfigOutput\n
  1757. * CR2 OIS4 LL_TIM_OC_ConfigOutput\n
  1758. * CR2 OIS5 LL_TIM_OC_ConfigOutput\n
  1759. * CR2 OIS6 LL_TIM_OC_ConfigOutput
  1760. * @param TIMx Timer instance
  1761. * @param Channel This parameter can be one of the following values:
  1762. * @arg @ref LL_TIM_CHANNEL_CH1
  1763. * @arg @ref LL_TIM_CHANNEL_CH2
  1764. * @arg @ref LL_TIM_CHANNEL_CH3
  1765. * @arg @ref LL_TIM_CHANNEL_CH4
  1766. * @arg @ref LL_TIM_CHANNEL_CH5
  1767. * @arg @ref LL_TIM_CHANNEL_CH6
  1768. * @param Configuration This parameter must be a combination of all the following values:
  1769. * @arg @ref LL_TIM_OCPOLARITY_HIGH or @ref LL_TIM_OCPOLARITY_LOW
  1770. * @arg @ref LL_TIM_OCIDLESTATE_LOW or @ref LL_TIM_OCIDLESTATE_HIGH
  1771. * @retval None
  1772. */
  1773. __STATIC_INLINE void LL_TIM_OC_ConfigOutput(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Configuration)
  1774. {
  1775. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1776. register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1777. CLEAR_BIT(*pReg, (TIM_CCMR1_CC1S << SHIFT_TAB_OCxx[iChannel]));
  1778. MODIFY_REG(TIMx->CCER, (TIM_CCER_CC1P << SHIFT_TAB_CCxP[iChannel]),
  1779. (Configuration & TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel]);
  1780. MODIFY_REG(TIMx->CR2, (TIM_CR2_OIS1 << SHIFT_TAB_OISx[iChannel]),
  1781. (Configuration & TIM_CR2_OIS1) << SHIFT_TAB_OISx[iChannel]);
  1782. }
  1783. /**
  1784. * @brief Define the behavior of the output reference signal OCxREF from which
  1785. * OCx and OCxN (when relevant) are derived.
  1786. * @rmtoll CCMR1 OC1M LL_TIM_OC_SetMode\n
  1787. * CCMR1 OC2M LL_TIM_OC_SetMode\n
  1788. * CCMR2 OC3M LL_TIM_OC_SetMode\n
  1789. * CCMR2 OC4M LL_TIM_OC_SetMode\n
  1790. * CCMR3 OC5M LL_TIM_OC_SetMode\n
  1791. * CCMR3 OC6M LL_TIM_OC_SetMode
  1792. * @param TIMx Timer instance
  1793. * @param Channel This parameter can be one of the following values:
  1794. * @arg @ref LL_TIM_CHANNEL_CH1
  1795. * @arg @ref LL_TIM_CHANNEL_CH2
  1796. * @arg @ref LL_TIM_CHANNEL_CH3
  1797. * @arg @ref LL_TIM_CHANNEL_CH4
  1798. * @arg @ref LL_TIM_CHANNEL_CH5
  1799. * @arg @ref LL_TIM_CHANNEL_CH6
  1800. * @param Mode This parameter can be one of the following values:
  1801. * @arg @ref LL_TIM_OCMODE_FROZEN
  1802. * @arg @ref LL_TIM_OCMODE_ACTIVE
  1803. * @arg @ref LL_TIM_OCMODE_INACTIVE
  1804. * @arg @ref LL_TIM_OCMODE_TOGGLE
  1805. * @arg @ref LL_TIM_OCMODE_FORCED_INACTIVE
  1806. * @arg @ref LL_TIM_OCMODE_FORCED_ACTIVE
  1807. * @arg @ref LL_TIM_OCMODE_PWM1
  1808. * @arg @ref LL_TIM_OCMODE_PWM2
  1809. * @arg @ref LL_TIM_OCMODE_RETRIG_OPM1
  1810. * @arg @ref LL_TIM_OCMODE_RETRIG_OPM2
  1811. * @arg @ref LL_TIM_OCMODE_COMBINED_PWM1
  1812. * @arg @ref LL_TIM_OCMODE_COMBINED_PWM2
  1813. * @arg @ref LL_TIM_OCMODE_ASSYMETRIC_PWM1
  1814. * @arg @ref LL_TIM_OCMODE_ASSYMETRIC_PWM2
  1815. * @retval None
  1816. */
  1817. __STATIC_INLINE void LL_TIM_OC_SetMode(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Mode)
  1818. {
  1819. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1820. register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1821. MODIFY_REG(*pReg, ((TIM_CCMR1_OC1M | TIM_CCMR1_CC1S) << SHIFT_TAB_OCxx[iChannel]), Mode << SHIFT_TAB_OCxx[iChannel]);
  1822. }
  1823. /**
  1824. * @brief Get the output compare mode of an output channel.
  1825. * @rmtoll CCMR1 OC1M LL_TIM_OC_GetMode\n
  1826. * CCMR1 OC2M LL_TIM_OC_GetMode\n
  1827. * CCMR2 OC3M LL_TIM_OC_GetMode\n
  1828. * CCMR2 OC4M LL_TIM_OC_GetMode\n
  1829. * CCMR3 OC5M LL_TIM_OC_GetMode\n
  1830. * CCMR3 OC6M LL_TIM_OC_GetMode
  1831. * @param TIMx Timer instance
  1832. * @param Channel This parameter can be one of the following values:
  1833. * @arg @ref LL_TIM_CHANNEL_CH1
  1834. * @arg @ref LL_TIM_CHANNEL_CH2
  1835. * @arg @ref LL_TIM_CHANNEL_CH3
  1836. * @arg @ref LL_TIM_CHANNEL_CH4
  1837. * @arg @ref LL_TIM_CHANNEL_CH5
  1838. * @arg @ref LL_TIM_CHANNEL_CH6
  1839. * @retval Returned value can be one of the following values:
  1840. * @arg @ref LL_TIM_OCMODE_FROZEN
  1841. * @arg @ref LL_TIM_OCMODE_ACTIVE
  1842. * @arg @ref LL_TIM_OCMODE_INACTIVE
  1843. * @arg @ref LL_TIM_OCMODE_TOGGLE
  1844. * @arg @ref LL_TIM_OCMODE_FORCED_INACTIVE
  1845. * @arg @ref LL_TIM_OCMODE_FORCED_ACTIVE
  1846. * @arg @ref LL_TIM_OCMODE_PWM1
  1847. * @arg @ref LL_TIM_OCMODE_PWM2
  1848. * @arg @ref LL_TIM_OCMODE_RETRIG_OPM1
  1849. * @arg @ref LL_TIM_OCMODE_RETRIG_OPM2
  1850. * @arg @ref LL_TIM_OCMODE_COMBINED_PWM1
  1851. * @arg @ref LL_TIM_OCMODE_COMBINED_PWM2
  1852. * @arg @ref LL_TIM_OCMODE_ASSYMETRIC_PWM1
  1853. * @arg @ref LL_TIM_OCMODE_ASSYMETRIC_PWM2
  1854. */
  1855. __STATIC_INLINE uint32_t LL_TIM_OC_GetMode(TIM_TypeDef *TIMx, uint32_t Channel)
  1856. {
  1857. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1858. register const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1859. return (READ_BIT(*pReg, ((TIM_CCMR1_OC1M | TIM_CCMR1_CC1S) << SHIFT_TAB_OCxx[iChannel])) >> SHIFT_TAB_OCxx[iChannel]);
  1860. }
  1861. /**
  1862. * @brief Set the polarity of an output channel.
  1863. * @rmtoll CCER CC1P LL_TIM_OC_SetPolarity\n
  1864. * CCER CC1NP LL_TIM_OC_SetPolarity\n
  1865. * CCER CC2P LL_TIM_OC_SetPolarity\n
  1866. * CCER CC2NP LL_TIM_OC_SetPolarity\n
  1867. * CCER CC3P LL_TIM_OC_SetPolarity\n
  1868. * CCER CC3NP LL_TIM_OC_SetPolarity\n
  1869. * CCER CC4P LL_TIM_OC_SetPolarity\n
  1870. * CCER CC5P LL_TIM_OC_SetPolarity\n
  1871. * CCER CC6P LL_TIM_OC_SetPolarity
  1872. * @param TIMx Timer instance
  1873. * @param Channel This parameter can be one of the following values:
  1874. * @arg @ref LL_TIM_CHANNEL_CH1
  1875. * @arg @ref LL_TIM_CHANNEL_CH1N
  1876. * @arg @ref LL_TIM_CHANNEL_CH2
  1877. * @arg @ref LL_TIM_CHANNEL_CH2N
  1878. * @arg @ref LL_TIM_CHANNEL_CH3
  1879. * @arg @ref LL_TIM_CHANNEL_CH3N
  1880. * @arg @ref LL_TIM_CHANNEL_CH4
  1881. * @arg @ref LL_TIM_CHANNEL_CH5
  1882. * @arg @ref LL_TIM_CHANNEL_CH6
  1883. * @param Polarity This parameter can be one of the following values:
  1884. * @arg @ref LL_TIM_OCPOLARITY_HIGH
  1885. * @arg @ref LL_TIM_OCPOLARITY_LOW
  1886. * @retval None
  1887. */
  1888. __STATIC_INLINE void LL_TIM_OC_SetPolarity(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Polarity)
  1889. {
  1890. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1891. MODIFY_REG(TIMx->CCER, (TIM_CCER_CC1P << SHIFT_TAB_CCxP[iChannel]), Polarity << SHIFT_TAB_CCxP[iChannel]);
  1892. }
  1893. /**
  1894. * @brief Get the polarity of an output channel.
  1895. * @rmtoll CCER CC1P LL_TIM_OC_GetPolarity\n
  1896. * CCER CC1NP LL_TIM_OC_GetPolarity\n
  1897. * CCER CC2P LL_TIM_OC_GetPolarity\n
  1898. * CCER CC2NP LL_TIM_OC_GetPolarity\n
  1899. * CCER CC3P LL_TIM_OC_GetPolarity\n
  1900. * CCER CC3NP LL_TIM_OC_GetPolarity\n
  1901. * CCER CC4P LL_TIM_OC_GetPolarity\n
  1902. * CCER CC5P LL_TIM_OC_GetPolarity\n
  1903. * CCER CC6P LL_TIM_OC_GetPolarity
  1904. * @param TIMx Timer instance
  1905. * @param Channel This parameter can be one of the following values:
  1906. * @arg @ref LL_TIM_CHANNEL_CH1
  1907. * @arg @ref LL_TIM_CHANNEL_CH1N
  1908. * @arg @ref LL_TIM_CHANNEL_CH2
  1909. * @arg @ref LL_TIM_CHANNEL_CH2N
  1910. * @arg @ref LL_TIM_CHANNEL_CH3
  1911. * @arg @ref LL_TIM_CHANNEL_CH3N
  1912. * @arg @ref LL_TIM_CHANNEL_CH4
  1913. * @arg @ref LL_TIM_CHANNEL_CH5
  1914. * @arg @ref LL_TIM_CHANNEL_CH6
  1915. * @retval Returned value can be one of the following values:
  1916. * @arg @ref LL_TIM_OCPOLARITY_HIGH
  1917. * @arg @ref LL_TIM_OCPOLARITY_LOW
  1918. */
  1919. __STATIC_INLINE uint32_t LL_TIM_OC_GetPolarity(TIM_TypeDef *TIMx, uint32_t Channel)
  1920. {
  1921. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1922. return (READ_BIT(TIMx->CCER, (TIM_CCER_CC1P << SHIFT_TAB_CCxP[iChannel])) >> SHIFT_TAB_CCxP[iChannel]);
  1923. }
  1924. /**
  1925. * @brief Set the IDLE state of an output channel
  1926. * @note This function is significant only for the timer instances
  1927. * supporting the break feature. Macro IS_TIM_BREAK_INSTANCE(TIMx)
  1928. * can be used to check whether or not a timer instance provides
  1929. * a break input.
  1930. * @rmtoll CR2 OIS1 LL_TIM_OC_SetIdleState\n
  1931. * CR2 OIS2N LL_TIM_OC_SetIdleState\n
  1932. * CR2 OIS2 LL_TIM_OC_SetIdleState\n
  1933. * CR2 OIS2N LL_TIM_OC_SetIdleState\n
  1934. * CR2 OIS3 LL_TIM_OC_SetIdleState\n
  1935. * CR2 OIS3N LL_TIM_OC_SetIdleState\n
  1936. * CR2 OIS4 LL_TIM_OC_SetIdleState\n
  1937. * CR2 OIS5 LL_TIM_OC_SetIdleState\n
  1938. * CR2 OIS6 LL_TIM_OC_SetIdleState
  1939. * @param TIMx Timer instance
  1940. * @param Channel This parameter can be one of the following values:
  1941. * @arg @ref LL_TIM_CHANNEL_CH1
  1942. * @arg @ref LL_TIM_CHANNEL_CH1N
  1943. * @arg @ref LL_TIM_CHANNEL_CH2
  1944. * @arg @ref LL_TIM_CHANNEL_CH2N
  1945. * @arg @ref LL_TIM_CHANNEL_CH3
  1946. * @arg @ref LL_TIM_CHANNEL_CH3N
  1947. * @arg @ref LL_TIM_CHANNEL_CH4
  1948. * @arg @ref LL_TIM_CHANNEL_CH5
  1949. * @arg @ref LL_TIM_CHANNEL_CH6
  1950. * @param IdleState This parameter can be one of the following values:
  1951. * @arg @ref LL_TIM_OCIDLESTATE_LOW
  1952. * @arg @ref LL_TIM_OCIDLESTATE_HIGH
  1953. * @retval None
  1954. */
  1955. __STATIC_INLINE void LL_TIM_OC_SetIdleState(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t IdleState)
  1956. {
  1957. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1958. MODIFY_REG(TIMx->CR2, (TIM_CR2_OIS1 << SHIFT_TAB_OISx[iChannel]), IdleState << SHIFT_TAB_OISx[iChannel]);
  1959. }
  1960. /**
  1961. * @brief Get the IDLE state of an output channel
  1962. * @rmtoll CR2 OIS1 LL_TIM_OC_GetIdleState\n
  1963. * CR2 OIS2N LL_TIM_OC_GetIdleState\n
  1964. * CR2 OIS2 LL_TIM_OC_GetIdleState\n
  1965. * CR2 OIS2N LL_TIM_OC_GetIdleState\n
  1966. * CR2 OIS3 LL_TIM_OC_GetIdleState\n
  1967. * CR2 OIS3N LL_TIM_OC_GetIdleState\n
  1968. * CR2 OIS4 LL_TIM_OC_GetIdleState\n
  1969. * CR2 OIS5 LL_TIM_OC_GetIdleState\n
  1970. * CR2 OIS6 LL_TIM_OC_GetIdleState
  1971. * @param TIMx Timer instance
  1972. * @param Channel This parameter can be one of the following values:
  1973. * @arg @ref LL_TIM_CHANNEL_CH1
  1974. * @arg @ref LL_TIM_CHANNEL_CH1N
  1975. * @arg @ref LL_TIM_CHANNEL_CH2
  1976. * @arg @ref LL_TIM_CHANNEL_CH2N
  1977. * @arg @ref LL_TIM_CHANNEL_CH3
  1978. * @arg @ref LL_TIM_CHANNEL_CH3N
  1979. * @arg @ref LL_TIM_CHANNEL_CH4
  1980. * @arg @ref LL_TIM_CHANNEL_CH5
  1981. * @arg @ref LL_TIM_CHANNEL_CH6
  1982. * @retval Returned value can be one of the following values:
  1983. * @arg @ref LL_TIM_OCIDLESTATE_LOW
  1984. * @arg @ref LL_TIM_OCIDLESTATE_HIGH
  1985. */
  1986. __STATIC_INLINE uint32_t LL_TIM_OC_GetIdleState(TIM_TypeDef *TIMx, uint32_t Channel)
  1987. {
  1988. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1989. return (READ_BIT(TIMx->CR2, (TIM_CR2_OIS1 << SHIFT_TAB_OISx[iChannel])) >> SHIFT_TAB_OISx[iChannel]);
  1990. }
  1991. /**
  1992. * @brief Enable fast mode for the output channel.
  1993. * @note Acts only if the channel is configured in PWM1 or PWM2 mode.
  1994. * @rmtoll CCMR1 OC1FE LL_TIM_OC_EnableFast\n
  1995. * CCMR1 OC2FE LL_TIM_OC_EnableFast\n
  1996. * CCMR2 OC3FE LL_TIM_OC_EnableFast\n
  1997. * CCMR2 OC4FE LL_TIM_OC_EnableFast\n
  1998. * CCMR3 OC5FE LL_TIM_OC_EnableFast\n
  1999. * CCMR3 OC6FE LL_TIM_OC_EnableFast
  2000. * @param TIMx Timer instance
  2001. * @param Channel This parameter can be one of the following values:
  2002. * @arg @ref LL_TIM_CHANNEL_CH1
  2003. * @arg @ref LL_TIM_CHANNEL_CH2
  2004. * @arg @ref LL_TIM_CHANNEL_CH3
  2005. * @arg @ref LL_TIM_CHANNEL_CH4
  2006. * @arg @ref LL_TIM_CHANNEL_CH5
  2007. * @arg @ref LL_TIM_CHANNEL_CH6
  2008. * @retval None
  2009. */
  2010. __STATIC_INLINE void LL_TIM_OC_EnableFast(TIM_TypeDef *TIMx, uint32_t Channel)
  2011. {
  2012. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2013. register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2014. SET_BIT(*pReg, (TIM_CCMR1_OC1FE << SHIFT_TAB_OCxx[iChannel]));
  2015. }
  2016. /**
  2017. * @brief Disable fast mode for the output channel.
  2018. * @rmtoll CCMR1 OC1FE LL_TIM_OC_DisableFast\n
  2019. * CCMR1 OC2FE LL_TIM_OC_DisableFast\n
  2020. * CCMR2 OC3FE LL_TIM_OC_DisableFast\n
  2021. * CCMR2 OC4FE LL_TIM_OC_DisableFast\n
  2022. * CCMR3 OC5FE LL_TIM_OC_DisableFast\n
  2023. * CCMR3 OC6FE LL_TIM_OC_DisableFast
  2024. * @param TIMx Timer instance
  2025. * @param Channel This parameter can be one of the following values:
  2026. * @arg @ref LL_TIM_CHANNEL_CH1
  2027. * @arg @ref LL_TIM_CHANNEL_CH2
  2028. * @arg @ref LL_TIM_CHANNEL_CH3
  2029. * @arg @ref LL_TIM_CHANNEL_CH4
  2030. * @arg @ref LL_TIM_CHANNEL_CH5
  2031. * @arg @ref LL_TIM_CHANNEL_CH6
  2032. * @retval None
  2033. */
  2034. __STATIC_INLINE void LL_TIM_OC_DisableFast(TIM_TypeDef *TIMx, uint32_t Channel)
  2035. {
  2036. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2037. register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2038. CLEAR_BIT(*pReg, (TIM_CCMR1_OC1FE << SHIFT_TAB_OCxx[iChannel]));
  2039. }
  2040. /**
  2041. * @brief Indicates whether fast mode is enabled for the output channel.
  2042. * @rmtoll CCMR1 OC1FE LL_TIM_OC_IsEnabledFast\n
  2043. * CCMR1 OC2FE LL_TIM_OC_IsEnabledFast\n
  2044. * CCMR2 OC3FE LL_TIM_OC_IsEnabledFast\n
  2045. * CCMR2 OC4FE LL_TIM_OC_IsEnabledFast\n
  2046. * CCMR3 OC5FE LL_TIM_OC_IsEnabledFast\n
  2047. * CCMR3 OC6FE LL_TIM_OC_IsEnabledFast
  2048. * @param TIMx Timer instance
  2049. * @param Channel This parameter can be one of the following values:
  2050. * @arg @ref LL_TIM_CHANNEL_CH1
  2051. * @arg @ref LL_TIM_CHANNEL_CH2
  2052. * @arg @ref LL_TIM_CHANNEL_CH3
  2053. * @arg @ref LL_TIM_CHANNEL_CH4
  2054. * @arg @ref LL_TIM_CHANNEL_CH5
  2055. * @arg @ref LL_TIM_CHANNEL_CH6
  2056. * @retval State of bit (1 or 0).
  2057. */
  2058. __STATIC_INLINE uint32_t LL_TIM_OC_IsEnabledFast(TIM_TypeDef *TIMx, uint32_t Channel)
  2059. {
  2060. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2061. register const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2062. register uint32_t bitfield = TIM_CCMR1_OC1FE << SHIFT_TAB_OCxx[iChannel];
  2063. return ((READ_BIT(*pReg, bitfield) == bitfield) ? 1UL : 0UL);
  2064. }
  2065. /**
  2066. * @brief Enable compare register (TIMx_CCRx) preload for the output channel.
  2067. * @rmtoll CCMR1 OC1PE LL_TIM_OC_EnablePreload\n
  2068. * CCMR1 OC2PE LL_TIM_OC_EnablePreload\n
  2069. * CCMR2 OC3PE LL_TIM_OC_EnablePreload\n
  2070. * CCMR2 OC4PE LL_TIM_OC_EnablePreload\n
  2071. * CCMR3 OC5PE LL_TIM_OC_EnablePreload\n
  2072. * CCMR3 OC6PE LL_TIM_OC_EnablePreload
  2073. * @param TIMx Timer instance
  2074. * @param Channel This parameter can be one of the following values:
  2075. * @arg @ref LL_TIM_CHANNEL_CH1
  2076. * @arg @ref LL_TIM_CHANNEL_CH2
  2077. * @arg @ref LL_TIM_CHANNEL_CH3
  2078. * @arg @ref LL_TIM_CHANNEL_CH4
  2079. * @arg @ref LL_TIM_CHANNEL_CH5
  2080. * @arg @ref LL_TIM_CHANNEL_CH6
  2081. * @retval None
  2082. */
  2083. __STATIC_INLINE void LL_TIM_OC_EnablePreload(TIM_TypeDef *TIMx, uint32_t Channel)
  2084. {
  2085. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2086. register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2087. SET_BIT(*pReg, (TIM_CCMR1_OC1PE << SHIFT_TAB_OCxx[iChannel]));
  2088. }
  2089. /**
  2090. * @brief Disable compare register (TIMx_CCRx) preload for the output channel.
  2091. * @rmtoll CCMR1 OC1PE LL_TIM_OC_DisablePreload\n
  2092. * CCMR1 OC2PE LL_TIM_OC_DisablePreload\n
  2093. * CCMR2 OC3PE LL_TIM_OC_DisablePreload\n
  2094. * CCMR2 OC4PE LL_TIM_OC_DisablePreload\n
  2095. * CCMR3 OC5PE LL_TIM_OC_DisablePreload\n
  2096. * CCMR3 OC6PE LL_TIM_OC_DisablePreload
  2097. * @param TIMx Timer instance
  2098. * @param Channel This parameter can be one of the following values:
  2099. * @arg @ref LL_TIM_CHANNEL_CH1
  2100. * @arg @ref LL_TIM_CHANNEL_CH2
  2101. * @arg @ref LL_TIM_CHANNEL_CH3
  2102. * @arg @ref LL_TIM_CHANNEL_CH4
  2103. * @arg @ref LL_TIM_CHANNEL_CH5
  2104. * @arg @ref LL_TIM_CHANNEL_CH6
  2105. * @retval None
  2106. */
  2107. __STATIC_INLINE void LL_TIM_OC_DisablePreload(TIM_TypeDef *TIMx, uint32_t Channel)
  2108. {
  2109. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2110. register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2111. CLEAR_BIT(*pReg, (TIM_CCMR1_OC1PE << SHIFT_TAB_OCxx[iChannel]));
  2112. }
  2113. /**
  2114. * @brief Indicates whether compare register (TIMx_CCRx) preload is enabled for the output channel.
  2115. * @rmtoll CCMR1 OC1PE LL_TIM_OC_IsEnabledPreload\n
  2116. * CCMR1 OC2PE LL_TIM_OC_IsEnabledPreload\n
  2117. * CCMR2 OC3PE LL_TIM_OC_IsEnabledPreload\n
  2118. * CCMR2 OC4PE LL_TIM_OC_IsEnabledPreload\n
  2119. * CCMR3 OC5PE LL_TIM_OC_IsEnabledPreload\n
  2120. * CCMR3 OC6PE LL_TIM_OC_IsEnabledPreload
  2121. * @param TIMx Timer instance
  2122. * @param Channel This parameter can be one of the following values:
  2123. * @arg @ref LL_TIM_CHANNEL_CH1
  2124. * @arg @ref LL_TIM_CHANNEL_CH2
  2125. * @arg @ref LL_TIM_CHANNEL_CH3
  2126. * @arg @ref LL_TIM_CHANNEL_CH4
  2127. * @arg @ref LL_TIM_CHANNEL_CH5
  2128. * @arg @ref LL_TIM_CHANNEL_CH6
  2129. * @retval State of bit (1 or 0).
  2130. */
  2131. __STATIC_INLINE uint32_t LL_TIM_OC_IsEnabledPreload(TIM_TypeDef *TIMx, uint32_t Channel)
  2132. {
  2133. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2134. register const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2135. register uint32_t bitfield = TIM_CCMR1_OC1PE << SHIFT_TAB_OCxx[iChannel];
  2136. return ((READ_BIT(*pReg, bitfield) == bitfield) ? 1UL : 0UL);
  2137. }
  2138. /**
  2139. * @brief Enable clearing the output channel on an external event.
  2140. * @note This function can only be used in Output compare and PWM modes. It does not work in Forced mode.
  2141. * @note Macro IS_TIM_OCXREF_CLEAR_INSTANCE(TIMx) can be used to check whether
  2142. * or not a timer instance can clear the OCxREF signal on an external event.
  2143. * @rmtoll CCMR1 OC1CE LL_TIM_OC_EnableClear\n
  2144. * CCMR1 OC2CE LL_TIM_OC_EnableClear\n
  2145. * CCMR2 OC3CE LL_TIM_OC_EnableClear\n
  2146. * CCMR2 OC4CE LL_TIM_OC_EnableClear\n
  2147. * CCMR3 OC5CE LL_TIM_OC_EnableClear\n
  2148. * CCMR3 OC6CE LL_TIM_OC_EnableClear
  2149. * @param TIMx Timer instance
  2150. * @param Channel This parameter can be one of the following values:
  2151. * @arg @ref LL_TIM_CHANNEL_CH1
  2152. * @arg @ref LL_TIM_CHANNEL_CH2
  2153. * @arg @ref LL_TIM_CHANNEL_CH3
  2154. * @arg @ref LL_TIM_CHANNEL_CH4
  2155. * @arg @ref LL_TIM_CHANNEL_CH5
  2156. * @arg @ref LL_TIM_CHANNEL_CH6
  2157. * @retval None
  2158. */
  2159. __STATIC_INLINE void LL_TIM_OC_EnableClear(TIM_TypeDef *TIMx, uint32_t Channel)
  2160. {
  2161. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2162. register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2163. SET_BIT(*pReg, (TIM_CCMR1_OC1CE << SHIFT_TAB_OCxx[iChannel]));
  2164. }
  2165. /**
  2166. * @brief Disable clearing the output channel on an external event.
  2167. * @note Macro IS_TIM_OCXREF_CLEAR_INSTANCE(TIMx) can be used to check whether
  2168. * or not a timer instance can clear the OCxREF signal on an external event.
  2169. * @rmtoll CCMR1 OC1CE LL_TIM_OC_DisableClear\n
  2170. * CCMR1 OC2CE LL_TIM_OC_DisableClear\n
  2171. * CCMR2 OC3CE LL_TIM_OC_DisableClear\n
  2172. * CCMR2 OC4CE LL_TIM_OC_DisableClear\n
  2173. * CCMR3 OC5CE LL_TIM_OC_DisableClear\n
  2174. * CCMR3 OC6CE LL_TIM_OC_DisableClear
  2175. * @param TIMx Timer instance
  2176. * @param Channel This parameter can be one of the following values:
  2177. * @arg @ref LL_TIM_CHANNEL_CH1
  2178. * @arg @ref LL_TIM_CHANNEL_CH2
  2179. * @arg @ref LL_TIM_CHANNEL_CH3
  2180. * @arg @ref LL_TIM_CHANNEL_CH4
  2181. * @arg @ref LL_TIM_CHANNEL_CH5
  2182. * @arg @ref LL_TIM_CHANNEL_CH6
  2183. * @retval None
  2184. */
  2185. __STATIC_INLINE void LL_TIM_OC_DisableClear(TIM_TypeDef *TIMx, uint32_t Channel)
  2186. {
  2187. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2188. register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2189. CLEAR_BIT(*pReg, (TIM_CCMR1_OC1CE << SHIFT_TAB_OCxx[iChannel]));
  2190. }
  2191. /**
  2192. * @brief Indicates clearing the output channel on an external event is enabled for the output channel.
  2193. * @note This function enables clearing the output channel on an external event.
  2194. * @note This function can only be used in Output compare and PWM modes. It does not work in Forced mode.
  2195. * @note Macro IS_TIM_OCXREF_CLEAR_INSTANCE(TIMx) can be used to check whether
  2196. * or not a timer instance can clear the OCxREF signal on an external event.
  2197. * @rmtoll CCMR1 OC1CE LL_TIM_OC_IsEnabledClear\n
  2198. * CCMR1 OC2CE LL_TIM_OC_IsEnabledClear\n
  2199. * CCMR2 OC3CE LL_TIM_OC_IsEnabledClear\n
  2200. * CCMR2 OC4CE LL_TIM_OC_IsEnabledClear\n
  2201. * CCMR3 OC5CE LL_TIM_OC_IsEnabledClear\n
  2202. * CCMR3 OC6CE LL_TIM_OC_IsEnabledClear
  2203. * @param TIMx Timer instance
  2204. * @param Channel This parameter can be one of the following values:
  2205. * @arg @ref LL_TIM_CHANNEL_CH1
  2206. * @arg @ref LL_TIM_CHANNEL_CH2
  2207. * @arg @ref LL_TIM_CHANNEL_CH3
  2208. * @arg @ref LL_TIM_CHANNEL_CH4
  2209. * @arg @ref LL_TIM_CHANNEL_CH5
  2210. * @arg @ref LL_TIM_CHANNEL_CH6
  2211. * @retval State of bit (1 or 0).
  2212. */
  2213. __STATIC_INLINE uint32_t LL_TIM_OC_IsEnabledClear(TIM_TypeDef *TIMx, uint32_t Channel)
  2214. {
  2215. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2216. register const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2217. register uint32_t bitfield = TIM_CCMR1_OC1CE << SHIFT_TAB_OCxx[iChannel];
  2218. return ((READ_BIT(*pReg, bitfield) == bitfield) ? 1UL : 0UL);
  2219. }
  2220. /**
  2221. * @brief Set the dead-time delay (delay inserted between the rising edge of the OCxREF signal and the rising edge of the Ocx and OCxN signals).
  2222. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2223. * dead-time insertion feature is supported by a timer instance.
  2224. * @note Helper macro @ref __LL_TIM_CALC_DEADTIME can be used to calculate the DeadTime parameter
  2225. * @rmtoll BDTR DTG LL_TIM_OC_SetDeadTime
  2226. * @param TIMx Timer instance
  2227. * @param DeadTime between Min_Data=0 and Max_Data=255
  2228. * @retval None
  2229. */
  2230. __STATIC_INLINE void LL_TIM_OC_SetDeadTime(TIM_TypeDef *TIMx, uint32_t DeadTime)
  2231. {
  2232. MODIFY_REG(TIMx->BDTR, TIM_BDTR_DTG, DeadTime);
  2233. }
  2234. /**
  2235. * @brief Set compare value for output channel 1 (TIMx_CCR1).
  2236. * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
  2237. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2238. * whether or not a timer instance supports a 32 bits counter.
  2239. * @note Macro IS_TIM_CC1_INSTANCE(TIMx) can be used to check whether or not
  2240. * output channel 1 is supported by a timer instance.
  2241. * @rmtoll CCR1 CCR1 LL_TIM_OC_SetCompareCH1
  2242. * @param TIMx Timer instance
  2243. * @param CompareValue between Min_Data=0 and Max_Data=65535
  2244. * @retval None
  2245. */
  2246. __STATIC_INLINE void LL_TIM_OC_SetCompareCH1(TIM_TypeDef *TIMx, uint32_t CompareValue)
  2247. {
  2248. WRITE_REG(TIMx->CCR1, CompareValue);
  2249. }
  2250. /**
  2251. * @brief Set compare value for output channel 2 (TIMx_CCR2).
  2252. * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
  2253. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2254. * whether or not a timer instance supports a 32 bits counter.
  2255. * @note Macro IS_TIM_CC2_INSTANCE(TIMx) can be used to check whether or not
  2256. * output channel 2 is supported by a timer instance.
  2257. * @rmtoll CCR2 CCR2 LL_TIM_OC_SetCompareCH2
  2258. * @param TIMx Timer instance
  2259. * @param CompareValue between Min_Data=0 and Max_Data=65535
  2260. * @retval None
  2261. */
  2262. __STATIC_INLINE void LL_TIM_OC_SetCompareCH2(TIM_TypeDef *TIMx, uint32_t CompareValue)
  2263. {
  2264. WRITE_REG(TIMx->CCR2, CompareValue);
  2265. }
  2266. /**
  2267. * @brief Set compare value for output channel 3 (TIMx_CCR3).
  2268. * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
  2269. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2270. * whether or not a timer instance supports a 32 bits counter.
  2271. * @note Macro IS_TIM_CC3_INSTANCE(TIMx) can be used to check whether or not
  2272. * output channel is supported by a timer instance.
  2273. * @rmtoll CCR3 CCR3 LL_TIM_OC_SetCompareCH3
  2274. * @param TIMx Timer instance
  2275. * @param CompareValue between Min_Data=0 and Max_Data=65535
  2276. * @retval None
  2277. */
  2278. __STATIC_INLINE void LL_TIM_OC_SetCompareCH3(TIM_TypeDef *TIMx, uint32_t CompareValue)
  2279. {
  2280. WRITE_REG(TIMx->CCR3, CompareValue);
  2281. }
  2282. /**
  2283. * @brief Set compare value for output channel 4 (TIMx_CCR4).
  2284. * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
  2285. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2286. * whether or not a timer instance supports a 32 bits counter.
  2287. * @note Macro IS_TIM_CC4_INSTANCE(TIMx) can be used to check whether or not
  2288. * output channel 4 is supported by a timer instance.
  2289. * @rmtoll CCR4 CCR4 LL_TIM_OC_SetCompareCH4
  2290. * @param TIMx Timer instance
  2291. * @param CompareValue between Min_Data=0 and Max_Data=65535
  2292. * @retval None
  2293. */
  2294. __STATIC_INLINE void LL_TIM_OC_SetCompareCH4(TIM_TypeDef *TIMx, uint32_t CompareValue)
  2295. {
  2296. WRITE_REG(TIMx->CCR4, CompareValue);
  2297. }
  2298. /**
  2299. * @brief Set compare value for output channel 5 (TIMx_CCR5).
  2300. * @note Macro IS_TIM_CC5_INSTANCE(TIMx) can be used to check whether or not
  2301. * output channel 5 is supported by a timer instance.
  2302. * @rmtoll CCR5 CCR5 LL_TIM_OC_SetCompareCH5
  2303. * @param TIMx Timer instance
  2304. * @param CompareValue between Min_Data=0 and Max_Data=65535
  2305. * @retval None
  2306. */
  2307. __STATIC_INLINE void LL_TIM_OC_SetCompareCH5(TIM_TypeDef *TIMx, uint32_t CompareValue)
  2308. {
  2309. MODIFY_REG(TIMx->CCR5, TIM_CCR5_CCR5, CompareValue);
  2310. }
  2311. /**
  2312. * @brief Set compare value for output channel 6 (TIMx_CCR6).
  2313. * @note Macro IS_TIM_CC6_INSTANCE(TIMx) can be used to check whether or not
  2314. * output channel 6 is supported by a timer instance.
  2315. * @rmtoll CCR6 CCR6 LL_TIM_OC_SetCompareCH6
  2316. * @param TIMx Timer instance
  2317. * @param CompareValue between Min_Data=0 and Max_Data=65535
  2318. * @retval None
  2319. */
  2320. __STATIC_INLINE void LL_TIM_OC_SetCompareCH6(TIM_TypeDef *TIMx, uint32_t CompareValue)
  2321. {
  2322. WRITE_REG(TIMx->CCR6, CompareValue);
  2323. }
  2324. /**
  2325. * @brief Get compare value (TIMx_CCR1) set for output channel 1.
  2326. * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
  2327. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2328. * whether or not a timer instance supports a 32 bits counter.
  2329. * @note Macro IS_TIM_CC1_INSTANCE(TIMx) can be used to check whether or not
  2330. * output channel 1 is supported by a timer instance.
  2331. * @rmtoll CCR1 CCR1 LL_TIM_OC_GetCompareCH1
  2332. * @param TIMx Timer instance
  2333. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  2334. */
  2335. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH1(TIM_TypeDef *TIMx)
  2336. {
  2337. return (uint32_t)(READ_REG(TIMx->CCR1));
  2338. }
  2339. /**
  2340. * @brief Get compare value (TIMx_CCR2) set for output channel 2.
  2341. * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
  2342. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2343. * whether or not a timer instance supports a 32 bits counter.
  2344. * @note Macro IS_TIM_CC2_INSTANCE(TIMx) can be used to check whether or not
  2345. * output channel 2 is supported by a timer instance.
  2346. * @rmtoll CCR2 CCR2 LL_TIM_OC_GetCompareCH2
  2347. * @param TIMx Timer instance
  2348. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  2349. */
  2350. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH2(TIM_TypeDef *TIMx)
  2351. {
  2352. return (uint32_t)(READ_REG(TIMx->CCR2));
  2353. }
  2354. /**
  2355. * @brief Get compare value (TIMx_CCR3) set for output channel 3.
  2356. * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
  2357. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2358. * whether or not a timer instance supports a 32 bits counter.
  2359. * @note Macro IS_TIM_CC3_INSTANCE(TIMx) can be used to check whether or not
  2360. * output channel 3 is supported by a timer instance.
  2361. * @rmtoll CCR3 CCR3 LL_TIM_OC_GetCompareCH3
  2362. * @param TIMx Timer instance
  2363. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  2364. */
  2365. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH3(TIM_TypeDef *TIMx)
  2366. {
  2367. return (uint32_t)(READ_REG(TIMx->CCR3));
  2368. }
  2369. /**
  2370. * @brief Get compare value (TIMx_CCR4) set for output channel 4.
  2371. * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
  2372. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2373. * whether or not a timer instance supports a 32 bits counter.
  2374. * @note Macro IS_TIM_CC4_INSTANCE(TIMx) can be used to check whether or not
  2375. * output channel 4 is supported by a timer instance.
  2376. * @rmtoll CCR4 CCR4 LL_TIM_OC_GetCompareCH4
  2377. * @param TIMx Timer instance
  2378. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  2379. */
  2380. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH4(TIM_TypeDef *TIMx)
  2381. {
  2382. return (uint32_t)(READ_REG(TIMx->CCR4));
  2383. }
  2384. /**
  2385. * @brief Get compare value (TIMx_CCR5) set for output channel 5.
  2386. * @note Macro IS_TIM_CC5_INSTANCE(TIMx) can be used to check whether or not
  2387. * output channel 5 is supported by a timer instance.
  2388. * @rmtoll CCR5 CCR5 LL_TIM_OC_GetCompareCH5
  2389. * @param TIMx Timer instance
  2390. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  2391. */
  2392. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH5(TIM_TypeDef *TIMx)
  2393. {
  2394. return (uint32_t)(READ_BIT(TIMx->CCR5, TIM_CCR5_CCR5));
  2395. }
  2396. /**
  2397. * @brief Get compare value (TIMx_CCR6) set for output channel 6.
  2398. * @note Macro IS_TIM_CC6_INSTANCE(TIMx) can be used to check whether or not
  2399. * output channel 6 is supported by a timer instance.
  2400. * @rmtoll CCR6 CCR6 LL_TIM_OC_GetCompareCH6
  2401. * @param TIMx Timer instance
  2402. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  2403. */
  2404. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH6(TIM_TypeDef *TIMx)
  2405. {
  2406. return (uint32_t)(READ_REG(TIMx->CCR6));
  2407. }
  2408. /**
  2409. * @brief Select on which reference signal the OC5REF is combined to.
  2410. * @note Macro IS_TIM_COMBINED3PHASEPWM_INSTANCE(TIMx) can be used to check
  2411. * whether or not a timer instance supports the combined 3-phase PWM mode.
  2412. * @rmtoll CCR5 GC5C3 LL_TIM_SetCH5CombinedChannels\n
  2413. * CCR5 GC5C2 LL_TIM_SetCH5CombinedChannels\n
  2414. * CCR5 GC5C1 LL_TIM_SetCH5CombinedChannels
  2415. * @param TIMx Timer instance
  2416. * @param GroupCH5 This parameter can be a combination of the following values:
  2417. * @arg @ref LL_TIM_GROUPCH5_NONE
  2418. * @arg @ref LL_TIM_GROUPCH5_OC1REFC
  2419. * @arg @ref LL_TIM_GROUPCH5_OC2REFC
  2420. * @arg @ref LL_TIM_GROUPCH5_OC3REFC
  2421. * @retval None
  2422. */
  2423. __STATIC_INLINE void LL_TIM_SetCH5CombinedChannels(TIM_TypeDef *TIMx, uint32_t GroupCH5)
  2424. {
  2425. MODIFY_REG(TIMx->CCR5, (TIM_CCR5_GC5C3 | TIM_CCR5_GC5C2 | TIM_CCR5_GC5C1), GroupCH5);
  2426. }
  2427. /**
  2428. * @}
  2429. */
  2430. /** @defgroup TIM_LL_EF_Input_Channel Input channel configuration
  2431. * @{
  2432. */
  2433. /**
  2434. * @brief Configure input channel.
  2435. * @rmtoll CCMR1 CC1S LL_TIM_IC_Config\n
  2436. * CCMR1 IC1PSC LL_TIM_IC_Config\n
  2437. * CCMR1 IC1F LL_TIM_IC_Config\n
  2438. * CCMR1 CC2S LL_TIM_IC_Config\n
  2439. * CCMR1 IC2PSC LL_TIM_IC_Config\n
  2440. * CCMR1 IC2F LL_TIM_IC_Config\n
  2441. * CCMR2 CC3S LL_TIM_IC_Config\n
  2442. * CCMR2 IC3PSC LL_TIM_IC_Config\n
  2443. * CCMR2 IC3F LL_TIM_IC_Config\n
  2444. * CCMR2 CC4S LL_TIM_IC_Config\n
  2445. * CCMR2 IC4PSC LL_TIM_IC_Config\n
  2446. * CCMR2 IC4F LL_TIM_IC_Config\n
  2447. * CCER CC1P LL_TIM_IC_Config\n
  2448. * CCER CC1NP LL_TIM_IC_Config\n
  2449. * CCER CC2P LL_TIM_IC_Config\n
  2450. * CCER CC2NP LL_TIM_IC_Config\n
  2451. * CCER CC3P LL_TIM_IC_Config\n
  2452. * CCER CC3NP LL_TIM_IC_Config\n
  2453. * CCER CC4P LL_TIM_IC_Config\n
  2454. * CCER CC4NP LL_TIM_IC_Config
  2455. * @param TIMx Timer instance
  2456. * @param Channel This parameter can be one of the following values:
  2457. * @arg @ref LL_TIM_CHANNEL_CH1
  2458. * @arg @ref LL_TIM_CHANNEL_CH2
  2459. * @arg @ref LL_TIM_CHANNEL_CH3
  2460. * @arg @ref LL_TIM_CHANNEL_CH4
  2461. * @param Configuration This parameter must be a combination of all the following values:
  2462. * @arg @ref LL_TIM_ACTIVEINPUT_DIRECTTI or @ref LL_TIM_ACTIVEINPUT_INDIRECTTI or @ref LL_TIM_ACTIVEINPUT_TRC
  2463. * @arg @ref LL_TIM_ICPSC_DIV1 or ... or @ref LL_TIM_ICPSC_DIV8
  2464. * @arg @ref LL_TIM_IC_FILTER_FDIV1 or ... or @ref LL_TIM_IC_FILTER_FDIV32_N8
  2465. * @arg @ref LL_TIM_IC_POLARITY_RISING or @ref LL_TIM_IC_POLARITY_FALLING or @ref LL_TIM_IC_POLARITY_BOTHEDGE
  2466. * @retval None
  2467. */
  2468. __STATIC_INLINE void LL_TIM_IC_Config(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Configuration)
  2469. {
  2470. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2471. register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2472. MODIFY_REG(*pReg, ((TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC | TIM_CCMR1_CC1S) << SHIFT_TAB_ICxx[iChannel]),
  2473. ((Configuration >> 16U) & (TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC | TIM_CCMR1_CC1S)) << SHIFT_TAB_ICxx[iChannel]);
  2474. MODIFY_REG(TIMx->CCER, ((TIM_CCER_CC1NP | TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel]),
  2475. (Configuration & (TIM_CCER_CC1NP | TIM_CCER_CC1P)) << SHIFT_TAB_CCxP[iChannel]);
  2476. }
  2477. /**
  2478. * @brief Set the active input.
  2479. * @rmtoll CCMR1 CC1S LL_TIM_IC_SetActiveInput\n
  2480. * CCMR1 CC2S LL_TIM_IC_SetActiveInput\n
  2481. * CCMR2 CC3S LL_TIM_IC_SetActiveInput\n
  2482. * CCMR2 CC4S LL_TIM_IC_SetActiveInput
  2483. * @param TIMx Timer instance
  2484. * @param Channel This parameter can be one of the following values:
  2485. * @arg @ref LL_TIM_CHANNEL_CH1
  2486. * @arg @ref LL_TIM_CHANNEL_CH2
  2487. * @arg @ref LL_TIM_CHANNEL_CH3
  2488. * @arg @ref LL_TIM_CHANNEL_CH4
  2489. * @param ICActiveInput This parameter can be one of the following values:
  2490. * @arg @ref LL_TIM_ACTIVEINPUT_DIRECTTI
  2491. * @arg @ref LL_TIM_ACTIVEINPUT_INDIRECTTI
  2492. * @arg @ref LL_TIM_ACTIVEINPUT_TRC
  2493. * @retval None
  2494. */
  2495. __STATIC_INLINE void LL_TIM_IC_SetActiveInput(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICActiveInput)
  2496. {
  2497. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2498. register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2499. MODIFY_REG(*pReg, ((TIM_CCMR1_CC1S) << SHIFT_TAB_ICxx[iChannel]), (ICActiveInput >> 16U) << SHIFT_TAB_ICxx[iChannel]);
  2500. }
  2501. /**
  2502. * @brief Get the current active input.
  2503. * @rmtoll CCMR1 CC1S LL_TIM_IC_GetActiveInput\n
  2504. * CCMR1 CC2S LL_TIM_IC_GetActiveInput\n
  2505. * CCMR2 CC3S LL_TIM_IC_GetActiveInput\n
  2506. * CCMR2 CC4S LL_TIM_IC_GetActiveInput
  2507. * @param TIMx Timer instance
  2508. * @param Channel This parameter can be one of the following values:
  2509. * @arg @ref LL_TIM_CHANNEL_CH1
  2510. * @arg @ref LL_TIM_CHANNEL_CH2
  2511. * @arg @ref LL_TIM_CHANNEL_CH3
  2512. * @arg @ref LL_TIM_CHANNEL_CH4
  2513. * @retval Returned value can be one of the following values:
  2514. * @arg @ref LL_TIM_ACTIVEINPUT_DIRECTTI
  2515. * @arg @ref LL_TIM_ACTIVEINPUT_INDIRECTTI
  2516. * @arg @ref LL_TIM_ACTIVEINPUT_TRC
  2517. */
  2518. __STATIC_INLINE uint32_t LL_TIM_IC_GetActiveInput(TIM_TypeDef *TIMx, uint32_t Channel)
  2519. {
  2520. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2521. register const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2522. return ((READ_BIT(*pReg, ((TIM_CCMR1_CC1S) << SHIFT_TAB_ICxx[iChannel])) >> SHIFT_TAB_ICxx[iChannel]) << 16U);
  2523. }
  2524. /**
  2525. * @brief Set the prescaler of input channel.
  2526. * @rmtoll CCMR1 IC1PSC LL_TIM_IC_SetPrescaler\n
  2527. * CCMR1 IC2PSC LL_TIM_IC_SetPrescaler\n
  2528. * CCMR2 IC3PSC LL_TIM_IC_SetPrescaler\n
  2529. * CCMR2 IC4PSC LL_TIM_IC_SetPrescaler
  2530. * @param TIMx Timer instance
  2531. * @param Channel This parameter can be one of the following values:
  2532. * @arg @ref LL_TIM_CHANNEL_CH1
  2533. * @arg @ref LL_TIM_CHANNEL_CH2
  2534. * @arg @ref LL_TIM_CHANNEL_CH3
  2535. * @arg @ref LL_TIM_CHANNEL_CH4
  2536. * @param ICPrescaler This parameter can be one of the following values:
  2537. * @arg @ref LL_TIM_ICPSC_DIV1
  2538. * @arg @ref LL_TIM_ICPSC_DIV2
  2539. * @arg @ref LL_TIM_ICPSC_DIV4
  2540. * @arg @ref LL_TIM_ICPSC_DIV8
  2541. * @retval None
  2542. */
  2543. __STATIC_INLINE void LL_TIM_IC_SetPrescaler(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICPrescaler)
  2544. {
  2545. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2546. register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2547. MODIFY_REG(*pReg, ((TIM_CCMR1_IC1PSC) << SHIFT_TAB_ICxx[iChannel]), (ICPrescaler >> 16U) << SHIFT_TAB_ICxx[iChannel]);
  2548. }
  2549. /**
  2550. * @brief Get the current prescaler value acting on an input channel.
  2551. * @rmtoll CCMR1 IC1PSC LL_TIM_IC_GetPrescaler\n
  2552. * CCMR1 IC2PSC LL_TIM_IC_GetPrescaler\n
  2553. * CCMR2 IC3PSC LL_TIM_IC_GetPrescaler\n
  2554. * CCMR2 IC4PSC LL_TIM_IC_GetPrescaler
  2555. * @param TIMx Timer instance
  2556. * @param Channel This parameter can be one of the following values:
  2557. * @arg @ref LL_TIM_CHANNEL_CH1
  2558. * @arg @ref LL_TIM_CHANNEL_CH2
  2559. * @arg @ref LL_TIM_CHANNEL_CH3
  2560. * @arg @ref LL_TIM_CHANNEL_CH4
  2561. * @retval Returned value can be one of the following values:
  2562. * @arg @ref LL_TIM_ICPSC_DIV1
  2563. * @arg @ref LL_TIM_ICPSC_DIV2
  2564. * @arg @ref LL_TIM_ICPSC_DIV4
  2565. * @arg @ref LL_TIM_ICPSC_DIV8
  2566. */
  2567. __STATIC_INLINE uint32_t LL_TIM_IC_GetPrescaler(TIM_TypeDef *TIMx, uint32_t Channel)
  2568. {
  2569. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2570. register const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2571. return ((READ_BIT(*pReg, ((TIM_CCMR1_IC1PSC) << SHIFT_TAB_ICxx[iChannel])) >> SHIFT_TAB_ICxx[iChannel]) << 16U);
  2572. }
  2573. /**
  2574. * @brief Set the input filter duration.
  2575. * @rmtoll CCMR1 IC1F LL_TIM_IC_SetFilter\n
  2576. * CCMR1 IC2F LL_TIM_IC_SetFilter\n
  2577. * CCMR2 IC3F LL_TIM_IC_SetFilter\n
  2578. * CCMR2 IC4F LL_TIM_IC_SetFilter
  2579. * @param TIMx Timer instance
  2580. * @param Channel This parameter can be one of the following values:
  2581. * @arg @ref LL_TIM_CHANNEL_CH1
  2582. * @arg @ref LL_TIM_CHANNEL_CH2
  2583. * @arg @ref LL_TIM_CHANNEL_CH3
  2584. * @arg @ref LL_TIM_CHANNEL_CH4
  2585. * @param ICFilter This parameter can be one of the following values:
  2586. * @arg @ref LL_TIM_IC_FILTER_FDIV1
  2587. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N2
  2588. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N4
  2589. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N8
  2590. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N6
  2591. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N8
  2592. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N6
  2593. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N8
  2594. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N6
  2595. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N8
  2596. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N5
  2597. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N6
  2598. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N8
  2599. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N5
  2600. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N6
  2601. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N8
  2602. * @retval None
  2603. */
  2604. __STATIC_INLINE void LL_TIM_IC_SetFilter(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICFilter)
  2605. {
  2606. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2607. register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2608. MODIFY_REG(*pReg, ((TIM_CCMR1_IC1F) << SHIFT_TAB_ICxx[iChannel]), (ICFilter >> 16U) << SHIFT_TAB_ICxx[iChannel]);
  2609. }
  2610. /**
  2611. * @brief Get the input filter duration.
  2612. * @rmtoll CCMR1 IC1F LL_TIM_IC_GetFilter\n
  2613. * CCMR1 IC2F LL_TIM_IC_GetFilter\n
  2614. * CCMR2 IC3F LL_TIM_IC_GetFilter\n
  2615. * CCMR2 IC4F LL_TIM_IC_GetFilter
  2616. * @param TIMx Timer instance
  2617. * @param Channel This parameter can be one of the following values:
  2618. * @arg @ref LL_TIM_CHANNEL_CH1
  2619. * @arg @ref LL_TIM_CHANNEL_CH2
  2620. * @arg @ref LL_TIM_CHANNEL_CH3
  2621. * @arg @ref LL_TIM_CHANNEL_CH4
  2622. * @retval Returned value can be one of the following values:
  2623. * @arg @ref LL_TIM_IC_FILTER_FDIV1
  2624. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N2
  2625. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N4
  2626. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N8
  2627. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N6
  2628. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N8
  2629. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N6
  2630. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N8
  2631. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N6
  2632. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N8
  2633. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N5
  2634. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N6
  2635. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N8
  2636. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N5
  2637. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N6
  2638. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N8
  2639. */
  2640. __STATIC_INLINE uint32_t LL_TIM_IC_GetFilter(TIM_TypeDef *TIMx, uint32_t Channel)
  2641. {
  2642. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2643. register const __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2644. return ((READ_BIT(*pReg, ((TIM_CCMR1_IC1F) << SHIFT_TAB_ICxx[iChannel])) >> SHIFT_TAB_ICxx[iChannel]) << 16U);
  2645. }
  2646. /**
  2647. * @brief Set the input channel polarity.
  2648. * @rmtoll CCER CC1P LL_TIM_IC_SetPolarity\n
  2649. * CCER CC1NP LL_TIM_IC_SetPolarity\n
  2650. * CCER CC2P LL_TIM_IC_SetPolarity\n
  2651. * CCER CC2NP LL_TIM_IC_SetPolarity\n
  2652. * CCER CC3P LL_TIM_IC_SetPolarity\n
  2653. * CCER CC3NP LL_TIM_IC_SetPolarity\n
  2654. * CCER CC4P LL_TIM_IC_SetPolarity\n
  2655. * CCER CC4NP LL_TIM_IC_SetPolarity
  2656. * @param TIMx Timer instance
  2657. * @param Channel This parameter can be one of the following values:
  2658. * @arg @ref LL_TIM_CHANNEL_CH1
  2659. * @arg @ref LL_TIM_CHANNEL_CH2
  2660. * @arg @ref LL_TIM_CHANNEL_CH3
  2661. * @arg @ref LL_TIM_CHANNEL_CH4
  2662. * @param ICPolarity This parameter can be one of the following values:
  2663. * @arg @ref LL_TIM_IC_POLARITY_RISING
  2664. * @arg @ref LL_TIM_IC_POLARITY_FALLING
  2665. * @arg @ref LL_TIM_IC_POLARITY_BOTHEDGE
  2666. * @retval None
  2667. */
  2668. __STATIC_INLINE void LL_TIM_IC_SetPolarity(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICPolarity)
  2669. {
  2670. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2671. MODIFY_REG(TIMx->CCER, ((TIM_CCER_CC1NP | TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel]),
  2672. ICPolarity << SHIFT_TAB_CCxP[iChannel]);
  2673. }
  2674. /**
  2675. * @brief Get the current input channel polarity.
  2676. * @rmtoll CCER CC1P LL_TIM_IC_GetPolarity\n
  2677. * CCER CC1NP LL_TIM_IC_GetPolarity\n
  2678. * CCER CC2P LL_TIM_IC_GetPolarity\n
  2679. * CCER CC2NP LL_TIM_IC_GetPolarity\n
  2680. * CCER CC3P LL_TIM_IC_GetPolarity\n
  2681. * CCER CC3NP LL_TIM_IC_GetPolarity\n
  2682. * CCER CC4P LL_TIM_IC_GetPolarity\n
  2683. * CCER CC4NP LL_TIM_IC_GetPolarity
  2684. * @param TIMx Timer instance
  2685. * @param Channel This parameter can be one of the following values:
  2686. * @arg @ref LL_TIM_CHANNEL_CH1
  2687. * @arg @ref LL_TIM_CHANNEL_CH2
  2688. * @arg @ref LL_TIM_CHANNEL_CH3
  2689. * @arg @ref LL_TIM_CHANNEL_CH4
  2690. * @retval Returned value can be one of the following values:
  2691. * @arg @ref LL_TIM_IC_POLARITY_RISING
  2692. * @arg @ref LL_TIM_IC_POLARITY_FALLING
  2693. * @arg @ref LL_TIM_IC_POLARITY_BOTHEDGE
  2694. */
  2695. __STATIC_INLINE uint32_t LL_TIM_IC_GetPolarity(TIM_TypeDef *TIMx, uint32_t Channel)
  2696. {
  2697. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2698. return (READ_BIT(TIMx->CCER, ((TIM_CCER_CC1NP | TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel])) >>
  2699. SHIFT_TAB_CCxP[iChannel]);
  2700. }
  2701. /**
  2702. * @brief Connect the TIMx_CH1, CH2 and CH3 pins to the TI1 input (XOR combination).
  2703. * @note Macro IS_TIM_XOR_INSTANCE(TIMx) can be used to check whether or not
  2704. * a timer instance provides an XOR input.
  2705. * @rmtoll CR2 TI1S LL_TIM_IC_EnableXORCombination
  2706. * @param TIMx Timer instance
  2707. * @retval None
  2708. */
  2709. __STATIC_INLINE void LL_TIM_IC_EnableXORCombination(TIM_TypeDef *TIMx)
  2710. {
  2711. SET_BIT(TIMx->CR2, TIM_CR2_TI1S);
  2712. }
  2713. /**
  2714. * @brief Disconnect the TIMx_CH1, CH2 and CH3 pins from the TI1 input.
  2715. * @note Macro IS_TIM_XOR_INSTANCE(TIMx) can be used to check whether or not
  2716. * a timer instance provides an XOR input.
  2717. * @rmtoll CR2 TI1S LL_TIM_IC_DisableXORCombination
  2718. * @param TIMx Timer instance
  2719. * @retval None
  2720. */
  2721. __STATIC_INLINE void LL_TIM_IC_DisableXORCombination(TIM_TypeDef *TIMx)
  2722. {
  2723. CLEAR_BIT(TIMx->CR2, TIM_CR2_TI1S);
  2724. }
  2725. /**
  2726. * @brief Indicates whether the TIMx_CH1, CH2 and CH3 pins are connectected to the TI1 input.
  2727. * @note Macro IS_TIM_XOR_INSTANCE(TIMx) can be used to check whether or not
  2728. * a timer instance provides an XOR input.
  2729. * @rmtoll CR2 TI1S LL_TIM_IC_IsEnabledXORCombination
  2730. * @param TIMx Timer instance
  2731. * @retval State of bit (1 or 0).
  2732. */
  2733. __STATIC_INLINE uint32_t LL_TIM_IC_IsEnabledXORCombination(TIM_TypeDef *TIMx)
  2734. {
  2735. return ((READ_BIT(TIMx->CR2, TIM_CR2_TI1S) == (TIM_CR2_TI1S)) ? 1UL : 0UL);
  2736. }
  2737. /**
  2738. * @brief Get captured value for input channel 1.
  2739. * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
  2740. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2741. * whether or not a timer instance supports a 32 bits counter.
  2742. * @note Macro IS_TIM_CC1_INSTANCE(TIMx) can be used to check whether or not
  2743. * input channel 1 is supported by a timer instance.
  2744. * @rmtoll CCR1 CCR1 LL_TIM_IC_GetCaptureCH1
  2745. * @param TIMx Timer instance
  2746. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  2747. */
  2748. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH1(TIM_TypeDef *TIMx)
  2749. {
  2750. return (uint32_t)(READ_REG(TIMx->CCR1));
  2751. }
  2752. /**
  2753. * @brief Get captured value for input channel 2.
  2754. * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
  2755. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2756. * whether or not a timer instance supports a 32 bits counter.
  2757. * @note Macro IS_TIM_CC2_INSTANCE(TIMx) can be used to check whether or not
  2758. * input channel 2 is supported by a timer instance.
  2759. * @rmtoll CCR2 CCR2 LL_TIM_IC_GetCaptureCH2
  2760. * @param TIMx Timer instance
  2761. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  2762. */
  2763. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH2(TIM_TypeDef *TIMx)
  2764. {
  2765. return (uint32_t)(READ_REG(TIMx->CCR2));
  2766. }
  2767. /**
  2768. * @brief Get captured value for input channel 3.
  2769. * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
  2770. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2771. * whether or not a timer instance supports a 32 bits counter.
  2772. * @note Macro IS_TIM_CC3_INSTANCE(TIMx) can be used to check whether or not
  2773. * input channel 3 is supported by a timer instance.
  2774. * @rmtoll CCR3 CCR3 LL_TIM_IC_GetCaptureCH3
  2775. * @param TIMx Timer instance
  2776. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  2777. */
  2778. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH3(TIM_TypeDef *TIMx)
  2779. {
  2780. return (uint32_t)(READ_REG(TIMx->CCR3));
  2781. }
  2782. /**
  2783. * @brief Get captured value for input channel 4.
  2784. * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
  2785. * @note Macro IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2786. * whether or not a timer instance supports a 32 bits counter.
  2787. * @note Macro IS_TIM_CC4_INSTANCE(TIMx) can be used to check whether or not
  2788. * input channel 4 is supported by a timer instance.
  2789. * @rmtoll CCR4 CCR4 LL_TIM_IC_GetCaptureCH4
  2790. * @param TIMx Timer instance
  2791. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  2792. */
  2793. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH4(TIM_TypeDef *TIMx)
  2794. {
  2795. return (uint32_t)(READ_REG(TIMx->CCR4));
  2796. }
  2797. /**
  2798. * @}
  2799. */
  2800. /** @defgroup TIM_LL_EF_Clock_Selection Counter clock selection
  2801. * @{
  2802. */
  2803. /**
  2804. * @brief Enable external clock mode 2.
  2805. * @note When external clock mode 2 is enabled the counter is clocked by any active edge on the ETRF signal.
  2806. * @note Macro IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  2807. * whether or not a timer instance supports external clock mode2.
  2808. * @rmtoll SMCR ECE LL_TIM_EnableExternalClock
  2809. * @param TIMx Timer instance
  2810. * @retval None
  2811. */
  2812. __STATIC_INLINE void LL_TIM_EnableExternalClock(TIM_TypeDef *TIMx)
  2813. {
  2814. SET_BIT(TIMx->SMCR, TIM_SMCR_ECE);
  2815. }
  2816. /**
  2817. * @brief Disable external clock mode 2.
  2818. * @note Macro IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  2819. * whether or not a timer instance supports external clock mode2.
  2820. * @rmtoll SMCR ECE LL_TIM_DisableExternalClock
  2821. * @param TIMx Timer instance
  2822. * @retval None
  2823. */
  2824. __STATIC_INLINE void LL_TIM_DisableExternalClock(TIM_TypeDef *TIMx)
  2825. {
  2826. CLEAR_BIT(TIMx->SMCR, TIM_SMCR_ECE);
  2827. }
  2828. /**
  2829. * @brief Indicate whether external clock mode 2 is enabled.
  2830. * @note Macro IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  2831. * whether or not a timer instance supports external clock mode2.
  2832. * @rmtoll SMCR ECE LL_TIM_IsEnabledExternalClock
  2833. * @param TIMx Timer instance
  2834. * @retval State of bit (1 or 0).
  2835. */
  2836. __STATIC_INLINE uint32_t LL_TIM_IsEnabledExternalClock(TIM_TypeDef *TIMx)
  2837. {
  2838. return ((READ_BIT(TIMx->SMCR, TIM_SMCR_ECE) == (TIM_SMCR_ECE)) ? 1UL : 0UL);
  2839. }
  2840. /**
  2841. * @brief Set the clock source of the counter clock.
  2842. * @note when selected clock source is external clock mode 1, the timer input
  2843. * the external clock is applied is selected by calling the @ref LL_TIM_SetTriggerInput()
  2844. * function. This timer input must be configured by calling
  2845. * the @ref LL_TIM_IC_Config() function.
  2846. * @note Macro IS_TIM_CLOCKSOURCE_ETRMODE1_INSTANCE(TIMx) can be used to check
  2847. * whether or not a timer instance supports external clock mode1.
  2848. * @note Macro IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  2849. * whether or not a timer instance supports external clock mode2.
  2850. * @rmtoll SMCR SMS LL_TIM_SetClockSource\n
  2851. * SMCR ECE LL_TIM_SetClockSource
  2852. * @param TIMx Timer instance
  2853. * @param ClockSource This parameter can be one of the following values:
  2854. * @arg @ref LL_TIM_CLOCKSOURCE_INTERNAL
  2855. * @arg @ref LL_TIM_CLOCKSOURCE_EXT_MODE1
  2856. * @arg @ref LL_TIM_CLOCKSOURCE_EXT_MODE2
  2857. * @retval None
  2858. */
  2859. __STATIC_INLINE void LL_TIM_SetClockSource(TIM_TypeDef *TIMx, uint32_t ClockSource)
  2860. {
  2861. MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMS | TIM_SMCR_ECE, ClockSource);
  2862. }
  2863. /**
  2864. * @brief Set the encoder interface mode.
  2865. * @note Macro IS_TIM_ENCODER_INTERFACE_INSTANCE(TIMx) can be used to check
  2866. * whether or not a timer instance supports the encoder mode.
  2867. * @rmtoll SMCR SMS LL_TIM_SetEncoderMode
  2868. * @param TIMx Timer instance
  2869. * @param EncoderMode This parameter can be one of the following values:
  2870. * @arg @ref LL_TIM_ENCODERMODE_X2_TI1
  2871. * @arg @ref LL_TIM_ENCODERMODE_X2_TI2
  2872. * @arg @ref LL_TIM_ENCODERMODE_X4_TI12
  2873. * @retval None
  2874. */
  2875. __STATIC_INLINE void LL_TIM_SetEncoderMode(TIM_TypeDef *TIMx, uint32_t EncoderMode)
  2876. {
  2877. MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMS, EncoderMode);
  2878. }
  2879. /**
  2880. * @}
  2881. */
  2882. /** @defgroup TIM_LL_EF_Timer_Synchronization Timer synchronisation configuration
  2883. * @{
  2884. */
  2885. /**
  2886. * @brief Set the trigger output (TRGO) used for timer synchronization .
  2887. * @note Macro IS_TIM_MASTER_INSTANCE(TIMx) can be used to check
  2888. * whether or not a timer instance can operate as a master timer.
  2889. * @rmtoll CR2 MMS LL_TIM_SetTriggerOutput
  2890. * @param TIMx Timer instance
  2891. * @param TimerSynchronization This parameter can be one of the following values:
  2892. * @arg @ref LL_TIM_TRGO_RESET
  2893. * @arg @ref LL_TIM_TRGO_ENABLE
  2894. * @arg @ref LL_TIM_TRGO_UPDATE
  2895. * @arg @ref LL_TIM_TRGO_CC1IF
  2896. * @arg @ref LL_TIM_TRGO_OC1REF
  2897. * @arg @ref LL_TIM_TRGO_OC2REF
  2898. * @arg @ref LL_TIM_TRGO_OC3REF
  2899. * @arg @ref LL_TIM_TRGO_OC4REF
  2900. * @retval None
  2901. */
  2902. __STATIC_INLINE void LL_TIM_SetTriggerOutput(TIM_TypeDef *TIMx, uint32_t TimerSynchronization)
  2903. {
  2904. MODIFY_REG(TIMx->CR2, TIM_CR2_MMS, TimerSynchronization);
  2905. }
  2906. /**
  2907. * @brief Set the trigger output 2 (TRGO2) used for ADC synchronization .
  2908. * @note Macro IS_TIM_TRGO2_INSTANCE(TIMx) can be used to check
  2909. * whether or not a timer instance can be used for ADC synchronization.
  2910. * @rmtoll CR2 MMS2 LL_TIM_SetTriggerOutput2
  2911. * @param TIMx Timer Instance
  2912. * @param ADCSynchronization This parameter can be one of the following values:
  2913. * @arg @ref LL_TIM_TRGO2_RESET
  2914. * @arg @ref LL_TIM_TRGO2_ENABLE
  2915. * @arg @ref LL_TIM_TRGO2_UPDATE
  2916. * @arg @ref LL_TIM_TRGO2_CC1F
  2917. * @arg @ref LL_TIM_TRGO2_OC1
  2918. * @arg @ref LL_TIM_TRGO2_OC2
  2919. * @arg @ref LL_TIM_TRGO2_OC3
  2920. * @arg @ref LL_TIM_TRGO2_OC4
  2921. * @arg @ref LL_TIM_TRGO2_OC5
  2922. * @arg @ref LL_TIM_TRGO2_OC6
  2923. * @arg @ref LL_TIM_TRGO2_OC4_RISINGFALLING
  2924. * @arg @ref LL_TIM_TRGO2_OC6_RISINGFALLING
  2925. * @arg @ref LL_TIM_TRGO2_OC4_RISING_OC6_RISING
  2926. * @arg @ref LL_TIM_TRGO2_OC4_RISING_OC6_FALLING
  2927. * @arg @ref LL_TIM_TRGO2_OC5_RISING_OC6_RISING
  2928. * @arg @ref LL_TIM_TRGO2_OC5_RISING_OC6_FALLING
  2929. * @retval None
  2930. */
  2931. __STATIC_INLINE void LL_TIM_SetTriggerOutput2(TIM_TypeDef *TIMx, uint32_t ADCSynchronization)
  2932. {
  2933. MODIFY_REG(TIMx->CR2, TIM_CR2_MMS2, ADCSynchronization);
  2934. }
  2935. /**
  2936. * @brief Set the synchronization mode of a slave timer.
  2937. * @note Macro IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  2938. * a timer instance can operate as a slave timer.
  2939. * @rmtoll SMCR SMS LL_TIM_SetSlaveMode
  2940. * @param TIMx Timer instance
  2941. * @param SlaveMode This parameter can be one of the following values:
  2942. * @arg @ref LL_TIM_SLAVEMODE_DISABLED
  2943. * @arg @ref LL_TIM_SLAVEMODE_RESET
  2944. * @arg @ref LL_TIM_SLAVEMODE_GATED
  2945. * @arg @ref LL_TIM_SLAVEMODE_TRIGGER
  2946. * @arg @ref LL_TIM_SLAVEMODE_COMBINED_RESETTRIGGER
  2947. * @retval None
  2948. */
  2949. __STATIC_INLINE void LL_TIM_SetSlaveMode(TIM_TypeDef *TIMx, uint32_t SlaveMode)
  2950. {
  2951. MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMS, SlaveMode);
  2952. }
  2953. /**
  2954. * @brief Set the selects the trigger input to be used to synchronize the counter.
  2955. * @note Macro IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  2956. * a timer instance can operate as a slave timer.
  2957. * @rmtoll SMCR TS LL_TIM_SetTriggerInput
  2958. * @param TIMx Timer instance
  2959. * @param TriggerInput This parameter can be one of the following values:
  2960. * @arg @ref LL_TIM_TS_ITR0
  2961. * @arg @ref LL_TIM_TS_ITR1
  2962. * @arg @ref LL_TIM_TS_ITR2
  2963. * @arg @ref LL_TIM_TS_ITR3
  2964. * @arg @ref LL_TIM_TS_TI1F_ED
  2965. * @arg @ref LL_TIM_TS_TI1FP1
  2966. * @arg @ref LL_TIM_TS_TI2FP2
  2967. * @arg @ref LL_TIM_TS_ETRF
  2968. * @arg @ref LL_TIM_TS_ITR4
  2969. * @arg @ref LL_TIM_TS_ITR5
  2970. * @arg @ref LL_TIM_TS_ITR6
  2971. * @arg @ref LL_TIM_TS_ITR7
  2972. * @arg @ref LL_TIM_TS_ITR8 (*)
  2973. * @arg @ref LL_TIM_TS_ITR9 (*)
  2974. * @arg @ref LL_TIM_TS_ITR10 (*)
  2975. * @arg @ref LL_TIM_TS_ITR11 (*)
  2976. * @arg @ref LL_TIM_TS_ITR12 (*)
  2977. * @arg @ref LL_TIM_TS_ITR13 (*)
  2978. *
  2979. * (*) Value not defined in all devices.
  2980. * @retval None
  2981. */
  2982. __STATIC_INLINE void LL_TIM_SetTriggerInput(TIM_TypeDef *TIMx, uint32_t TriggerInput)
  2983. {
  2984. MODIFY_REG(TIMx->SMCR, TIM_SMCR_TS, TriggerInput);
  2985. }
  2986. /**
  2987. * @brief Enable the Master/Slave mode.
  2988. * @note Macro IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  2989. * a timer instance can operate as a slave timer.
  2990. * @rmtoll SMCR MSM LL_TIM_EnableMasterSlaveMode
  2991. * @param TIMx Timer instance
  2992. * @retval None
  2993. */
  2994. __STATIC_INLINE void LL_TIM_EnableMasterSlaveMode(TIM_TypeDef *TIMx)
  2995. {
  2996. SET_BIT(TIMx->SMCR, TIM_SMCR_MSM);
  2997. }
  2998. /**
  2999. * @brief Disable the Master/Slave mode.
  3000. * @note Macro IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  3001. * a timer instance can operate as a slave timer.
  3002. * @rmtoll SMCR MSM LL_TIM_DisableMasterSlaveMode
  3003. * @param TIMx Timer instance
  3004. * @retval None
  3005. */
  3006. __STATIC_INLINE void LL_TIM_DisableMasterSlaveMode(TIM_TypeDef *TIMx)
  3007. {
  3008. CLEAR_BIT(TIMx->SMCR, TIM_SMCR_MSM);
  3009. }
  3010. /**
  3011. * @brief Indicates whether the Master/Slave mode is enabled.
  3012. * @note Macro IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  3013. * a timer instance can operate as a slave timer.
  3014. * @rmtoll SMCR MSM LL_TIM_IsEnabledMasterSlaveMode
  3015. * @param TIMx Timer instance
  3016. * @retval State of bit (1 or 0).
  3017. */
  3018. __STATIC_INLINE uint32_t LL_TIM_IsEnabledMasterSlaveMode(TIM_TypeDef *TIMx)
  3019. {
  3020. return ((READ_BIT(TIMx->SMCR, TIM_SMCR_MSM) == (TIM_SMCR_MSM)) ? 1UL : 0UL);
  3021. }
  3022. /**
  3023. * @brief Configure the external trigger (ETR) input.
  3024. * @note Macro IS_TIM_ETR_INSTANCE(TIMx) can be used to check whether or not
  3025. * a timer instance provides an external trigger input.
  3026. * @rmtoll SMCR ETP LL_TIM_ConfigETR\n
  3027. * SMCR ETPS LL_TIM_ConfigETR\n
  3028. * SMCR ETF LL_TIM_ConfigETR
  3029. * @param TIMx Timer instance
  3030. * @param ETRPolarity This parameter can be one of the following values:
  3031. * @arg @ref LL_TIM_ETR_POLARITY_NONINVERTED
  3032. * @arg @ref LL_TIM_ETR_POLARITY_INVERTED
  3033. * @param ETRPrescaler This parameter can be one of the following values:
  3034. * @arg @ref LL_TIM_ETR_PRESCALER_DIV1
  3035. * @arg @ref LL_TIM_ETR_PRESCALER_DIV2
  3036. * @arg @ref LL_TIM_ETR_PRESCALER_DIV4
  3037. * @arg @ref LL_TIM_ETR_PRESCALER_DIV8
  3038. * @param ETRFilter This parameter can be one of the following values:
  3039. * @arg @ref LL_TIM_ETR_FILTER_FDIV1
  3040. * @arg @ref LL_TIM_ETR_FILTER_FDIV1_N2
  3041. * @arg @ref LL_TIM_ETR_FILTER_FDIV1_N4
  3042. * @arg @ref LL_TIM_ETR_FILTER_FDIV1_N8
  3043. * @arg @ref LL_TIM_ETR_FILTER_FDIV2_N6
  3044. * @arg @ref LL_TIM_ETR_FILTER_FDIV2_N8
  3045. * @arg @ref LL_TIM_ETR_FILTER_FDIV4_N6
  3046. * @arg @ref LL_TIM_ETR_FILTER_FDIV4_N8
  3047. * @arg @ref LL_TIM_ETR_FILTER_FDIV8_N6
  3048. * @arg @ref LL_TIM_ETR_FILTER_FDIV8_N8
  3049. * @arg @ref LL_TIM_ETR_FILTER_FDIV16_N5
  3050. * @arg @ref LL_TIM_ETR_FILTER_FDIV16_N6
  3051. * @arg @ref LL_TIM_ETR_FILTER_FDIV16_N8
  3052. * @arg @ref LL_TIM_ETR_FILTER_FDIV32_N5
  3053. * @arg @ref LL_TIM_ETR_FILTER_FDIV32_N6
  3054. * @arg @ref LL_TIM_ETR_FILTER_FDIV32_N8
  3055. * @retval None
  3056. */
  3057. __STATIC_INLINE void LL_TIM_ConfigETR(TIM_TypeDef *TIMx, uint32_t ETRPolarity, uint32_t ETRPrescaler,
  3058. uint32_t ETRFilter)
  3059. {
  3060. MODIFY_REG(TIMx->SMCR, TIM_SMCR_ETP | TIM_SMCR_ETPS | TIM_SMCR_ETF, ETRPolarity | ETRPrescaler | ETRFilter);
  3061. }
  3062. /**
  3063. * @brief Select the external trigger (ETR) input source.
  3064. * @note Macro IS_TIM_ETRSEL_INSTANCE(TIMx) can be used to check whether or
  3065. * not a timer instance supports ETR source selection.
  3066. * @rmtoll AF1 ETRSEL LL_TIM_SetETRSource
  3067. * @param TIMx Timer instance
  3068. * @param ETRSource This parameter can be one of the following values:
  3069. * For TIM1, the parameter is one of the following values:
  3070. * @arg LL_TIM_TIM1_ETRSOURCE_GPIO: TIM1_ETR is connected to GPIO
  3071. * @arg LL_TIM_TIM1_ETRSOURCE_COMP1: TIM1_ETR is connected to COMP1 output
  3072. * @arg LL_TIM_TIM1_ETRSOURCE_COMP2: TIM1_ETR is connected to COMP2 output
  3073. * @arg LL_TIM_TIM1_ETRSOURCE_ADC1_AWD1: TIM1_ETR is connected to ADC1 AWD1
  3074. * @arg LL_TIM_TIM1_ETRSOURCE_ADC1_AWD2: TIM1_ETR is connected to ADC1 AWD2
  3075. * @arg LL_TIM_TIM1_ETRSOURCE_ADC1_AWD3: TIM1_ETR is connected to ADC1 AWD3
  3076. * @arg LL_TIM_TIM1_ETRSOURCE_ADC3_AWD1: TIM1_ETR is connected to ADC3 AWD1
  3077. * @arg LL_TIM_TIM1_ETRSOURCE_ADC3_AWD2: TIM1_ETR is connected to ADC3 AWD2
  3078. * @arg LL_TIM_TIM1_ETRSOURCE_ADC3_AWD3: TIM1_ETR is connected to ADC3 AWD3
  3079. *
  3080. * For TIM2, the parameter is one of the following values:
  3081. * @arg LL_TIM_TIM2_ETRSOURCE_GPIO: TIM2_ETR is connected to GPIO
  3082. * @arg LL_TIM_TIM2_ETRSOURCE_COMP1: TIM2_ETR is connected to COMP1 output
  3083. * @arg LL_TIM_TIM2_ETRSOURCE_COMP2: TIM2_ETR is connected to COMP2 output
  3084. * @arg LL_TIM_TIM2_ETRSOURCE_LSE: TIM2_ETR is connected to LSE
  3085. * @arg LL_TIM_TIM2_ETRSOURCE_SAI1_FSA: TIM2_ETR is connected to SAI1 FS_A
  3086. * @arg LL_TIM_TIM2_ETRSOURCE_SAI1_FSB: TIM2_ETR is connected to SAI1 FS_B
  3087. *
  3088. * For TIM3, the parameter is one of the following values:
  3089. * @arg LL_TIM_TIM3_ETRSOURCE_GPIO: TIM3_ETR is connected to GPIO
  3090. * @arg LL_TIM_TIM3_ETRSOURCE_COMP1: TIM3_ETR is connected to COMP1 output
  3091. *
  3092. * For TIM5, the parameter is one of the following values:
  3093. * @arg LL_TIM_TIM5_ETRSOURCE_GPIO: TIM5_ETR is connected to GPIO
  3094. * @arg LL_TIM_TIM5_ETRSOURCE_SAI2_FSA: TIM5_ETR is connected to SAI2 FS_A (*)
  3095. * @arg LL_TIM_TIM5_ETRSOURCE_SAI2_FSB: TIM5_ETR is connected to SAI2 FS_B (*)
  3096. * @arg LL_TIM_TIM5_ETRSOURCE_SAI4_FSA: TIM5_ETR is connected to SAI2 FS_A (*)
  3097. * @arg LL_TIM_TIM5_ETRSOURCE_SAI4_FSB: TIM5_ETR is connected to SAI2 FS_B (*)
  3098. *
  3099. * For TIM8, the parameter is one of the following values:
  3100. * @arg LL_TIM_TIM8_ETRSOURCE_GPIO: TIM8_ETR is connected to GPIO
  3101. * @arg LL_TIM_TIM8_ETRSOURCE_COMP1: TIM8_ETR is connected to COMP1 output
  3102. * @arg LL_TIM_TIM8_ETRSOURCE_COMP2: TIM8_ETR is connected to COMP2 output
  3103. * @arg LL_TIM_TIM8_ETRSOURCE_ADC2_AWD1: TIM8_ETR is connected to ADC2 AWD1
  3104. * @arg LL_TIM_TIM8_ETRSOURCE_ADC2_AWD2: TIM8_ETR is connected to ADC2 AWD2
  3105. * @arg LL_TIM_TIM8_ETRSOURCE_ADC2_AWD3: TIM8_ETR is connected to ADC2 AWD3
  3106. * @arg LL_TIM_TIM8_ETRSOURCE_ADC3_AWD1: TIM8_ETR is connected to ADC3 AWD1
  3107. * @arg LL_TIM_TIM8_ETRSOURCE_ADC3_AWD2: TIM8_ETR is connected to ADC3 AWD2
  3108. * @arg LL_TIM_TIM8_ETRSOURCE_ADC3_AWD3: TIM8_ETR is connected to ADC3 AWD3
  3109. *
  3110. * For TIM23, the parameter is one of the following values: (*)
  3111. * @arg LL_TIM_TIM23_ETRSOURCE_GPIO TIM23_ETR is connected to GPIO
  3112. * @arg LL_TIM_TIM23_ETRSOURCE_COMP1 TIM23_ETR is connected to COMP1 output
  3113. * @arg LL_TIM_TIM23_ETRSOURCE_COMP2 TIM23_ETR is connected to COMP2 output
  3114. *
  3115. * For TIM24, the parameter is one of the following values: (*)
  3116. * @arg LL_TIM_TIM24_ETRSOURCE_GPIO TIM24_ETR is connected to GPIO
  3117. * @arg LL_TIM_TIM24_ETRSOURCE_SAI4_FSA TIM24_ETR is connected to SAI4 FS_A
  3118. * @arg LL_TIM_TIM24_ETRSOURCE_SAI4_FSB TIM24_ETR is connected to SAI4 FS_B
  3119. * @arg LL_TIM_TIM24_ETRSOURCE_SAI1_FSA TIM24_ETR is connected to SAI1 FS_A
  3120. * @arg LL_TIM_TIM24_ETRSOURCE_SAI1_FSB TIM24_ETR is connected to SAI1 FS_B
  3121. *
  3122. * (*) Value not defined in all devices.
  3123. * @retval None
  3124. */
  3125. __STATIC_INLINE void LL_TIM_SetETRSource(TIM_TypeDef *TIMx, uint32_t ETRSource)
  3126. {
  3127. MODIFY_REG(TIMx->AF1, TIMx_AF1_ETRSEL, ETRSource);
  3128. }
  3129. /**
  3130. * @}
  3131. */
  3132. /** @defgroup TIM_LL_EF_Break_Function Break function configuration
  3133. * @{
  3134. */
  3135. /**
  3136. * @brief Enable the break function.
  3137. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3138. * a timer instance provides a break input.
  3139. * @rmtoll BDTR BKE LL_TIM_EnableBRK
  3140. * @param TIMx Timer instance
  3141. * @retval None
  3142. */
  3143. __STATIC_INLINE void LL_TIM_EnableBRK(TIM_TypeDef *TIMx)
  3144. {
  3145. SET_BIT(TIMx->BDTR, TIM_BDTR_BKE);
  3146. }
  3147. /**
  3148. * @brief Disable the break function.
  3149. * @rmtoll BDTR BKE LL_TIM_DisableBRK
  3150. * @param TIMx Timer instance
  3151. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3152. * a timer instance provides a break input.
  3153. * @retval None
  3154. */
  3155. __STATIC_INLINE void LL_TIM_DisableBRK(TIM_TypeDef *TIMx)
  3156. {
  3157. CLEAR_BIT(TIMx->BDTR, TIM_BDTR_BKE);
  3158. }
  3159. /**
  3160. * @brief Configure the break input.
  3161. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3162. * a timer instance provides a break input.
  3163. * @rmtoll BDTR BKP LL_TIM_ConfigBRK\n
  3164. * BDTR BKF LL_TIM_ConfigBRK
  3165. * @param TIMx Timer instance
  3166. * @param BreakPolarity This parameter can be one of the following values:
  3167. * @arg @ref LL_TIM_BREAK_POLARITY_LOW
  3168. * @arg @ref LL_TIM_BREAK_POLARITY_HIGH
  3169. * @param BreakFilter This parameter can be one of the following values:
  3170. * @arg @ref LL_TIM_BREAK_FILTER_FDIV1
  3171. * @arg @ref LL_TIM_BREAK_FILTER_FDIV1_N2
  3172. * @arg @ref LL_TIM_BREAK_FILTER_FDIV1_N4
  3173. * @arg @ref LL_TIM_BREAK_FILTER_FDIV1_N8
  3174. * @arg @ref LL_TIM_BREAK_FILTER_FDIV2_N6
  3175. * @arg @ref LL_TIM_BREAK_FILTER_FDIV2_N8
  3176. * @arg @ref LL_TIM_BREAK_FILTER_FDIV4_N6
  3177. * @arg @ref LL_TIM_BREAK_FILTER_FDIV4_N8
  3178. * @arg @ref LL_TIM_BREAK_FILTER_FDIV8_N6
  3179. * @arg @ref LL_TIM_BREAK_FILTER_FDIV8_N8
  3180. * @arg @ref LL_TIM_BREAK_FILTER_FDIV16_N5
  3181. * @arg @ref LL_TIM_BREAK_FILTER_FDIV16_N6
  3182. * @arg @ref LL_TIM_BREAK_FILTER_FDIV16_N8
  3183. * @arg @ref LL_TIM_BREAK_FILTER_FDIV32_N5
  3184. * @arg @ref LL_TIM_BREAK_FILTER_FDIV32_N6
  3185. * @arg @ref LL_TIM_BREAK_FILTER_FDIV32_N8
  3186. * @retval None
  3187. */
  3188. __STATIC_INLINE void LL_TIM_ConfigBRK(TIM_TypeDef *TIMx, uint32_t BreakPolarity,
  3189. uint32_t BreakFilter)
  3190. {
  3191. MODIFY_REG(TIMx->BDTR, TIM_BDTR_BKP | TIM_BDTR_BKF, BreakPolarity | BreakFilter);
  3192. }
  3193. /**
  3194. * @brief Enable the break 2 function.
  3195. * @note Macro IS_TIM_BKIN2_INSTANCE(TIMx) can be used to check whether or not
  3196. * a timer instance provides a second break input.
  3197. * @rmtoll BDTR BK2E LL_TIM_EnableBRK2
  3198. * @param TIMx Timer instance
  3199. * @retval None
  3200. */
  3201. __STATIC_INLINE void LL_TIM_EnableBRK2(TIM_TypeDef *TIMx)
  3202. {
  3203. SET_BIT(TIMx->BDTR, TIM_BDTR_BK2E);
  3204. }
  3205. /**
  3206. * @brief Disable the break 2 function.
  3207. * @note Macro IS_TIM_BKIN2_INSTANCE(TIMx) can be used to check whether or not
  3208. * a timer instance provides a second break input.
  3209. * @rmtoll BDTR BK2E LL_TIM_DisableBRK2
  3210. * @param TIMx Timer instance
  3211. * @retval None
  3212. */
  3213. __STATIC_INLINE void LL_TIM_DisableBRK2(TIM_TypeDef *TIMx)
  3214. {
  3215. CLEAR_BIT(TIMx->BDTR, TIM_BDTR_BK2E);
  3216. }
  3217. /**
  3218. * @brief Configure the break 2 input.
  3219. * @note Macro IS_TIM_BKIN2_INSTANCE(TIMx) can be used to check whether or not
  3220. * a timer instance provides a second break input.
  3221. * @rmtoll BDTR BK2P LL_TIM_ConfigBRK2\n
  3222. * BDTR BK2F LL_TIM_ConfigBRK2
  3223. * @param TIMx Timer instance
  3224. * @param Break2Polarity This parameter can be one of the following values:
  3225. * @arg @ref LL_TIM_BREAK2_POLARITY_LOW
  3226. * @arg @ref LL_TIM_BREAK2_POLARITY_HIGH
  3227. * @param Break2Filter This parameter can be one of the following values:
  3228. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV1
  3229. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV1_N2
  3230. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV1_N4
  3231. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV1_N8
  3232. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV2_N6
  3233. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV2_N8
  3234. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV4_N6
  3235. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV4_N8
  3236. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV8_N6
  3237. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV8_N8
  3238. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV16_N5
  3239. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV16_N6
  3240. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV16_N8
  3241. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV32_N5
  3242. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV32_N6
  3243. * @arg @ref LL_TIM_BREAK2_FILTER_FDIV32_N8
  3244. * @retval None
  3245. */
  3246. __STATIC_INLINE void LL_TIM_ConfigBRK2(TIM_TypeDef *TIMx, uint32_t Break2Polarity, uint32_t Break2Filter)
  3247. {
  3248. MODIFY_REG(TIMx->BDTR, TIM_BDTR_BK2P | TIM_BDTR_BK2F, Break2Polarity | Break2Filter);
  3249. }
  3250. /**
  3251. * @brief Select the outputs off state (enabled v.s. disabled) in Idle and Run modes.
  3252. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3253. * a timer instance provides a break input.
  3254. * @rmtoll BDTR OSSI LL_TIM_SetOffStates\n
  3255. * BDTR OSSR LL_TIM_SetOffStates
  3256. * @param TIMx Timer instance
  3257. * @param OffStateIdle This parameter can be one of the following values:
  3258. * @arg @ref LL_TIM_OSSI_DISABLE
  3259. * @arg @ref LL_TIM_OSSI_ENABLE
  3260. * @param OffStateRun This parameter can be one of the following values:
  3261. * @arg @ref LL_TIM_OSSR_DISABLE
  3262. * @arg @ref LL_TIM_OSSR_ENABLE
  3263. * @retval None
  3264. */
  3265. __STATIC_INLINE void LL_TIM_SetOffStates(TIM_TypeDef *TIMx, uint32_t OffStateIdle, uint32_t OffStateRun)
  3266. {
  3267. MODIFY_REG(TIMx->BDTR, TIM_BDTR_OSSI | TIM_BDTR_OSSR, OffStateIdle | OffStateRun);
  3268. }
  3269. /**
  3270. * @brief Enable automatic output (MOE can be set by software or automatically when a break input is active).
  3271. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3272. * a timer instance provides a break input.
  3273. * @rmtoll BDTR AOE LL_TIM_EnableAutomaticOutput
  3274. * @param TIMx Timer instance
  3275. * @retval None
  3276. */
  3277. __STATIC_INLINE void LL_TIM_EnableAutomaticOutput(TIM_TypeDef *TIMx)
  3278. {
  3279. SET_BIT(TIMx->BDTR, TIM_BDTR_AOE);
  3280. }
  3281. /**
  3282. * @brief Disable automatic output (MOE can be set only by software).
  3283. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3284. * a timer instance provides a break input.
  3285. * @rmtoll BDTR AOE LL_TIM_DisableAutomaticOutput
  3286. * @param TIMx Timer instance
  3287. * @retval None
  3288. */
  3289. __STATIC_INLINE void LL_TIM_DisableAutomaticOutput(TIM_TypeDef *TIMx)
  3290. {
  3291. CLEAR_BIT(TIMx->BDTR, TIM_BDTR_AOE);
  3292. }
  3293. /**
  3294. * @brief Indicate whether automatic output is enabled.
  3295. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3296. * a timer instance provides a break input.
  3297. * @rmtoll BDTR AOE LL_TIM_IsEnabledAutomaticOutput
  3298. * @param TIMx Timer instance
  3299. * @retval State of bit (1 or 0).
  3300. */
  3301. __STATIC_INLINE uint32_t LL_TIM_IsEnabledAutomaticOutput(TIM_TypeDef *TIMx)
  3302. {
  3303. return ((READ_BIT(TIMx->BDTR, TIM_BDTR_AOE) == (TIM_BDTR_AOE)) ? 1UL : 0UL);
  3304. }
  3305. /**
  3306. * @brief Enable the outputs (set the MOE bit in TIMx_BDTR register).
  3307. * @note The MOE bit in TIMx_BDTR register allows to enable /disable the outputs by
  3308. * software and is reset in case of break or break2 event
  3309. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3310. * a timer instance provides a break input.
  3311. * @rmtoll BDTR MOE LL_TIM_EnableAllOutputs
  3312. * @param TIMx Timer instance
  3313. * @retval None
  3314. */
  3315. __STATIC_INLINE void LL_TIM_EnableAllOutputs(TIM_TypeDef *TIMx)
  3316. {
  3317. SET_BIT(TIMx->BDTR, TIM_BDTR_MOE);
  3318. }
  3319. /**
  3320. * @brief Disable the outputs (reset the MOE bit in TIMx_BDTR register).
  3321. * @note The MOE bit in TIMx_BDTR register allows to enable /disable the outputs by
  3322. * software and is reset in case of break or break2 event.
  3323. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3324. * a timer instance provides a break input.
  3325. * @rmtoll BDTR MOE LL_TIM_DisableAllOutputs
  3326. * @param TIMx Timer instance
  3327. * @retval None
  3328. */
  3329. __STATIC_INLINE void LL_TIM_DisableAllOutputs(TIM_TypeDef *TIMx)
  3330. {
  3331. CLEAR_BIT(TIMx->BDTR, TIM_BDTR_MOE);
  3332. }
  3333. /**
  3334. * @brief Indicates whether outputs are enabled.
  3335. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  3336. * a timer instance provides a break input.
  3337. * @rmtoll BDTR MOE LL_TIM_IsEnabledAllOutputs
  3338. * @param TIMx Timer instance
  3339. * @retval State of bit (1 or 0).
  3340. */
  3341. __STATIC_INLINE uint32_t LL_TIM_IsEnabledAllOutputs(TIM_TypeDef *TIMx)
  3342. {
  3343. return ((READ_BIT(TIMx->BDTR, TIM_BDTR_MOE) == (TIM_BDTR_MOE)) ? 1UL : 0UL);
  3344. }
  3345. #if defined(TIM_BREAK_INPUT_SUPPORT)
  3346. /**
  3347. * @brief Enable the signals connected to the designated timer break input.
  3348. * @note Macro IS_TIM_BREAKSOURCE_INSTANCE(TIMx) can be used to check whether
  3349. * or not a timer instance allows for break input selection.
  3350. * @rmtoll AF1 BKINE LL_TIM_EnableBreakInputSource\n
  3351. * AF1 BKCMP1E LL_TIM_EnableBreakInputSource\n
  3352. * AF1 BKCMP2E LL_TIM_EnableBreakInputSource\n
  3353. * AF1 BKDF1BK0E LL_TIM_EnableBreakInputSource\n
  3354. * AF2 BK2INE LL_TIM_EnableBreakInputSource\n
  3355. * AF2 BK2CMP1E LL_TIM_EnableBreakInputSource\n
  3356. * AF2 BK2CMP2E LL_TIM_EnableBreakInputSource\n
  3357. * AF2 BK2DF1BK1E LL_TIM_EnableBreakInputSource
  3358. * @param TIMx Timer instance
  3359. * @param BreakInput This parameter can be one of the following values:
  3360. * @arg @ref LL_TIM_BREAK_INPUT_BKIN
  3361. * @arg @ref LL_TIM_BREAK_INPUT_BKIN2
  3362. * @param Source This parameter can be one of the following values:
  3363. * @arg @ref LL_TIM_BKIN_SOURCE_BKIN
  3364. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP1
  3365. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP2
  3366. * @arg @ref LL_TIM_BKIN_SOURCE_DF1BK
  3367. * @retval None
  3368. */
  3369. __STATIC_INLINE void LL_TIM_EnableBreakInputSource(TIM_TypeDef *TIMx, uint32_t BreakInput, uint32_t Source)
  3370. {
  3371. register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->AF1) + BreakInput));
  3372. SET_BIT(*pReg, Source);
  3373. }
  3374. /**
  3375. * @brief Disable the signals connected to the designated timer break input.
  3376. * @note Macro IS_TIM_BREAKSOURCE_INSTANCE(TIMx) can be used to check whether
  3377. * or not a timer instance allows for break input selection.
  3378. * @rmtoll AF1 BKINE LL_TIM_DisableBreakInputSource\n
  3379. * AF1 BKCMP1E LL_TIM_DisableBreakInputSource\n
  3380. * AF1 BKCMP2E LL_TIM_DisableBreakInputSource\n
  3381. * AF1 BKDF1BK0E LL_TIM_DisableBreakInputSource\n
  3382. * AF2 BK2INE LL_TIM_DisableBreakInputSource\n
  3383. * AF2 BK2CMP1E LL_TIM_DisableBreakInputSource\n
  3384. * AF2 BK2CMP2E LL_TIM_DisableBreakInputSource\n
  3385. * AF2 BK2DF1BK1E LL_TIM_DisableBreakInputSource
  3386. * @param TIMx Timer instance
  3387. * @param BreakInput This parameter can be one of the following values:
  3388. * @arg @ref LL_TIM_BREAK_INPUT_BKIN
  3389. * @arg @ref LL_TIM_BREAK_INPUT_BKIN2
  3390. * @param Source This parameter can be one of the following values:
  3391. * @arg @ref LL_TIM_BKIN_SOURCE_BKIN
  3392. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP1
  3393. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP2
  3394. * @arg @ref LL_TIM_BKIN_SOURCE_DF1BK
  3395. * @retval None
  3396. */
  3397. __STATIC_INLINE void LL_TIM_DisableBreakInputSource(TIM_TypeDef *TIMx, uint32_t BreakInput, uint32_t Source)
  3398. {
  3399. register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->AF1) + BreakInput));
  3400. CLEAR_BIT(*pReg, Source);
  3401. }
  3402. /**
  3403. * @brief Set the polarity of the break signal for the timer break input.
  3404. * @note Macro IS_TIM_BREAKSOURCE_INSTANCE(TIMx) can be used to check whether
  3405. * or not a timer instance allows for break input selection.
  3406. * @rmtoll AF1 BKINP LL_TIM_SetBreakInputSourcePolarity\n
  3407. * AF1 BKCMP1P LL_TIM_SetBreakInputSourcePolarity\n
  3408. * AF1 BKCMP2P LL_TIM_SetBreakInputSourcePolarity\n
  3409. * AF2 BK2INP LL_TIM_SetBreakInputSourcePolarity\n
  3410. * AF2 BK2CMP1P LL_TIM_SetBreakInputSourcePolarity\n
  3411. * AF2 BK2CMP2P LL_TIM_SetBreakInputSourcePolarity
  3412. * @param TIMx Timer instance
  3413. * @param BreakInput This parameter can be one of the following values:
  3414. * @arg @ref LL_TIM_BREAK_INPUT_BKIN
  3415. * @arg @ref LL_TIM_BREAK_INPUT_BKIN2
  3416. * @param Source This parameter can be one of the following values:
  3417. * @arg @ref LL_TIM_BKIN_SOURCE_BKIN
  3418. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP1
  3419. * @arg @ref LL_TIM_BKIN_SOURCE_BKCOMP2
  3420. * @param Polarity This parameter can be one of the following values:
  3421. * @arg @ref LL_TIM_BKIN_POLARITY_LOW
  3422. * @arg @ref LL_TIM_BKIN_POLARITY_HIGH
  3423. * @retval None
  3424. */
  3425. __STATIC_INLINE void LL_TIM_SetBreakInputSourcePolarity(TIM_TypeDef *TIMx, uint32_t BreakInput, uint32_t Source,
  3426. uint32_t Polarity)
  3427. {
  3428. register __IO uint32_t *pReg = (__IO uint32_t *)((uint32_t)((uint32_t)(&TIMx->AF1) + BreakInput));
  3429. MODIFY_REG(*pReg, (TIMx_AF1_BKINP << TIM_POSITION_BRK_SOURCE), (Polarity << TIM_POSITION_BRK_SOURCE));
  3430. }
  3431. #endif /* TIM_BREAK_INPUT_SUPPORT */
  3432. /**
  3433. * @}
  3434. */
  3435. /** @defgroup TIM_LL_EF_DMA_Burst_Mode DMA burst mode configuration
  3436. * @{
  3437. */
  3438. /**
  3439. * @brief Configures the timer DMA burst feature.
  3440. * @note Macro IS_TIM_DMABURST_INSTANCE(TIMx) can be used to check whether or
  3441. * not a timer instance supports the DMA burst mode.
  3442. * @rmtoll DCR DBL LL_TIM_ConfigDMABurst\n
  3443. * DCR DBA LL_TIM_ConfigDMABurst
  3444. * @param TIMx Timer instance
  3445. * @param DMABurstBaseAddress This parameter can be one of the following values:
  3446. * @arg @ref LL_TIM_DMABURST_BASEADDR_CR1
  3447. * @arg @ref LL_TIM_DMABURST_BASEADDR_CR2
  3448. * @arg @ref LL_TIM_DMABURST_BASEADDR_SMCR
  3449. * @arg @ref LL_TIM_DMABURST_BASEADDR_DIER
  3450. * @arg @ref LL_TIM_DMABURST_BASEADDR_SR
  3451. * @arg @ref LL_TIM_DMABURST_BASEADDR_EGR
  3452. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCMR1
  3453. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCMR2
  3454. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCER
  3455. * @arg @ref LL_TIM_DMABURST_BASEADDR_CNT
  3456. * @arg @ref LL_TIM_DMABURST_BASEADDR_PSC
  3457. * @arg @ref LL_TIM_DMABURST_BASEADDR_ARR
  3458. * @arg @ref LL_TIM_DMABURST_BASEADDR_RCR
  3459. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR1
  3460. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR2
  3461. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR3
  3462. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR4
  3463. * @arg @ref LL_TIM_DMABURST_BASEADDR_BDTR
  3464. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCMR3
  3465. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR5
  3466. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR6
  3467. * @arg @ref LL_TIM_DMABURST_BASEADDR_AF1
  3468. * @arg @ref LL_TIM_DMABURST_BASEADDR_AF2
  3469. * @arg @ref LL_TIM_DMABURST_BASEADDR_TISEL
  3470. *
  3471. * @param DMABurstLength This parameter can be one of the following values:
  3472. * @arg @ref LL_TIM_DMABURST_LENGTH_1TRANSFER
  3473. * @arg @ref LL_TIM_DMABURST_LENGTH_2TRANSFERS
  3474. * @arg @ref LL_TIM_DMABURST_LENGTH_3TRANSFERS
  3475. * @arg @ref LL_TIM_DMABURST_LENGTH_4TRANSFERS
  3476. * @arg @ref LL_TIM_DMABURST_LENGTH_5TRANSFERS
  3477. * @arg @ref LL_TIM_DMABURST_LENGTH_6TRANSFERS
  3478. * @arg @ref LL_TIM_DMABURST_LENGTH_7TRANSFERS
  3479. * @arg @ref LL_TIM_DMABURST_LENGTH_8TRANSFERS
  3480. * @arg @ref LL_TIM_DMABURST_LENGTH_9TRANSFERS
  3481. * @arg @ref LL_TIM_DMABURST_LENGTH_10TRANSFERS
  3482. * @arg @ref LL_TIM_DMABURST_LENGTH_11TRANSFERS
  3483. * @arg @ref LL_TIM_DMABURST_LENGTH_12TRANSFERS
  3484. * @arg @ref LL_TIM_DMABURST_LENGTH_13TRANSFERS
  3485. * @arg @ref LL_TIM_DMABURST_LENGTH_14TRANSFERS
  3486. * @arg @ref LL_TIM_DMABURST_LENGTH_15TRANSFERS
  3487. * @arg @ref LL_TIM_DMABURST_LENGTH_16TRANSFERS
  3488. * @arg @ref LL_TIM_DMABURST_LENGTH_17TRANSFERS
  3489. * @arg @ref LL_TIM_DMABURST_LENGTH_18TRANSFERS
  3490. * @retval None
  3491. */
  3492. __STATIC_INLINE void LL_TIM_ConfigDMABurst(TIM_TypeDef *TIMx, uint32_t DMABurstBaseAddress, uint32_t DMABurstLength)
  3493. {
  3494. MODIFY_REG(TIMx->DCR, (TIM_DCR_DBL | TIM_DCR_DBA), (DMABurstBaseAddress | DMABurstLength));
  3495. }
  3496. /**
  3497. * @}
  3498. */
  3499. /** @defgroup TIM_LL_EF_Timer_Inputs_Remapping Timer input remapping
  3500. * @{
  3501. */
  3502. /**
  3503. * @brief Remap TIM inputs (input channel, internal/external triggers).
  3504. * @note Macro IS_TIM_REMAP_INSTANCE(TIMx) can be used to check whether or not
  3505. * a some timer inputs can be remapped.
  3506. * TIM1: one of the following values:
  3507. * @arg LL_TIM_TIM1_TI1_RMP_GPIO: TIM1 TI1 is connected to GPIO
  3508. * @arg LL_TIM_TIM1_TI1_RMP_COMP1: TIM1 TI1 is connected to COMP1 output
  3509. *
  3510. * TIM2: one of the following values:
  3511. * @arg LL_TIM_TIM2_TI4_RMP_GPIO: TIM2 TI4 is connected to GPIO
  3512. * @arg LL_TIM_TIM2_TI4_RMP_COMP1: TIM2 TI4 is connected to COMP1 output
  3513. * @arg LL_TIM_TIM2_TI4_RMP_COMP2: TIM2 TI4 is connected to COMP2 output
  3514. * @arg LL_TIM_TIM2_TI4_RMP_COMP1_COMP2: TIM2 TI4 is connected to logical OR between COMP1 and COMP2 output
  3515. *
  3516. * TIM3: one of the following values:
  3517. * @arg LL_TIM_TIM3_TI1_RMP_GPIO: TIM3 TI1 is connected to GPIO
  3518. * @arg LL_TIM_TIM3_TI1_RMP_COMP1: TIM3 TI1 is connected to COMP1 output
  3519. * @arg LL_TIM_TIM3_TI1_RMP_COMP2: TIM3 TI1 is connected to COMP2 output
  3520. * @arg LL_TIM_TIM3_TI1_RMP_COMP1_COMP2: TIM3 TI1 is connected to logical OR between COMP1 and COMP2 output
  3521. *
  3522. * TIM5: one of the following values:
  3523. * @arg LL_TIM_TIM5_TI1_RMP_GPIO: TIM5 TI1 is connected to GPIO
  3524. * @arg LL_TIM_TIM5_TI1_RMP_CAN_TMP: TIM5 TI1 is connected to CAN TMP
  3525. * @arg LL_TIM_TIM5_TI1_RMP_CAN_RTP: TIM5 TI1 is connected to CAN RTP
  3526. *
  3527. * TIM8: one of the following values:
  3528. * @arg LL_TIM_TIM8_TI1_RMP_GPIO: TIM8 TI1 is connected to GPIO
  3529. * @arg LL_TIM_TIM8_TI1_RMP_COMP2: TIM8 TI1 is connected to COMP2 output
  3530. *
  3531. * TIM12: one of the following values: (*)
  3532. * @arg LL_TIM_TIM12_TI1_RMP_GPIO: TIM12 TI1 is connected to GPIO
  3533. * @arg LL_TIM_TIM12_TI1_RMP_SPDIF_FS: TIM12 TI1 is connected to SPDIF FS
  3534. *
  3535. * TIM15: one of the following values:
  3536. * @arg LL_TIM_TIM15_TI1_RMP_GPIO: TIM15 TI1 is connected to GPIO
  3537. * @arg LL_TIM_TIM15_TI1_RMP_TIM2: TIM15 TI1 is connected to TIM2 CH1
  3538. * @arg LL_TIM_TIM15_TI1_RMP_TIM3: TIM15 TI1 is connected to TIM3 CH1
  3539. * @arg LL_TIM_TIM15_TI1_RMP_TIM4: TIM15 TI1 is connected to TIM4 CH1
  3540. * @arg LL_TIM_TIM15_TI1_RMP_LSE: TIM15 TI1 is connected to LSE
  3541. * @arg LL_TIM_TIM15_TI1_RMP_CSI: TIM15 TI1 is connected to CSI
  3542. * @arg LL_TIM_TIM15_TI1_RMP_MCO2: TIM15 TI1 is connected to MCO2
  3543. * @arg LL_TIM_TIM15_TI2_RMP_GPIO: TIM15 TI2 is connected to GPIO
  3544. * @arg LL_TIM_TIM15_TI2_RMP_TIM2: TIM15 TI2 is connected to TIM2 CH2
  3545. * @arg LL_TIM_TIM15_TI2_RMP_TIM3: TIM15 TI2 is connected to TIM3 CH2
  3546. * @arg LL_TIM_TIM15_TI2_RMP_TIM4: TIM15 TI2 is connected to TIM4 CH2
  3547. *
  3548. * TIM16: one of the following values:
  3549. * @arg LL_TIM_TIM16_TI1_RMP_GPIO: TIM16 TI1 is connected to GPIO
  3550. * @arg LL_TIM_TIM16_TI1_RMP_LSI: TIM16 TI1 is connected to LSI
  3551. * @arg LL_TIM_TIM16_TI1_RMP_LSE: TIM16 TI1 is connected to LSE
  3552. * @arg LL_TIM_TIM16_TI1_RMP_RTC: TIM16 TI1 is connected to RTC wakeup interrupt
  3553. *
  3554. * TIM17: one of the following values:
  3555. * @arg LL_TIM_TIM17_TI1_RMP_GPIO: TIM17 TI1 is connected to GPIO
  3556. * @arg LL_TIM_TIM17_TI1_RMP_SPDIF_FS: TIM17 TI1 is connected to SPDIF FS (*)
  3557. * @arg LL_TIM_TIM17_TI1_RMP_HSE_1MHZ: TIM17 TI1 is connected to HSE 1MHz
  3558. * @arg LL_TIM_TIM17_TI1_RMP_MCO1: TIM17 TI1 is connected to MCO1
  3559. *
  3560. * TIM23: one of the following values: (*)
  3561. * @arg LL_TIM_TIM23_TI4_RMP_GPIO TIM23_TI4 is connected to GPIO
  3562. * @arg LL_TIM_TIM23_TI4_RMP_COMP1 TIM23_TI4 is connected to COMP1 output
  3563. * @arg LL_TIM_TIM23_TI4_RMP_COMP2 TIM23_TI4 is connected to COMP2 output
  3564. * @arg LL_TIM_TIM23_TI4_RMP_COMP1_COMP2 TIM23_TI4 is connected to COMP2 output
  3565. *
  3566. * TIM24: one of the following values: (*)
  3567. * @arg LL_TIM_TIM24_TI1_RMP_GPIO TIM24_TI1 is connected to GPIO
  3568. * @arg LL_TIM_TIM24_TI1_RMP_CAN_TMP TIM24_TI1 is connected to CAN_TMP
  3569. * @arg LL_TIM_TIM24_TI1_RMP_CAN_RTP TIM24_TI1 is connected to CAN_RTP
  3570. * @arg LL_TIM_TIM24_TI1_RMP_CAN_SOC TIM24_TI1 is connected to CAN_SOC
  3571. *
  3572. * (*) Value not defined in all devices. \n
  3573. * @retval None
  3574. */
  3575. __STATIC_INLINE void LL_TIM_SetRemap(TIM_TypeDef *TIMx, uint32_t Remap)
  3576. {
  3577. MODIFY_REG(TIMx->TISEL, (TIM_TISEL_TI1SEL | TIM_TISEL_TI2SEL | TIM_TISEL_TI3SEL | TIM_TISEL_TI4SEL), Remap);
  3578. }
  3579. /**
  3580. * @}
  3581. */
  3582. /** @defgroup TIM_LL_EF_FLAG_Management FLAG-Management
  3583. * @{
  3584. */
  3585. /**
  3586. * @brief Clear the update interrupt flag (UIF).
  3587. * @rmtoll SR UIF LL_TIM_ClearFlag_UPDATE
  3588. * @param TIMx Timer instance
  3589. * @retval None
  3590. */
  3591. __STATIC_INLINE void LL_TIM_ClearFlag_UPDATE(TIM_TypeDef *TIMx)
  3592. {
  3593. WRITE_REG(TIMx->SR, ~(TIM_SR_UIF));
  3594. }
  3595. /**
  3596. * @brief Indicate whether update interrupt flag (UIF) is set (update interrupt is pending).
  3597. * @rmtoll SR UIF LL_TIM_IsActiveFlag_UPDATE
  3598. * @param TIMx Timer instance
  3599. * @retval State of bit (1 or 0).
  3600. */
  3601. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_UPDATE(TIM_TypeDef *TIMx)
  3602. {
  3603. return ((READ_BIT(TIMx->SR, TIM_SR_UIF) == (TIM_SR_UIF)) ? 1UL : 0UL);
  3604. }
  3605. /**
  3606. * @brief Clear the Capture/Compare 1 interrupt flag (CC1F).
  3607. * @rmtoll SR CC1IF LL_TIM_ClearFlag_CC1
  3608. * @param TIMx Timer instance
  3609. * @retval None
  3610. */
  3611. __STATIC_INLINE void LL_TIM_ClearFlag_CC1(TIM_TypeDef *TIMx)
  3612. {
  3613. WRITE_REG(TIMx->SR, ~(TIM_SR_CC1IF));
  3614. }
  3615. /**
  3616. * @brief Indicate whether Capture/Compare 1 interrupt flag (CC1F) is set (Capture/Compare 1 interrupt is pending).
  3617. * @rmtoll SR CC1IF LL_TIM_IsActiveFlag_CC1
  3618. * @param TIMx Timer instance
  3619. * @retval State of bit (1 or 0).
  3620. */
  3621. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC1(TIM_TypeDef *TIMx)
  3622. {
  3623. return ((READ_BIT(TIMx->SR, TIM_SR_CC1IF) == (TIM_SR_CC1IF)) ? 1UL : 0UL);
  3624. }
  3625. /**
  3626. * @brief Clear the Capture/Compare 2 interrupt flag (CC2F).
  3627. * @rmtoll SR CC2IF LL_TIM_ClearFlag_CC2
  3628. * @param TIMx Timer instance
  3629. * @retval None
  3630. */
  3631. __STATIC_INLINE void LL_TIM_ClearFlag_CC2(TIM_TypeDef *TIMx)
  3632. {
  3633. WRITE_REG(TIMx->SR, ~(TIM_SR_CC2IF));
  3634. }
  3635. /**
  3636. * @brief Indicate whether Capture/Compare 2 interrupt flag (CC2F) is set (Capture/Compare 2 interrupt is pending).
  3637. * @rmtoll SR CC2IF LL_TIM_IsActiveFlag_CC2
  3638. * @param TIMx Timer instance
  3639. * @retval State of bit (1 or 0).
  3640. */
  3641. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC2(TIM_TypeDef *TIMx)
  3642. {
  3643. return ((READ_BIT(TIMx->SR, TIM_SR_CC2IF) == (TIM_SR_CC2IF)) ? 1UL : 0UL);
  3644. }
  3645. /**
  3646. * @brief Clear the Capture/Compare 3 interrupt flag (CC3F).
  3647. * @rmtoll SR CC3IF LL_TIM_ClearFlag_CC3
  3648. * @param TIMx Timer instance
  3649. * @retval None
  3650. */
  3651. __STATIC_INLINE void LL_TIM_ClearFlag_CC3(TIM_TypeDef *TIMx)
  3652. {
  3653. WRITE_REG(TIMx->SR, ~(TIM_SR_CC3IF));
  3654. }
  3655. /**
  3656. * @brief Indicate whether Capture/Compare 3 interrupt flag (CC3F) is set (Capture/Compare 3 interrupt is pending).
  3657. * @rmtoll SR CC3IF LL_TIM_IsActiveFlag_CC3
  3658. * @param TIMx Timer instance
  3659. * @retval State of bit (1 or 0).
  3660. */
  3661. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC3(TIM_TypeDef *TIMx)
  3662. {
  3663. return ((READ_BIT(TIMx->SR, TIM_SR_CC3IF) == (TIM_SR_CC3IF)) ? 1UL : 0UL);
  3664. }
  3665. /**
  3666. * @brief Clear the Capture/Compare 4 interrupt flag (CC4F).
  3667. * @rmtoll SR CC4IF LL_TIM_ClearFlag_CC4
  3668. * @param TIMx Timer instance
  3669. * @retval None
  3670. */
  3671. __STATIC_INLINE void LL_TIM_ClearFlag_CC4(TIM_TypeDef *TIMx)
  3672. {
  3673. WRITE_REG(TIMx->SR, ~(TIM_SR_CC4IF));
  3674. }
  3675. /**
  3676. * @brief Indicate whether Capture/Compare 4 interrupt flag (CC4F) is set (Capture/Compare 4 interrupt is pending).
  3677. * @rmtoll SR CC4IF LL_TIM_IsActiveFlag_CC4
  3678. * @param TIMx Timer instance
  3679. * @retval State of bit (1 or 0).
  3680. */
  3681. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC4(TIM_TypeDef *TIMx)
  3682. {
  3683. return ((READ_BIT(TIMx->SR, TIM_SR_CC4IF) == (TIM_SR_CC4IF)) ? 1UL : 0UL);
  3684. }
  3685. /**
  3686. * @brief Clear the Capture/Compare 5 interrupt flag (CC5F).
  3687. * @rmtoll SR CC5IF LL_TIM_ClearFlag_CC5
  3688. * @param TIMx Timer instance
  3689. * @retval None
  3690. */
  3691. __STATIC_INLINE void LL_TIM_ClearFlag_CC5(TIM_TypeDef *TIMx)
  3692. {
  3693. WRITE_REG(TIMx->SR, ~(TIM_SR_CC5IF));
  3694. }
  3695. /**
  3696. * @brief Indicate whether Capture/Compare 5 interrupt flag (CC5F) is set (Capture/Compare 5 interrupt is pending).
  3697. * @rmtoll SR CC5IF LL_TIM_IsActiveFlag_CC5
  3698. * @param TIMx Timer instance
  3699. * @retval State of bit (1 or 0).
  3700. */
  3701. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC5(TIM_TypeDef *TIMx)
  3702. {
  3703. return ((READ_BIT(TIMx->SR, TIM_SR_CC5IF) == (TIM_SR_CC5IF)) ? 1UL : 0UL);
  3704. }
  3705. /**
  3706. * @brief Clear the Capture/Compare 6 interrupt flag (CC6F).
  3707. * @rmtoll SR CC6IF LL_TIM_ClearFlag_CC6
  3708. * @param TIMx Timer instance
  3709. * @retval None
  3710. */
  3711. __STATIC_INLINE void LL_TIM_ClearFlag_CC6(TIM_TypeDef *TIMx)
  3712. {
  3713. WRITE_REG(TIMx->SR, ~(TIM_SR_CC6IF));
  3714. }
  3715. /**
  3716. * @brief Indicate whether Capture/Compare 6 interrupt flag (CC6F) is set (Capture/Compare 6 interrupt is pending).
  3717. * @rmtoll SR CC6IF LL_TIM_IsActiveFlag_CC6
  3718. * @param TIMx Timer instance
  3719. * @retval State of bit (1 or 0).
  3720. */
  3721. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC6(TIM_TypeDef *TIMx)
  3722. {
  3723. return ((READ_BIT(TIMx->SR, TIM_SR_CC6IF) == (TIM_SR_CC6IF)) ? 1UL : 0UL);
  3724. }
  3725. /**
  3726. * @brief Clear the commutation interrupt flag (COMIF).
  3727. * @rmtoll SR COMIF LL_TIM_ClearFlag_COM
  3728. * @param TIMx Timer instance
  3729. * @retval None
  3730. */
  3731. __STATIC_INLINE void LL_TIM_ClearFlag_COM(TIM_TypeDef *TIMx)
  3732. {
  3733. WRITE_REG(TIMx->SR, ~(TIM_SR_COMIF));
  3734. }
  3735. /**
  3736. * @brief Indicate whether commutation interrupt flag (COMIF) is set (commutation interrupt is pending).
  3737. * @rmtoll SR COMIF LL_TIM_IsActiveFlag_COM
  3738. * @param TIMx Timer instance
  3739. * @retval State of bit (1 or 0).
  3740. */
  3741. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_COM(TIM_TypeDef *TIMx)
  3742. {
  3743. return ((READ_BIT(TIMx->SR, TIM_SR_COMIF) == (TIM_SR_COMIF)) ? 1UL : 0UL);
  3744. }
  3745. /**
  3746. * @brief Clear the trigger interrupt flag (TIF).
  3747. * @rmtoll SR TIF LL_TIM_ClearFlag_TRIG
  3748. * @param TIMx Timer instance
  3749. * @retval None
  3750. */
  3751. __STATIC_INLINE void LL_TIM_ClearFlag_TRIG(TIM_TypeDef *TIMx)
  3752. {
  3753. WRITE_REG(TIMx->SR, ~(TIM_SR_TIF));
  3754. }
  3755. /**
  3756. * @brief Indicate whether trigger interrupt flag (TIF) is set (trigger interrupt is pending).
  3757. * @rmtoll SR TIF LL_TIM_IsActiveFlag_TRIG
  3758. * @param TIMx Timer instance
  3759. * @retval State of bit (1 or 0).
  3760. */
  3761. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_TRIG(TIM_TypeDef *TIMx)
  3762. {
  3763. return ((READ_BIT(TIMx->SR, TIM_SR_TIF) == (TIM_SR_TIF)) ? 1UL : 0UL);
  3764. }
  3765. /**
  3766. * @brief Clear the break interrupt flag (BIF).
  3767. * @rmtoll SR BIF LL_TIM_ClearFlag_BRK
  3768. * @param TIMx Timer instance
  3769. * @retval None
  3770. */
  3771. __STATIC_INLINE void LL_TIM_ClearFlag_BRK(TIM_TypeDef *TIMx)
  3772. {
  3773. WRITE_REG(TIMx->SR, ~(TIM_SR_BIF));
  3774. }
  3775. /**
  3776. * @brief Indicate whether break interrupt flag (BIF) is set (break interrupt is pending).
  3777. * @rmtoll SR BIF LL_TIM_IsActiveFlag_BRK
  3778. * @param TIMx Timer instance
  3779. * @retval State of bit (1 or 0).
  3780. */
  3781. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_BRK(TIM_TypeDef *TIMx)
  3782. {
  3783. return ((READ_BIT(TIMx->SR, TIM_SR_BIF) == (TIM_SR_BIF)) ? 1UL : 0UL);
  3784. }
  3785. /**
  3786. * @brief Clear the break 2 interrupt flag (B2IF).
  3787. * @rmtoll SR B2IF LL_TIM_ClearFlag_BRK2
  3788. * @param TIMx Timer instance
  3789. * @retval None
  3790. */
  3791. __STATIC_INLINE void LL_TIM_ClearFlag_BRK2(TIM_TypeDef *TIMx)
  3792. {
  3793. WRITE_REG(TIMx->SR, ~(TIM_SR_B2IF));
  3794. }
  3795. /**
  3796. * @brief Indicate whether break 2 interrupt flag (B2IF) is set (break 2 interrupt is pending).
  3797. * @rmtoll SR B2IF LL_TIM_IsActiveFlag_BRK2
  3798. * @param TIMx Timer instance
  3799. * @retval State of bit (1 or 0).
  3800. */
  3801. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_BRK2(TIM_TypeDef *TIMx)
  3802. {
  3803. return ((READ_BIT(TIMx->SR, TIM_SR_B2IF) == (TIM_SR_B2IF)) ? 1UL : 0UL);
  3804. }
  3805. /**
  3806. * @brief Clear the Capture/Compare 1 over-capture interrupt flag (CC1OF).
  3807. * @rmtoll SR CC1OF LL_TIM_ClearFlag_CC1OVR
  3808. * @param TIMx Timer instance
  3809. * @retval None
  3810. */
  3811. __STATIC_INLINE void LL_TIM_ClearFlag_CC1OVR(TIM_TypeDef *TIMx)
  3812. {
  3813. WRITE_REG(TIMx->SR, ~(TIM_SR_CC1OF));
  3814. }
  3815. /**
  3816. * @brief Indicate whether Capture/Compare 1 over-capture interrupt flag (CC1OF) is set (Capture/Compare 1 interrupt is pending).
  3817. * @rmtoll SR CC1OF LL_TIM_IsActiveFlag_CC1OVR
  3818. * @param TIMx Timer instance
  3819. * @retval State of bit (1 or 0).
  3820. */
  3821. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC1OVR(TIM_TypeDef *TIMx)
  3822. {
  3823. return ((READ_BIT(TIMx->SR, TIM_SR_CC1OF) == (TIM_SR_CC1OF)) ? 1UL : 0UL);
  3824. }
  3825. /**
  3826. * @brief Clear the Capture/Compare 2 over-capture interrupt flag (CC2OF).
  3827. * @rmtoll SR CC2OF LL_TIM_ClearFlag_CC2OVR
  3828. * @param TIMx Timer instance
  3829. * @retval None
  3830. */
  3831. __STATIC_INLINE void LL_TIM_ClearFlag_CC2OVR(TIM_TypeDef *TIMx)
  3832. {
  3833. WRITE_REG(TIMx->SR, ~(TIM_SR_CC2OF));
  3834. }
  3835. /**
  3836. * @brief Indicate whether Capture/Compare 2 over-capture interrupt flag (CC2OF) is set (Capture/Compare 2 over-capture interrupt is pending).
  3837. * @rmtoll SR CC2OF LL_TIM_IsActiveFlag_CC2OVR
  3838. * @param TIMx Timer instance
  3839. * @retval State of bit (1 or 0).
  3840. */
  3841. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC2OVR(TIM_TypeDef *TIMx)
  3842. {
  3843. return ((READ_BIT(TIMx->SR, TIM_SR_CC2OF) == (TIM_SR_CC2OF)) ? 1UL : 0UL);
  3844. }
  3845. /**
  3846. * @brief Clear the Capture/Compare 3 over-capture interrupt flag (CC3OF).
  3847. * @rmtoll SR CC3OF LL_TIM_ClearFlag_CC3OVR
  3848. * @param TIMx Timer instance
  3849. * @retval None
  3850. */
  3851. __STATIC_INLINE void LL_TIM_ClearFlag_CC3OVR(TIM_TypeDef *TIMx)
  3852. {
  3853. WRITE_REG(TIMx->SR, ~(TIM_SR_CC3OF));
  3854. }
  3855. /**
  3856. * @brief Indicate whether Capture/Compare 3 over-capture interrupt flag (CC3OF) is set (Capture/Compare 3 over-capture interrupt is pending).
  3857. * @rmtoll SR CC3OF LL_TIM_IsActiveFlag_CC3OVR
  3858. * @param TIMx Timer instance
  3859. * @retval State of bit (1 or 0).
  3860. */
  3861. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC3OVR(TIM_TypeDef *TIMx)
  3862. {
  3863. return ((READ_BIT(TIMx->SR, TIM_SR_CC3OF) == (TIM_SR_CC3OF)) ? 1UL : 0UL);
  3864. }
  3865. /**
  3866. * @brief Clear the Capture/Compare 4 over-capture interrupt flag (CC4OF).
  3867. * @rmtoll SR CC4OF LL_TIM_ClearFlag_CC4OVR
  3868. * @param TIMx Timer instance
  3869. * @retval None
  3870. */
  3871. __STATIC_INLINE void LL_TIM_ClearFlag_CC4OVR(TIM_TypeDef *TIMx)
  3872. {
  3873. WRITE_REG(TIMx->SR, ~(TIM_SR_CC4OF));
  3874. }
  3875. /**
  3876. * @brief Indicate whether Capture/Compare 4 over-capture interrupt flag (CC4OF) is set (Capture/Compare 4 over-capture interrupt is pending).
  3877. * @rmtoll SR CC4OF LL_TIM_IsActiveFlag_CC4OVR
  3878. * @param TIMx Timer instance
  3879. * @retval State of bit (1 or 0).
  3880. */
  3881. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC4OVR(TIM_TypeDef *TIMx)
  3882. {
  3883. return ((READ_BIT(TIMx->SR, TIM_SR_CC4OF) == (TIM_SR_CC4OF)) ? 1UL : 0UL);
  3884. }
  3885. /**
  3886. * @brief Clear the system break interrupt flag (SBIF).
  3887. * @rmtoll SR SBIF LL_TIM_ClearFlag_SYSBRK
  3888. * @param TIMx Timer instance
  3889. * @retval None
  3890. */
  3891. __STATIC_INLINE void LL_TIM_ClearFlag_SYSBRK(TIM_TypeDef *TIMx)
  3892. {
  3893. WRITE_REG(TIMx->SR, ~(TIM_SR_SBIF));
  3894. }
  3895. /**
  3896. * @brief Indicate whether system break interrupt flag (SBIF) is set (system break interrupt is pending).
  3897. * @rmtoll SR SBIF LL_TIM_IsActiveFlag_SYSBRK
  3898. * @param TIMx Timer instance
  3899. * @retval State of bit (1 or 0).
  3900. */
  3901. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_SYSBRK(TIM_TypeDef *TIMx)
  3902. {
  3903. return ((READ_BIT(TIMx->SR, TIM_SR_SBIF) == (TIM_SR_SBIF)) ? 1UL : 0UL);
  3904. }
  3905. /**
  3906. * @}
  3907. */
  3908. /** @defgroup TIM_LL_EF_IT_Management IT-Management
  3909. * @{
  3910. */
  3911. /**
  3912. * @brief Enable update interrupt (UIE).
  3913. * @rmtoll DIER UIE LL_TIM_EnableIT_UPDATE
  3914. * @param TIMx Timer instance
  3915. * @retval None
  3916. */
  3917. __STATIC_INLINE void LL_TIM_EnableIT_UPDATE(TIM_TypeDef *TIMx)
  3918. {
  3919. SET_BIT(TIMx->DIER, TIM_DIER_UIE);
  3920. }
  3921. /**
  3922. * @brief Disable update interrupt (UIE).
  3923. * @rmtoll DIER UIE LL_TIM_DisableIT_UPDATE
  3924. * @param TIMx Timer instance
  3925. * @retval None
  3926. */
  3927. __STATIC_INLINE void LL_TIM_DisableIT_UPDATE(TIM_TypeDef *TIMx)
  3928. {
  3929. CLEAR_BIT(TIMx->DIER, TIM_DIER_UIE);
  3930. }
  3931. /**
  3932. * @brief Indicates whether the update interrupt (UIE) is enabled.
  3933. * @rmtoll DIER UIE LL_TIM_IsEnabledIT_UPDATE
  3934. * @param TIMx Timer instance
  3935. * @retval State of bit (1 or 0).
  3936. */
  3937. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_UPDATE(TIM_TypeDef *TIMx)
  3938. {
  3939. return ((READ_BIT(TIMx->DIER, TIM_DIER_UIE) == (TIM_DIER_UIE)) ? 1UL : 0UL);
  3940. }
  3941. /**
  3942. * @brief Enable capture/compare 1 interrupt (CC1IE).
  3943. * @rmtoll DIER CC1IE LL_TIM_EnableIT_CC1
  3944. * @param TIMx Timer instance
  3945. * @retval None
  3946. */
  3947. __STATIC_INLINE void LL_TIM_EnableIT_CC1(TIM_TypeDef *TIMx)
  3948. {
  3949. SET_BIT(TIMx->DIER, TIM_DIER_CC1IE);
  3950. }
  3951. /**
  3952. * @brief Disable capture/compare 1 interrupt (CC1IE).
  3953. * @rmtoll DIER CC1IE LL_TIM_DisableIT_CC1
  3954. * @param TIMx Timer instance
  3955. * @retval None
  3956. */
  3957. __STATIC_INLINE void LL_TIM_DisableIT_CC1(TIM_TypeDef *TIMx)
  3958. {
  3959. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC1IE);
  3960. }
  3961. /**
  3962. * @brief Indicates whether the capture/compare 1 interrupt (CC1IE) is enabled.
  3963. * @rmtoll DIER CC1IE LL_TIM_IsEnabledIT_CC1
  3964. * @param TIMx Timer instance
  3965. * @retval State of bit (1 or 0).
  3966. */
  3967. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC1(TIM_TypeDef *TIMx)
  3968. {
  3969. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC1IE) == (TIM_DIER_CC1IE)) ? 1UL : 0UL);
  3970. }
  3971. /**
  3972. * @brief Enable capture/compare 2 interrupt (CC2IE).
  3973. * @rmtoll DIER CC2IE LL_TIM_EnableIT_CC2
  3974. * @param TIMx Timer instance
  3975. * @retval None
  3976. */
  3977. __STATIC_INLINE void LL_TIM_EnableIT_CC2(TIM_TypeDef *TIMx)
  3978. {
  3979. SET_BIT(TIMx->DIER, TIM_DIER_CC2IE);
  3980. }
  3981. /**
  3982. * @brief Disable capture/compare 2 interrupt (CC2IE).
  3983. * @rmtoll DIER CC2IE LL_TIM_DisableIT_CC2
  3984. * @param TIMx Timer instance
  3985. * @retval None
  3986. */
  3987. __STATIC_INLINE void LL_TIM_DisableIT_CC2(TIM_TypeDef *TIMx)
  3988. {
  3989. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC2IE);
  3990. }
  3991. /**
  3992. * @brief Indicates whether the capture/compare 2 interrupt (CC2IE) is enabled.
  3993. * @rmtoll DIER CC2IE LL_TIM_IsEnabledIT_CC2
  3994. * @param TIMx Timer instance
  3995. * @retval State of bit (1 or 0).
  3996. */
  3997. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC2(TIM_TypeDef *TIMx)
  3998. {
  3999. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC2IE) == (TIM_DIER_CC2IE)) ? 1UL : 0UL);
  4000. }
  4001. /**
  4002. * @brief Enable capture/compare 3 interrupt (CC3IE).
  4003. * @rmtoll DIER CC3IE LL_TIM_EnableIT_CC3
  4004. * @param TIMx Timer instance
  4005. * @retval None
  4006. */
  4007. __STATIC_INLINE void LL_TIM_EnableIT_CC3(TIM_TypeDef *TIMx)
  4008. {
  4009. SET_BIT(TIMx->DIER, TIM_DIER_CC3IE);
  4010. }
  4011. /**
  4012. * @brief Disable capture/compare 3 interrupt (CC3IE).
  4013. * @rmtoll DIER CC3IE LL_TIM_DisableIT_CC3
  4014. * @param TIMx Timer instance
  4015. * @retval None
  4016. */
  4017. __STATIC_INLINE void LL_TIM_DisableIT_CC3(TIM_TypeDef *TIMx)
  4018. {
  4019. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC3IE);
  4020. }
  4021. /**
  4022. * @brief Indicates whether the capture/compare 3 interrupt (CC3IE) is enabled.
  4023. * @rmtoll DIER CC3IE LL_TIM_IsEnabledIT_CC3
  4024. * @param TIMx Timer instance
  4025. * @retval State of bit (1 or 0).
  4026. */
  4027. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC3(TIM_TypeDef *TIMx)
  4028. {
  4029. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC3IE) == (TIM_DIER_CC3IE)) ? 1UL : 0UL);
  4030. }
  4031. /**
  4032. * @brief Enable capture/compare 4 interrupt (CC4IE).
  4033. * @rmtoll DIER CC4IE LL_TIM_EnableIT_CC4
  4034. * @param TIMx Timer instance
  4035. * @retval None
  4036. */
  4037. __STATIC_INLINE void LL_TIM_EnableIT_CC4(TIM_TypeDef *TIMx)
  4038. {
  4039. SET_BIT(TIMx->DIER, TIM_DIER_CC4IE);
  4040. }
  4041. /**
  4042. * @brief Disable capture/compare 4 interrupt (CC4IE).
  4043. * @rmtoll DIER CC4IE LL_TIM_DisableIT_CC4
  4044. * @param TIMx Timer instance
  4045. * @retval None
  4046. */
  4047. __STATIC_INLINE void LL_TIM_DisableIT_CC4(TIM_TypeDef *TIMx)
  4048. {
  4049. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC4IE);
  4050. }
  4051. /**
  4052. * @brief Indicates whether the capture/compare 4 interrupt (CC4IE) is enabled.
  4053. * @rmtoll DIER CC4IE LL_TIM_IsEnabledIT_CC4
  4054. * @param TIMx Timer instance
  4055. * @retval State of bit (1 or 0).
  4056. */
  4057. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC4(TIM_TypeDef *TIMx)
  4058. {
  4059. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC4IE) == (TIM_DIER_CC4IE)) ? 1UL : 0UL);
  4060. }
  4061. /**
  4062. * @brief Enable commutation interrupt (COMIE).
  4063. * @rmtoll DIER COMIE LL_TIM_EnableIT_COM
  4064. * @param TIMx Timer instance
  4065. * @retval None
  4066. */
  4067. __STATIC_INLINE void LL_TIM_EnableIT_COM(TIM_TypeDef *TIMx)
  4068. {
  4069. SET_BIT(TIMx->DIER, TIM_DIER_COMIE);
  4070. }
  4071. /**
  4072. * @brief Disable commutation interrupt (COMIE).
  4073. * @rmtoll DIER COMIE LL_TIM_DisableIT_COM
  4074. * @param TIMx Timer instance
  4075. * @retval None
  4076. */
  4077. __STATIC_INLINE void LL_TIM_DisableIT_COM(TIM_TypeDef *TIMx)
  4078. {
  4079. CLEAR_BIT(TIMx->DIER, TIM_DIER_COMIE);
  4080. }
  4081. /**
  4082. * @brief Indicates whether the commutation interrupt (COMIE) is enabled.
  4083. * @rmtoll DIER COMIE LL_TIM_IsEnabledIT_COM
  4084. * @param TIMx Timer instance
  4085. * @retval State of bit (1 or 0).
  4086. */
  4087. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_COM(TIM_TypeDef *TIMx)
  4088. {
  4089. return ((READ_BIT(TIMx->DIER, TIM_DIER_COMIE) == (TIM_DIER_COMIE)) ? 1UL : 0UL);
  4090. }
  4091. /**
  4092. * @brief Enable trigger interrupt (TIE).
  4093. * @rmtoll DIER TIE LL_TIM_EnableIT_TRIG
  4094. * @param TIMx Timer instance
  4095. * @retval None
  4096. */
  4097. __STATIC_INLINE void LL_TIM_EnableIT_TRIG(TIM_TypeDef *TIMx)
  4098. {
  4099. SET_BIT(TIMx->DIER, TIM_DIER_TIE);
  4100. }
  4101. /**
  4102. * @brief Disable trigger interrupt (TIE).
  4103. * @rmtoll DIER TIE LL_TIM_DisableIT_TRIG
  4104. * @param TIMx Timer instance
  4105. * @retval None
  4106. */
  4107. __STATIC_INLINE void LL_TIM_DisableIT_TRIG(TIM_TypeDef *TIMx)
  4108. {
  4109. CLEAR_BIT(TIMx->DIER, TIM_DIER_TIE);
  4110. }
  4111. /**
  4112. * @brief Indicates whether the trigger interrupt (TIE) is enabled.
  4113. * @rmtoll DIER TIE LL_TIM_IsEnabledIT_TRIG
  4114. * @param TIMx Timer instance
  4115. * @retval State of bit (1 or 0).
  4116. */
  4117. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_TRIG(TIM_TypeDef *TIMx)
  4118. {
  4119. return ((READ_BIT(TIMx->DIER, TIM_DIER_TIE) == (TIM_DIER_TIE)) ? 1UL : 0UL);
  4120. }
  4121. /**
  4122. * @brief Enable break interrupt (BIE).
  4123. * @rmtoll DIER BIE LL_TIM_EnableIT_BRK
  4124. * @param TIMx Timer instance
  4125. * @retval None
  4126. */
  4127. __STATIC_INLINE void LL_TIM_EnableIT_BRK(TIM_TypeDef *TIMx)
  4128. {
  4129. SET_BIT(TIMx->DIER, TIM_DIER_BIE);
  4130. }
  4131. /**
  4132. * @brief Disable break interrupt (BIE).
  4133. * @rmtoll DIER BIE LL_TIM_DisableIT_BRK
  4134. * @param TIMx Timer instance
  4135. * @retval None
  4136. */
  4137. __STATIC_INLINE void LL_TIM_DisableIT_BRK(TIM_TypeDef *TIMx)
  4138. {
  4139. CLEAR_BIT(TIMx->DIER, TIM_DIER_BIE);
  4140. }
  4141. /**
  4142. * @brief Indicates whether the break interrupt (BIE) is enabled.
  4143. * @rmtoll DIER BIE LL_TIM_IsEnabledIT_BRK
  4144. * @param TIMx Timer instance
  4145. * @retval State of bit (1 or 0).
  4146. */
  4147. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_BRK(TIM_TypeDef *TIMx)
  4148. {
  4149. return ((READ_BIT(TIMx->DIER, TIM_DIER_BIE) == (TIM_DIER_BIE)) ? 1UL : 0UL);
  4150. }
  4151. /**
  4152. * @}
  4153. */
  4154. /** @defgroup TIM_LL_EF_DMA_Management DMA-Management
  4155. * @{
  4156. */
  4157. /**
  4158. * @brief Enable update DMA request (UDE).
  4159. * @rmtoll DIER UDE LL_TIM_EnableDMAReq_UPDATE
  4160. * @param TIMx Timer instance
  4161. * @retval None
  4162. */
  4163. __STATIC_INLINE void LL_TIM_EnableDMAReq_UPDATE(TIM_TypeDef *TIMx)
  4164. {
  4165. SET_BIT(TIMx->DIER, TIM_DIER_UDE);
  4166. }
  4167. /**
  4168. * @brief Disable update DMA request (UDE).
  4169. * @rmtoll DIER UDE LL_TIM_DisableDMAReq_UPDATE
  4170. * @param TIMx Timer instance
  4171. * @retval None
  4172. */
  4173. __STATIC_INLINE void LL_TIM_DisableDMAReq_UPDATE(TIM_TypeDef *TIMx)
  4174. {
  4175. CLEAR_BIT(TIMx->DIER, TIM_DIER_UDE);
  4176. }
  4177. /**
  4178. * @brief Indicates whether the update DMA request (UDE) is enabled.
  4179. * @rmtoll DIER UDE LL_TIM_IsEnabledDMAReq_UPDATE
  4180. * @param TIMx Timer instance
  4181. * @retval State of bit (1 or 0).
  4182. */
  4183. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_UPDATE(TIM_TypeDef *TIMx)
  4184. {
  4185. return ((READ_BIT(TIMx->DIER, TIM_DIER_UDE) == (TIM_DIER_UDE)) ? 1UL : 0UL);
  4186. }
  4187. /**
  4188. * @brief Enable capture/compare 1 DMA request (CC1DE).
  4189. * @rmtoll DIER CC1DE LL_TIM_EnableDMAReq_CC1
  4190. * @param TIMx Timer instance
  4191. * @retval None
  4192. */
  4193. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC1(TIM_TypeDef *TIMx)
  4194. {
  4195. SET_BIT(TIMx->DIER, TIM_DIER_CC1DE);
  4196. }
  4197. /**
  4198. * @brief Disable capture/compare 1 DMA request (CC1DE).
  4199. * @rmtoll DIER CC1DE LL_TIM_DisableDMAReq_CC1
  4200. * @param TIMx Timer instance
  4201. * @retval None
  4202. */
  4203. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC1(TIM_TypeDef *TIMx)
  4204. {
  4205. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC1DE);
  4206. }
  4207. /**
  4208. * @brief Indicates whether the capture/compare 1 DMA request (CC1DE) is enabled.
  4209. * @rmtoll DIER CC1DE LL_TIM_IsEnabledDMAReq_CC1
  4210. * @param TIMx Timer instance
  4211. * @retval State of bit (1 or 0).
  4212. */
  4213. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC1(TIM_TypeDef *TIMx)
  4214. {
  4215. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC1DE) == (TIM_DIER_CC1DE)) ? 1UL : 0UL);
  4216. }
  4217. /**
  4218. * @brief Enable capture/compare 2 DMA request (CC2DE).
  4219. * @rmtoll DIER CC2DE LL_TIM_EnableDMAReq_CC2
  4220. * @param TIMx Timer instance
  4221. * @retval None
  4222. */
  4223. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC2(TIM_TypeDef *TIMx)
  4224. {
  4225. SET_BIT(TIMx->DIER, TIM_DIER_CC2DE);
  4226. }
  4227. /**
  4228. * @brief Disable capture/compare 2 DMA request (CC2DE).
  4229. * @rmtoll DIER CC2DE LL_TIM_DisableDMAReq_CC2
  4230. * @param TIMx Timer instance
  4231. * @retval None
  4232. */
  4233. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC2(TIM_TypeDef *TIMx)
  4234. {
  4235. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC2DE);
  4236. }
  4237. /**
  4238. * @brief Indicates whether the capture/compare 2 DMA request (CC2DE) is enabled.
  4239. * @rmtoll DIER CC2DE LL_TIM_IsEnabledDMAReq_CC2
  4240. * @param TIMx Timer instance
  4241. * @retval State of bit (1 or 0).
  4242. */
  4243. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC2(TIM_TypeDef *TIMx)
  4244. {
  4245. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC2DE) == (TIM_DIER_CC2DE)) ? 1UL : 0UL);
  4246. }
  4247. /**
  4248. * @brief Enable capture/compare 3 DMA request (CC3DE).
  4249. * @rmtoll DIER CC3DE LL_TIM_EnableDMAReq_CC3
  4250. * @param TIMx Timer instance
  4251. * @retval None
  4252. */
  4253. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC3(TIM_TypeDef *TIMx)
  4254. {
  4255. SET_BIT(TIMx->DIER, TIM_DIER_CC3DE);
  4256. }
  4257. /**
  4258. * @brief Disable capture/compare 3 DMA request (CC3DE).
  4259. * @rmtoll DIER CC3DE LL_TIM_DisableDMAReq_CC3
  4260. * @param TIMx Timer instance
  4261. * @retval None
  4262. */
  4263. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC3(TIM_TypeDef *TIMx)
  4264. {
  4265. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC3DE);
  4266. }
  4267. /**
  4268. * @brief Indicates whether the capture/compare 3 DMA request (CC3DE) is enabled.
  4269. * @rmtoll DIER CC3DE LL_TIM_IsEnabledDMAReq_CC3
  4270. * @param TIMx Timer instance
  4271. * @retval State of bit (1 or 0).
  4272. */
  4273. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC3(TIM_TypeDef *TIMx)
  4274. {
  4275. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC3DE) == (TIM_DIER_CC3DE)) ? 1UL : 0UL);
  4276. }
  4277. /**
  4278. * @brief Enable capture/compare 4 DMA request (CC4DE).
  4279. * @rmtoll DIER CC4DE LL_TIM_EnableDMAReq_CC4
  4280. * @param TIMx Timer instance
  4281. * @retval None
  4282. */
  4283. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC4(TIM_TypeDef *TIMx)
  4284. {
  4285. SET_BIT(TIMx->DIER, TIM_DIER_CC4DE);
  4286. }
  4287. /**
  4288. * @brief Disable capture/compare 4 DMA request (CC4DE).
  4289. * @rmtoll DIER CC4DE LL_TIM_DisableDMAReq_CC4
  4290. * @param TIMx Timer instance
  4291. * @retval None
  4292. */
  4293. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC4(TIM_TypeDef *TIMx)
  4294. {
  4295. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC4DE);
  4296. }
  4297. /**
  4298. * @brief Indicates whether the capture/compare 4 DMA request (CC4DE) is enabled.
  4299. * @rmtoll DIER CC4DE LL_TIM_IsEnabledDMAReq_CC4
  4300. * @param TIMx Timer instance
  4301. * @retval State of bit (1 or 0).
  4302. */
  4303. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC4(TIM_TypeDef *TIMx)
  4304. {
  4305. return ((READ_BIT(TIMx->DIER, TIM_DIER_CC4DE) == (TIM_DIER_CC4DE)) ? 1UL : 0UL);
  4306. }
  4307. /**
  4308. * @brief Enable commutation DMA request (COMDE).
  4309. * @rmtoll DIER COMDE LL_TIM_EnableDMAReq_COM
  4310. * @param TIMx Timer instance
  4311. * @retval None
  4312. */
  4313. __STATIC_INLINE void LL_TIM_EnableDMAReq_COM(TIM_TypeDef *TIMx)
  4314. {
  4315. SET_BIT(TIMx->DIER, TIM_DIER_COMDE);
  4316. }
  4317. /**
  4318. * @brief Disable commutation DMA request (COMDE).
  4319. * @rmtoll DIER COMDE LL_TIM_DisableDMAReq_COM
  4320. * @param TIMx Timer instance
  4321. * @retval None
  4322. */
  4323. __STATIC_INLINE void LL_TIM_DisableDMAReq_COM(TIM_TypeDef *TIMx)
  4324. {
  4325. CLEAR_BIT(TIMx->DIER, TIM_DIER_COMDE);
  4326. }
  4327. /**
  4328. * @brief Indicates whether the commutation DMA request (COMDE) is enabled.
  4329. * @rmtoll DIER COMDE LL_TIM_IsEnabledDMAReq_COM
  4330. * @param TIMx Timer instance
  4331. * @retval State of bit (1 or 0).
  4332. */
  4333. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_COM(TIM_TypeDef *TIMx)
  4334. {
  4335. return ((READ_BIT(TIMx->DIER, TIM_DIER_COMDE) == (TIM_DIER_COMDE)) ? 1UL : 0UL);
  4336. }
  4337. /**
  4338. * @brief Enable trigger interrupt (TDE).
  4339. * @rmtoll DIER TDE LL_TIM_EnableDMAReq_TRIG
  4340. * @param TIMx Timer instance
  4341. * @retval None
  4342. */
  4343. __STATIC_INLINE void LL_TIM_EnableDMAReq_TRIG(TIM_TypeDef *TIMx)
  4344. {
  4345. SET_BIT(TIMx->DIER, TIM_DIER_TDE);
  4346. }
  4347. /**
  4348. * @brief Disable trigger interrupt (TDE).
  4349. * @rmtoll DIER TDE LL_TIM_DisableDMAReq_TRIG
  4350. * @param TIMx Timer instance
  4351. * @retval None
  4352. */
  4353. __STATIC_INLINE void LL_TIM_DisableDMAReq_TRIG(TIM_TypeDef *TIMx)
  4354. {
  4355. CLEAR_BIT(TIMx->DIER, TIM_DIER_TDE);
  4356. }
  4357. /**
  4358. * @brief Indicates whether the trigger interrupt (TDE) is enabled.
  4359. * @rmtoll DIER TDE LL_TIM_IsEnabledDMAReq_TRIG
  4360. * @param TIMx Timer instance
  4361. * @retval State of bit (1 or 0).
  4362. */
  4363. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_TRIG(TIM_TypeDef *TIMx)
  4364. {
  4365. return ((READ_BIT(TIMx->DIER, TIM_DIER_TDE) == (TIM_DIER_TDE)) ? 1UL : 0UL);
  4366. }
  4367. /**
  4368. * @}
  4369. */
  4370. /** @defgroup TIM_LL_EF_EVENT_Management EVENT-Management
  4371. * @{
  4372. */
  4373. /**
  4374. * @brief Generate an update event.
  4375. * @rmtoll EGR UG LL_TIM_GenerateEvent_UPDATE
  4376. * @param TIMx Timer instance
  4377. * @retval None
  4378. */
  4379. __STATIC_INLINE void LL_TIM_GenerateEvent_UPDATE(TIM_TypeDef *TIMx)
  4380. {
  4381. SET_BIT(TIMx->EGR, TIM_EGR_UG);
  4382. }
  4383. /**
  4384. * @brief Generate Capture/Compare 1 event.
  4385. * @rmtoll EGR CC1G LL_TIM_GenerateEvent_CC1
  4386. * @param TIMx Timer instance
  4387. * @retval None
  4388. */
  4389. __STATIC_INLINE void LL_TIM_GenerateEvent_CC1(TIM_TypeDef *TIMx)
  4390. {
  4391. SET_BIT(TIMx->EGR, TIM_EGR_CC1G);
  4392. }
  4393. /**
  4394. * @brief Generate Capture/Compare 2 event.
  4395. * @rmtoll EGR CC2G LL_TIM_GenerateEvent_CC2
  4396. * @param TIMx Timer instance
  4397. * @retval None
  4398. */
  4399. __STATIC_INLINE void LL_TIM_GenerateEvent_CC2(TIM_TypeDef *TIMx)
  4400. {
  4401. SET_BIT(TIMx->EGR, TIM_EGR_CC2G);
  4402. }
  4403. /**
  4404. * @brief Generate Capture/Compare 3 event.
  4405. * @rmtoll EGR CC3G LL_TIM_GenerateEvent_CC3
  4406. * @param TIMx Timer instance
  4407. * @retval None
  4408. */
  4409. __STATIC_INLINE void LL_TIM_GenerateEvent_CC3(TIM_TypeDef *TIMx)
  4410. {
  4411. SET_BIT(TIMx->EGR, TIM_EGR_CC3G);
  4412. }
  4413. /**
  4414. * @brief Generate Capture/Compare 4 event.
  4415. * @rmtoll EGR CC4G LL_TIM_GenerateEvent_CC4
  4416. * @param TIMx Timer instance
  4417. * @retval None
  4418. */
  4419. __STATIC_INLINE void LL_TIM_GenerateEvent_CC4(TIM_TypeDef *TIMx)
  4420. {
  4421. SET_BIT(TIMx->EGR, TIM_EGR_CC4G);
  4422. }
  4423. /**
  4424. * @brief Generate commutation event.
  4425. * @rmtoll EGR COMG LL_TIM_GenerateEvent_COM
  4426. * @param TIMx Timer instance
  4427. * @retval None
  4428. */
  4429. __STATIC_INLINE void LL_TIM_GenerateEvent_COM(TIM_TypeDef *TIMx)
  4430. {
  4431. SET_BIT(TIMx->EGR, TIM_EGR_COMG);
  4432. }
  4433. /**
  4434. * @brief Generate trigger event.
  4435. * @rmtoll EGR TG LL_TIM_GenerateEvent_TRIG
  4436. * @param TIMx Timer instance
  4437. * @retval None
  4438. */
  4439. __STATIC_INLINE void LL_TIM_GenerateEvent_TRIG(TIM_TypeDef *TIMx)
  4440. {
  4441. SET_BIT(TIMx->EGR, TIM_EGR_TG);
  4442. }
  4443. /**
  4444. * @brief Generate break event.
  4445. * @rmtoll EGR BG LL_TIM_GenerateEvent_BRK
  4446. * @param TIMx Timer instance
  4447. * @retval None
  4448. */
  4449. __STATIC_INLINE void LL_TIM_GenerateEvent_BRK(TIM_TypeDef *TIMx)
  4450. {
  4451. SET_BIT(TIMx->EGR, TIM_EGR_BG);
  4452. }
  4453. /**
  4454. * @brief Generate break 2 event.
  4455. * @rmtoll EGR B2G LL_TIM_GenerateEvent_BRK2
  4456. * @param TIMx Timer instance
  4457. * @retval None
  4458. */
  4459. __STATIC_INLINE void LL_TIM_GenerateEvent_BRK2(TIM_TypeDef *TIMx)
  4460. {
  4461. SET_BIT(TIMx->EGR, TIM_EGR_B2G);
  4462. }
  4463. /**
  4464. * @}
  4465. */
  4466. #if defined(USE_FULL_LL_DRIVER)
  4467. /** @defgroup TIM_LL_EF_Init Initialisation and deinitialisation functions
  4468. * @{
  4469. */
  4470. ErrorStatus LL_TIM_DeInit(TIM_TypeDef *TIMx);
  4471. void LL_TIM_StructInit(LL_TIM_InitTypeDef *TIM_InitStruct);
  4472. ErrorStatus LL_TIM_Init(TIM_TypeDef *TIMx, LL_TIM_InitTypeDef *TIM_InitStruct);
  4473. void LL_TIM_OC_StructInit(LL_TIM_OC_InitTypeDef *TIM_OC_InitStruct);
  4474. ErrorStatus LL_TIM_OC_Init(TIM_TypeDef *TIMx, uint32_t Channel, LL_TIM_OC_InitTypeDef *TIM_OC_InitStruct);
  4475. void LL_TIM_IC_StructInit(LL_TIM_IC_InitTypeDef *TIM_ICInitStruct);
  4476. ErrorStatus LL_TIM_IC_Init(TIM_TypeDef *TIMx, uint32_t Channel, LL_TIM_IC_InitTypeDef *TIM_IC_InitStruct);
  4477. void LL_TIM_ENCODER_StructInit(LL_TIM_ENCODER_InitTypeDef *TIM_EncoderInitStruct);
  4478. ErrorStatus LL_TIM_ENCODER_Init(TIM_TypeDef *TIMx, LL_TIM_ENCODER_InitTypeDef *TIM_EncoderInitStruct);
  4479. void LL_TIM_HALLSENSOR_StructInit(LL_TIM_HALLSENSOR_InitTypeDef *TIM_HallSensorInitStruct);
  4480. ErrorStatus LL_TIM_HALLSENSOR_Init(TIM_TypeDef *TIMx, LL_TIM_HALLSENSOR_InitTypeDef *TIM_HallSensorInitStruct);
  4481. void LL_TIM_BDTR_StructInit(LL_TIM_BDTR_InitTypeDef *TIM_BDTRInitStruct);
  4482. ErrorStatus LL_TIM_BDTR_Init(TIM_TypeDef *TIMx, LL_TIM_BDTR_InitTypeDef *TIM_BDTRInitStruct);
  4483. /**
  4484. * @}
  4485. */
  4486. #endif /* USE_FULL_LL_DRIVER */
  4487. /**
  4488. * @}
  4489. */
  4490. /**
  4491. * @}
  4492. */
  4493. #endif /* TIM1 || TIM2 || TIM3 || TIM4 || TIM5 || TIM6 || TIM7 || TIM8 || TIM12 || TIM13 ||TIM14 || TIM15 || TIM16 || TIM17 */
  4494. /**
  4495. * @}
  4496. */
  4497. #ifdef __cplusplus
  4498. }
  4499. #endif
  4500. #endif /* __STM32H7xx_LL_TIM_H */
  4501. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/