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.
 
 
 

4809 lines
207 KiB

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