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.
 
 
 

3972 lines
166 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_ll_tim.h
  4. * @author MCD Application Team
  5. * @version V1.7.1
  6. * @date 14-April-2017
  7. * @brief Header file of TIM LL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32F4xx_LL_TIM_H
  39. #define __STM32F4xx_LL_TIM_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32f4xx.h"
  45. /** @addtogroup STM32F4xx_LL_Driver
  46. * @{
  47. */
  48. #if defined (TIM1) || defined (TIM2) || defined (TIM3) || defined (TIM4) || defined (TIM5) || defined (TIM6) || defined (TIM7) || defined (TIM8) || defined (TIM9) || defined (TIM10) || defined (TIM11) || defined (TIM12) || defined (TIM13) || defined (TIM14)
  49. /** @defgroup TIM_LL TIM
  50. * @{
  51. */
  52. /* Private types -------------------------------------------------------------*/
  53. /* Private variables ---------------------------------------------------------*/
  54. /** @defgroup TIM_LL_Private_Variables TIM Private Variables
  55. * @{
  56. */
  57. static const uint8_t OFFSET_TAB_CCMRx[] =
  58. {
  59. 0x00U, /* 0: TIMx_CH1 */
  60. 0x00U, /* 1: TIMx_CH1N */
  61. 0x00U, /* 2: TIMx_CH2 */
  62. 0x00U, /* 3: TIMx_CH2N */
  63. 0x04U, /* 4: TIMx_CH3 */
  64. 0x04U, /* 5: TIMx_CH3N */
  65. 0x04U /* 6: TIMx_CH4 */
  66. };
  67. static const uint8_t SHIFT_TAB_OCxx[] =
  68. {
  69. 0U, /* 0: OC1M, OC1FE, OC1PE */
  70. 0U, /* 1: - NA */
  71. 8U, /* 2: OC2M, OC2FE, OC2PE */
  72. 0U, /* 3: - NA */
  73. 0U, /* 4: OC3M, OC3FE, OC3PE */
  74. 0U, /* 5: - NA */
  75. 8U /* 6: OC4M, OC4FE, OC4PE */
  76. };
  77. static const uint8_t SHIFT_TAB_ICxx[] =
  78. {
  79. 0U, /* 0: CC1S, IC1PSC, IC1F */
  80. 0U, /* 1: - NA */
  81. 8U, /* 2: CC2S, IC2PSC, IC2F */
  82. 0U, /* 3: - NA */
  83. 0U, /* 4: CC3S, IC3PSC, IC3F */
  84. 0U, /* 5: - NA */
  85. 8U /* 6: CC4S, IC4PSC, IC4F */
  86. };
  87. static const uint8_t SHIFT_TAB_CCxP[] =
  88. {
  89. 0U, /* 0: CC1P */
  90. 2U, /* 1: CC1NP */
  91. 4U, /* 2: CC2P */
  92. 6U, /* 3: CC2NP */
  93. 8U, /* 4: CC3P */
  94. 10U, /* 5: CC3NP */
  95. 12U /* 6: CC4P */
  96. };
  97. static const uint8_t SHIFT_TAB_OISx[] =
  98. {
  99. 0U, /* 0: OIS1 */
  100. 1U, /* 1: OIS1N */
  101. 2U, /* 2: OIS2 */
  102. 3U, /* 3: OIS2N */
  103. 4U, /* 4: OIS3 */
  104. 5U, /* 5: OIS3N */
  105. 6U /* 6: OIS4 */
  106. };
  107. /**
  108. * @}
  109. */
  110. /* Private constants ---------------------------------------------------------*/
  111. /** @defgroup TIM_LL_Private_Constants TIM Private Constants
  112. * @{
  113. */
  114. /* Remap mask definitions */
  115. #define TIMx_OR_RMP_SHIFT 16U
  116. #define TIMx_OR_RMP_MASK 0x0000FFFFU
  117. #define TIM2_OR_RMP_MASK (TIM_OR_ITR1_RMP << TIMx_OR_RMP_SHIFT)
  118. #define TIM5_OR_RMP_MASK (TIM_OR_TI4_RMP << TIMx_OR_RMP_SHIFT)
  119. #define TIM11_OR_RMP_MASK (TIM_OR_TI1_RMP << TIMx_OR_RMP_SHIFT)
  120. /* Mask used to set the TDG[x:0] of the DTG bits of the TIMx_BDTR register */
  121. #define DT_DELAY_1 ((uint8_t)0x7FU)
  122. #define DT_DELAY_2 ((uint8_t)0x3FU)
  123. #define DT_DELAY_3 ((uint8_t)0x1FU)
  124. #define DT_DELAY_4 ((uint8_t)0x1FU)
  125. /* Mask used to set the DTG[7:5] bits of the DTG bits of the TIMx_BDTR register */
  126. #define DT_RANGE_1 ((uint8_t)0x00U)
  127. #define DT_RANGE_2 ((uint8_t)0x80U)
  128. #define DT_RANGE_3 ((uint8_t)0xC0U)
  129. #define DT_RANGE_4 ((uint8_t)0xE0U)
  130. /**
  131. * @}
  132. */
  133. /* Private macros ------------------------------------------------------------*/
  134. /** @defgroup TIM_LL_Private_Macros TIM Private Macros
  135. * @{
  136. */
  137. /** @brief Convert channel id into channel index.
  138. * @param __CHANNEL__ This parameter can be one of the following values:
  139. * @arg @ref LL_TIM_CHANNEL_CH1
  140. * @arg @ref LL_TIM_CHANNEL_CH1N
  141. * @arg @ref LL_TIM_CHANNEL_CH2
  142. * @arg @ref LL_TIM_CHANNEL_CH2N
  143. * @arg @ref LL_TIM_CHANNEL_CH3
  144. * @arg @ref LL_TIM_CHANNEL_CH3N
  145. * @arg @ref LL_TIM_CHANNEL_CH4
  146. * @retval none
  147. */
  148. #define TIM_GET_CHANNEL_INDEX( __CHANNEL__) \
  149. (((__CHANNEL__) == LL_TIM_CHANNEL_CH1) ? 0U :\
  150. ((__CHANNEL__) == LL_TIM_CHANNEL_CH1N) ? 1U :\
  151. ((__CHANNEL__) == LL_TIM_CHANNEL_CH2) ? 2U :\
  152. ((__CHANNEL__) == LL_TIM_CHANNEL_CH2N) ? 3U :\
  153. ((__CHANNEL__) == LL_TIM_CHANNEL_CH3) ? 4U :\
  154. ((__CHANNEL__) == LL_TIM_CHANNEL_CH3N) ? 5U : 6U)
  155. /** @brief Calculate the deadtime sampling period(in ps).
  156. * @param __TIMCLK__ timer input clock frequency (in Hz).
  157. * @param __CKD__ This parameter can be one of the following values:
  158. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  159. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  160. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  161. * @retval none
  162. */
  163. #define TIM_CALC_DTS(__TIMCLK__, __CKD__) \
  164. (((__CKD__) == LL_TIM_CLOCKDIVISION_DIV1) ? ((uint64_t)1000000000000U/(__TIMCLK__)) : \
  165. ((__CKD__) == LL_TIM_CLOCKDIVISION_DIV2) ? ((uint64_t)1000000000000U/((__TIMCLK__) >> 1U)) : \
  166. ((uint64_t)1000000000000U/((__TIMCLK__) >> 2U)))
  167. /**
  168. * @}
  169. */
  170. /* Exported types ------------------------------------------------------------*/
  171. #if defined(USE_FULL_LL_DRIVER)
  172. /** @defgroup TIM_LL_ES_INIT TIM Exported Init structure
  173. * @{
  174. */
  175. /**
  176. * @brief TIM Time Base configuration structure definition.
  177. */
  178. typedef struct
  179. {
  180. uint16_t Prescaler; /*!< Specifies the prescaler value used to divide the TIM clock.
  181. This parameter can be a number between Min_Data=0x0000 and Max_Data=0xFFFF.
  182. This feature can be modified afterwards using unitary function @ref LL_TIM_SetPrescaler().*/
  183. uint32_t CounterMode; /*!< Specifies the counter mode.
  184. This parameter can be a value of @ref TIM_LL_EC_COUNTERMODE.
  185. This feature can be modified afterwards using unitary function @ref LL_TIM_SetCounterMode().*/
  186. uint32_t Autoreload; /*!< Specifies the auto reload value to be loaded into the active
  187. Auto-Reload Register at the next update event.
  188. This parameter must be a number between Min_Data=0x0000 and Max_Data=0xFFFF.
  189. Some timer instances may support 32 bits counters. In that case this parameter must be a number between 0x0000 and 0xFFFFFFFF.
  190. This feature can be modified afterwards using unitary function @ref LL_TIM_SetAutoReload().*/
  191. uint32_t ClockDivision; /*!< Specifies the clock division.
  192. This parameter can be a value of @ref TIM_LL_EC_CLOCKDIVISION.
  193. This feature can be modified afterwards using unitary function @ref LL_TIM_SetClockDivision().*/
  194. uint8_t RepetitionCounter; /*!< Specifies the repetition counter value. Each time the RCR downcounter
  195. reaches zero, an update event is generated and counting restarts
  196. from the RCR value (N).
  197. This means in PWM mode that (N+1) corresponds to:
  198. - the number of PWM periods in edge-aligned mode
  199. - the number of half PWM period in center-aligned mode
  200. This parameter must be a number between 0x00 and 0xFF.
  201. This feature can be modified afterwards using unitary function @ref LL_TIM_SetRepetitionCounter().*/
  202. } LL_TIM_InitTypeDef;
  203. /**
  204. * @brief TIM Output Compare configuration structure definition.
  205. */
  206. typedef struct
  207. {
  208. uint32_t OCMode; /*!< Specifies the output mode.
  209. This parameter can be a value of @ref TIM_LL_EC_OCMODE.
  210. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetMode().*/
  211. uint32_t OCState; /*!< Specifies the TIM Output Compare state.
  212. This parameter can be a value of @ref TIM_LL_EC_OCSTATE.
  213. This feature can be modified afterwards using unitary functions @ref LL_TIM_CC_EnableChannel() or @ref LL_TIM_CC_DisableChannel().*/
  214. uint32_t OCNState; /*!< Specifies the TIM complementary Output Compare state.
  215. This parameter can be a value of @ref TIM_LL_EC_OCSTATE.
  216. This feature can be modified afterwards using unitary functions @ref LL_TIM_CC_EnableChannel() or @ref LL_TIM_CC_DisableChannel().*/
  217. uint32_t CompareValue; /*!< Specifies the Compare value to be loaded into the Capture Compare Register.
  218. This parameter can be a number between Min_Data=0x0000 and Max_Data=0xFFFF.
  219. This feature can be modified afterwards using unitary function LL_TIM_OC_SetCompareCHx (x=1..6).*/
  220. uint32_t OCPolarity; /*!< Specifies the output polarity.
  221. This parameter can be a value of @ref TIM_LL_EC_OCPOLARITY.
  222. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetPolarity().*/
  223. uint32_t OCNPolarity; /*!< Specifies the complementary output polarity.
  224. This parameter can be a value of @ref TIM_LL_EC_OCPOLARITY.
  225. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetPolarity().*/
  226. uint32_t OCIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
  227. This parameter can be a value of @ref TIM_LL_EC_OCIDLESTATE.
  228. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetIdleState().*/
  229. uint32_t OCNIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
  230. This parameter can be a value of @ref TIM_LL_EC_OCIDLESTATE.
  231. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetIdleState().*/
  232. } LL_TIM_OC_InitTypeDef;
  233. /**
  234. * @brief TIM Input Capture configuration structure definition.
  235. */
  236. typedef struct
  237. {
  238. uint32_t ICPolarity; /*!< Specifies the active edge of the input signal.
  239. This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
  240. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
  241. uint32_t ICActiveInput; /*!< Specifies the input.
  242. This parameter can be a value of @ref TIM_LL_EC_ACTIVEINPUT.
  243. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetActiveInput().*/
  244. uint32_t ICPrescaler; /*!< Specifies the Input Capture Prescaler.
  245. This parameter can be a value of @ref TIM_LL_EC_ICPSC.
  246. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
  247. uint32_t ICFilter; /*!< Specifies the input capture filter.
  248. This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
  249. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
  250. } LL_TIM_IC_InitTypeDef;
  251. /**
  252. * @brief TIM Encoder interface configuration structure definition.
  253. */
  254. typedef struct
  255. {
  256. uint32_t EncoderMode; /*!< Specifies the encoder resolution (x2 or x4).
  257. This parameter can be a value of @ref TIM_LL_EC_ENCODERMODE.
  258. This feature can be modified afterwards using unitary function @ref LL_TIM_SetEncoderMode().*/
  259. uint32_t IC1Polarity; /*!< Specifies the active edge of TI1 input.
  260. This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
  261. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
  262. uint32_t IC1ActiveInput; /*!< Specifies the TI1 input source
  263. This parameter can be a value of @ref TIM_LL_EC_ACTIVEINPUT.
  264. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetActiveInput().*/
  265. uint32_t IC1Prescaler; /*!< Specifies the TI1 input prescaler value.
  266. This parameter can be a value of @ref TIM_LL_EC_ICPSC.
  267. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
  268. uint32_t IC1Filter; /*!< Specifies the TI1 input filter.
  269. This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
  270. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
  271. uint32_t IC2Polarity; /*!< Specifies the active edge of TI2 input.
  272. This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
  273. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
  274. uint32_t IC2ActiveInput; /*!< Specifies the TI2 input source
  275. This parameter can be a value of @ref TIM_LL_EC_ACTIVEINPUT.
  276. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetActiveInput().*/
  277. uint32_t IC2Prescaler; /*!< Specifies the TI2 input prescaler value.
  278. This parameter can be a value of @ref TIM_LL_EC_ICPSC.
  279. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
  280. uint32_t IC2Filter; /*!< Specifies the TI2 input filter.
  281. This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
  282. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
  283. } LL_TIM_ENCODER_InitTypeDef;
  284. /**
  285. * @brief TIM Hall sensor interface configuration structure definition.
  286. */
  287. typedef struct
  288. {
  289. uint32_t IC1Polarity; /*!< Specifies the active edge of TI1 input.
  290. This parameter can be a value of @ref TIM_LL_EC_IC_POLARITY.
  291. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPolarity().*/
  292. uint32_t IC1Prescaler; /*!< Specifies the TI1 input prescaler value.
  293. Prescaler must be set to get a maximum counter period longer than the
  294. time interval between 2 consecutive changes on the Hall inputs.
  295. This parameter can be a value of @ref TIM_LL_EC_ICPSC.
  296. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetPrescaler().*/
  297. uint32_t IC1Filter; /*!< Specifies the TI1 input filter.
  298. This parameter can be a value of @ref TIM_LL_EC_IC_FILTER.
  299. This feature can be modified afterwards using unitary function @ref LL_TIM_IC_SetFilter().*/
  300. uint32_t CommutationDelay; /*!< Specifies the compare value to be loaded into the Capture Compare Register.
  301. A positive pulse (TRGO event) is generated with a programmable delay every time
  302. a change occurs on the Hall inputs.
  303. This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF.
  304. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetCompareCH2().*/
  305. } LL_TIM_HALLSENSOR_InitTypeDef;
  306. /**
  307. * @brief BDTR (Break and Dead Time) structure definition
  308. */
  309. typedef struct
  310. {
  311. uint32_t OSSRState; /*!< Specifies the Off-State selection used in Run mode.
  312. This parameter can be a value of @ref TIM_LL_EC_OSSR
  313. This feature can be modified afterwards using unitary function @ref LL_TIM_SetOffStates()
  314. @note This bit-field cannot be modified as long as LOCK level 2 has been programmed. */
  315. uint32_t OSSIState; /*!< Specifies the Off-State used in Idle state.
  316. This parameter can be a value of @ref TIM_LL_EC_OSSI
  317. This feature can be modified afterwards using unitary function @ref LL_TIM_SetOffStates()
  318. @note This bit-field cannot be modified as long as LOCK level 2 has been programmed. */
  319. uint32_t LockLevel; /*!< Specifies the LOCK level parameters.
  320. This parameter can be a value of @ref TIM_LL_EC_LOCKLEVEL
  321. @note The LOCK bits can be written only once after the reset. Once the TIMx_BDTR register
  322. has been written, their content is frozen until the next reset.*/
  323. uint8_t DeadTime; /*!< Specifies the delay time between the switching-off and the
  324. switching-on of the outputs.
  325. This parameter can be a number between Min_Data = 0x00 and Max_Data = 0xFF.
  326. This feature can be modified afterwards using unitary function @ref LL_TIM_OC_SetDeadTime()
  327. @note This bit-field can not be modified as long as LOCK level 1, 2 or 3 has been programmed. */
  328. uint16_t BreakState; /*!< Specifies whether the TIM Break input is enabled or not.
  329. This parameter can be a value of @ref TIM_LL_EC_BREAK_ENABLE
  330. This feature can be modified afterwards using unitary functions @ref LL_TIM_EnableBRK() or @ref LL_TIM_DisableBRK()
  331. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  332. uint32_t BreakPolarity; /*!< Specifies the TIM Break Input pin polarity.
  333. This parameter can be a value of @ref TIM_LL_EC_BREAK_POLARITY
  334. This feature can be modified afterwards using unitary function @ref LL_TIM_ConfigBRK()
  335. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  336. uint32_t AutomaticOutput; /*!< Specifies whether the TIM Automatic Output feature is enabled or not.
  337. This parameter can be a value of @ref TIM_LL_EC_AUTOMATICOUTPUT_ENABLE
  338. This feature can be modified afterwards using unitary functions @ref LL_TIM_EnableAutomaticOutput() or @ref LL_TIM_DisableAutomaticOutput()
  339. @note This bit-field can not be modified as long as LOCK level 1 has been programmed. */
  340. } LL_TIM_BDTR_InitTypeDef;
  341. /**
  342. * @}
  343. */
  344. #endif /* USE_FULL_LL_DRIVER */
  345. /* Exported constants --------------------------------------------------------*/
  346. /** @defgroup TIM_LL_Exported_Constants TIM Exported Constants
  347. * @{
  348. */
  349. /** @defgroup TIM_LL_EC_GET_FLAG Get Flags Defines
  350. * @brief Flags defines which can be used with LL_TIM_ReadReg function.
  351. * @{
  352. */
  353. #define LL_TIM_SR_UIF TIM_SR_UIF /*!< Update interrupt flag */
  354. #define LL_TIM_SR_CC1IF TIM_SR_CC1IF /*!< Capture/compare 1 interrupt flag */
  355. #define LL_TIM_SR_CC2IF TIM_SR_CC2IF /*!< Capture/compare 2 interrupt flag */
  356. #define LL_TIM_SR_CC3IF TIM_SR_CC3IF /*!< Capture/compare 3 interrupt flag */
  357. #define LL_TIM_SR_CC4IF TIM_SR_CC4IF /*!< Capture/compare 4 interrupt flag */
  358. #define LL_TIM_SR_COMIF TIM_SR_COMIF /*!< COM interrupt flag */
  359. #define LL_TIM_SR_TIF TIM_SR_TIF /*!< Trigger interrupt flag */
  360. #define LL_TIM_SR_BIF TIM_SR_BIF /*!< Break interrupt flag */
  361. #define LL_TIM_SR_CC1OF TIM_SR_CC1OF /*!< Capture/Compare 1 overcapture flag */
  362. #define LL_TIM_SR_CC2OF TIM_SR_CC2OF /*!< Capture/Compare 2 overcapture flag */
  363. #define LL_TIM_SR_CC3OF TIM_SR_CC3OF /*!< Capture/Compare 3 overcapture flag */
  364. #define LL_TIM_SR_CC4OF TIM_SR_CC4OF /*!< Capture/Compare 4 overcapture flag */
  365. /**
  366. * @}
  367. */
  368. #if defined(USE_FULL_LL_DRIVER)
  369. /** @defgroup TIM_LL_EC_BREAK_ENABLE Break Enable
  370. * @{
  371. */
  372. #define LL_TIM_BREAK_DISABLE 0x00000000U /*!< Break function disabled */
  373. #define LL_TIM_BREAK_ENABLE TIM_BDTR_BKE /*!< Break function enabled */
  374. /**
  375. * @}
  376. */
  377. /** @defgroup TIM_LL_EC_AUTOMATICOUTPUT_ENABLE Automatic output enable
  378. * @{
  379. */
  380. #define LL_TIM_AUTOMATICOUTPUT_DISABLE 0x00000000U /*!< MOE can be set only by software */
  381. #define LL_TIM_AUTOMATICOUTPUT_ENABLE TIM_BDTR_AOE /*!< MOE can be set by software or automatically at the next update event */
  382. /**
  383. * @}
  384. */
  385. #endif /* USE_FULL_LL_DRIVER */
  386. /** @defgroup TIM_LL_EC_IT IT Defines
  387. * @brief IT defines which can be used with LL_TIM_ReadReg and LL_TIM_WriteReg functions.
  388. * @{
  389. */
  390. #define LL_TIM_DIER_UIE TIM_DIER_UIE /*!< Update interrupt enable */
  391. #define LL_TIM_DIER_CC1IE TIM_DIER_CC1IE /*!< Capture/compare 1 interrupt enable */
  392. #define LL_TIM_DIER_CC2IE TIM_DIER_CC2IE /*!< Capture/compare 2 interrupt enable */
  393. #define LL_TIM_DIER_CC3IE TIM_DIER_CC3IE /*!< Capture/compare 3 interrupt enable */
  394. #define LL_TIM_DIER_CC4IE TIM_DIER_CC4IE /*!< Capture/compare 4 interrupt enable */
  395. #define LL_TIM_DIER_COMIE TIM_DIER_COMIE /*!< COM interrupt enable */
  396. #define LL_TIM_DIER_TIE TIM_DIER_TIE /*!< Trigger interrupt enable */
  397. #define LL_TIM_DIER_BIE TIM_DIER_BIE /*!< Break interrupt enable */
  398. /**
  399. * @}
  400. */
  401. /** @defgroup TIM_LL_EC_UPDATESOURCE Update Source
  402. * @{
  403. */
  404. #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 */
  405. #define LL_TIM_UPDATESOURCE_COUNTER TIM_CR1_URS /*!< Only counter overflow/underflow generates an update request */
  406. /**
  407. * @}
  408. */
  409. /** @defgroup TIM_LL_EC_ONEPULSEMODE One Pulse Mode
  410. * @{
  411. */
  412. #define LL_TIM_ONEPULSEMODE_SINGLE TIM_CR1_OPM /*!< Counter is not stopped at update event */
  413. #define LL_TIM_ONEPULSEMODE_REPETITIVE 0x00000000U /*!< Counter stops counting at the next update event */
  414. /**
  415. * @}
  416. */
  417. /** @defgroup TIM_LL_EC_COUNTERMODE Counter Mode
  418. * @{
  419. */
  420. #define LL_TIM_COUNTERMODE_UP 0x00000000U /*!<Counter used as upcounter */
  421. #define LL_TIM_COUNTERMODE_DOWN TIM_CR1_DIR /*!< Counter used as downcounter */
  422. #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. */
  423. #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 */
  424. #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. */
  425. /**
  426. * @}
  427. */
  428. /** @defgroup TIM_LL_EC_CLOCKDIVISION Clock Division
  429. * @{
  430. */
  431. #define LL_TIM_CLOCKDIVISION_DIV1 0x00000000U /*!< tDTS=tCK_INT */
  432. #define LL_TIM_CLOCKDIVISION_DIV2 TIM_CR1_CKD_0 /*!< tDTS=2*tCK_INT */
  433. #define LL_TIM_CLOCKDIVISION_DIV4 TIM_CR1_CKD_1 /*!< tDTS=4*tCK_INT */
  434. /**
  435. * @}
  436. */
  437. /** @defgroup TIM_LL_EC_COUNTERDIRECTION Counter Direction
  438. * @{
  439. */
  440. #define LL_TIM_COUNTERDIRECTION_UP 0x00000000U /*!< Timer counter counts up */
  441. #define LL_TIM_COUNTERDIRECTION_DOWN TIM_CR1_DIR /*!< Timer counter counts down */
  442. /**
  443. * @}
  444. */
  445. /** @defgroup TIM_LL_EC_CCUPDATESOURCE Capture Compare Update Source
  446. * @{
  447. */
  448. #define LL_TIM_CCUPDATESOURCE_COMG_ONLY 0x00000000U /*!< Capture/compare control bits are updated by setting the COMG bit only */
  449. #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) */
  450. /**
  451. * @}
  452. */
  453. /** @defgroup TIM_LL_EC_CCDMAREQUEST Capture Compare DMA Request
  454. * @{
  455. */
  456. #define LL_TIM_CCDMAREQUEST_CC 0x00000000U /*!< CCx DMA request sent when CCx event occurs */
  457. #define LL_TIM_CCDMAREQUEST_UPDATE TIM_CR2_CCDS /*!< CCx DMA requests sent when update event occurs */
  458. /**
  459. * @}
  460. */
  461. /** @defgroup TIM_LL_EC_LOCKLEVEL Lock Level
  462. * @{
  463. */
  464. #define LL_TIM_LOCKLEVEL_OFF 0x00000000U /*!< LOCK OFF - No bit is write protected */
  465. #define LL_TIM_LOCKLEVEL_1 TIM_BDTR_LOCK_0 /*!< LOCK Level 1 */
  466. #define LL_TIM_LOCKLEVEL_2 TIM_BDTR_LOCK_1 /*!< LOCK Level 2 */
  467. #define LL_TIM_LOCKLEVEL_3 TIM_BDTR_LOCK /*!< LOCK Level 3 */
  468. /**
  469. * @}
  470. */
  471. /** @defgroup TIM_LL_EC_CHANNEL Channel
  472. * @{
  473. */
  474. #define LL_TIM_CHANNEL_CH1 TIM_CCER_CC1E /*!< Timer input/output channel 1 */
  475. #define LL_TIM_CHANNEL_CH1N TIM_CCER_CC1NE /*!< Timer complementary output channel 1 */
  476. #define LL_TIM_CHANNEL_CH2 TIM_CCER_CC2E /*!< Timer input/output channel 2 */
  477. #define LL_TIM_CHANNEL_CH2N TIM_CCER_CC2NE /*!< Timer complementary output channel 2 */
  478. #define LL_TIM_CHANNEL_CH3 TIM_CCER_CC3E /*!< Timer input/output channel 3 */
  479. #define LL_TIM_CHANNEL_CH3N TIM_CCER_CC3NE /*!< Timer complementary output channel 3 */
  480. #define LL_TIM_CHANNEL_CH4 TIM_CCER_CC4E /*!< Timer input/output channel 4 */
  481. /**
  482. * @}
  483. */
  484. #if defined(USE_FULL_LL_DRIVER)
  485. /** @defgroup TIM_LL_EC_OCSTATE Output Configuration State
  486. * @{
  487. */
  488. #define LL_TIM_OCSTATE_DISABLE 0x00000000U /*!< OCx is not active */
  489. #define LL_TIM_OCSTATE_ENABLE TIM_CCER_CC1E /*!< OCx signal is output on the corresponding output pin */
  490. /**
  491. * @}
  492. */
  493. #endif /* USE_FULL_LL_DRIVER */
  494. /** @defgroup TIM_LL_EC_OCMODE Output Configuration Mode
  495. * @{
  496. */
  497. #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 */
  498. #define LL_TIM_OCMODE_ACTIVE TIM_CCMR1_OC1M_0 /*!<OCyREF is forced high on compare match*/
  499. #define LL_TIM_OCMODE_INACTIVE TIM_CCMR1_OC1M_1 /*!<OCyREF is forced low on compare match*/
  500. #define LL_TIM_OCMODE_TOGGLE (TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0) /*!<OCyREF toggles on compare match*/
  501. #define LL_TIM_OCMODE_FORCED_INACTIVE TIM_CCMR1_OC1M_2 /*!<OCyREF is forced low*/
  502. #define LL_TIM_OCMODE_FORCED_ACTIVE (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_0) /*!<OCyREF is forced high*/
  503. #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.*/
  504. #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*/
  505. /**
  506. * @}
  507. */
  508. /** @defgroup TIM_LL_EC_OCPOLARITY Output Configuration Polarity
  509. * @{
  510. */
  511. #define LL_TIM_OCPOLARITY_HIGH 0x00000000U /*!< OCxactive high*/
  512. #define LL_TIM_OCPOLARITY_LOW TIM_CCER_CC1P /*!< OCxactive low*/
  513. /**
  514. * @}
  515. */
  516. /** @defgroup TIM_LL_EC_OCIDLESTATE Output Configuration Idle State
  517. * @{
  518. */
  519. #define LL_TIM_OCIDLESTATE_LOW 0x00000000U /*!<OCx=0 (after a dead-time if OC is implemented) when MOE=0*/
  520. #define LL_TIM_OCIDLESTATE_HIGH TIM_CR2_OIS1 /*!<OCx=1 (after a dead-time if OC is implemented) when MOE=0*/
  521. /**
  522. * @}
  523. */
  524. /** @defgroup TIM_LL_EC_ACTIVEINPUT Active Input Selection
  525. * @{
  526. */
  527. #define LL_TIM_ACTIVEINPUT_DIRECTTI (TIM_CCMR1_CC1S_0 << 16U) /*!< ICx is mapped on TIx */
  528. #define LL_TIM_ACTIVEINPUT_INDIRECTTI (TIM_CCMR1_CC1S_1 << 16U) /*!< ICx is mapped on TIy */
  529. #define LL_TIM_ACTIVEINPUT_TRC (TIM_CCMR1_CC1S << 16U) /*!< ICx is mapped on TRC */
  530. /**
  531. * @}
  532. */
  533. /** @defgroup TIM_LL_EC_ICPSC Input Configuration Prescaler
  534. * @{
  535. */
  536. #define LL_TIM_ICPSC_DIV1 0x00000000U /*!< No prescaler, capture is done each time an edge is detected on the capture input */
  537. #define LL_TIM_ICPSC_DIV2 (TIM_CCMR1_IC1PSC_0 << 16U) /*!< Capture is done once every 2 events */
  538. #define LL_TIM_ICPSC_DIV4 (TIM_CCMR1_IC1PSC_1 << 16U) /*!< Capture is done once every 4 events */
  539. #define LL_TIM_ICPSC_DIV8 (TIM_CCMR1_IC1PSC << 16U) /*!< Capture is done once every 8 events */
  540. /**
  541. * @}
  542. */
  543. /** @defgroup TIM_LL_EC_IC_FILTER Input Configuration Filter
  544. * @{
  545. */
  546. #define LL_TIM_IC_FILTER_FDIV1 0x00000000U /*!< No filter, sampling is done at fDTS */
  547. #define LL_TIM_IC_FILTER_FDIV1_N2 (TIM_CCMR1_IC1F_0 << 16U) /*!< fSAMPLING=fCK_INT, N=2 */
  548. #define LL_TIM_IC_FILTER_FDIV1_N4 (TIM_CCMR1_IC1F_1 << 16U) /*!< fSAMPLING=fCK_INT, N=4 */
  549. #define LL_TIM_IC_FILTER_FDIV1_N8 ((TIM_CCMR1_IC1F_1 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fCK_INT, N=8 */
  550. #define LL_TIM_IC_FILTER_FDIV2_N6 (TIM_CCMR1_IC1F_2 << 16U) /*!< fSAMPLING=fDTS/2, N=6 */
  551. #define LL_TIM_IC_FILTER_FDIV2_N8 ((TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/2, N=8 */
  552. #define LL_TIM_IC_FILTER_FDIV4_N6 ((TIM_CCMR1_IC1F_2 | TIM_CCMR1_IC1F_1) << 16U) /*!< fSAMPLING=fDTS/4, N=6 */
  553. #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 */
  554. #define LL_TIM_IC_FILTER_FDIV8_N6 (TIM_CCMR1_IC1F_3 << 16U) /*!< fSAMPLING=fDTS/8, N=6 */
  555. #define LL_TIM_IC_FILTER_FDIV8_N8 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_0) << 16U) /*!< fSAMPLING=fDTS/8, N=8 */
  556. #define LL_TIM_IC_FILTER_FDIV16_N5 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_1) << 16U) /*!< fSAMPLING=fDTS/16, N=5 */
  557. #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 */
  558. #define LL_TIM_IC_FILTER_FDIV16_N8 ((TIM_CCMR1_IC1F_3 | TIM_CCMR1_IC1F_2) << 16U) /*!< fSAMPLING=fDTS/16, N=8 */
  559. #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 */
  560. #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 */
  561. #define LL_TIM_IC_FILTER_FDIV32_N8 (TIM_CCMR1_IC1F << 16U) /*!< fSAMPLING=fDTS/32, N=8 */
  562. /**
  563. * @}
  564. */
  565. /** @defgroup TIM_LL_EC_IC_POLARITY Input Configuration Polarity
  566. * @{
  567. */
  568. #define LL_TIM_IC_POLARITY_RISING 0x00000000U /*!< The circuit is sensitive to TIxFP1 rising edge, TIxFP1 is not inverted */
  569. #define LL_TIM_IC_POLARITY_FALLING TIM_CCER_CC1P /*!< The circuit is sensitive to TIxFP1 falling edge, TIxFP1 is inverted */
  570. #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 */
  571. /**
  572. * @}
  573. */
  574. /** @defgroup TIM_LL_EC_CLOCKSOURCE Clock Source
  575. * @{
  576. */
  577. #define LL_TIM_CLOCKSOURCE_INTERNAL 0x00000000U /*!< The timer is clocked by the internal clock provided from the RCC */
  578. #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 inpu t*/
  579. #define LL_TIM_CLOCKSOURCE_EXT_MODE2 TIM_SMCR_ECE /*!< Counter counts at each rising or falling edge on the external trigger input ETR */
  580. /**
  581. * @}
  582. */
  583. /** @defgroup TIM_LL_EC_ENCODERMODE Encoder Mode
  584. * @{
  585. */
  586. #define LL_TIM_ENCODERMODE_X2_TI1 TIM_SMCR_SMS_0 /*!< Encoder mode 1 - Counter counts up/down on TI2FP2 edge depending on TI1FP1 level */
  587. #define LL_TIM_ENCODERMODE_X2_TI2 TIM_SMCR_SMS_1 /*!< Encoder mode 2 - Counter counts up/down on TI1FP1 edge depending on TI2FP2 level */
  588. #define LL_TIM_ENCODERMODE_X4_TI12 (TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0) /*!< Encoder mode 3 - Counter counts up/down on both TI1FP1 and TI2FP2 edges depending on the level of the other input l */
  589. /**
  590. * @}
  591. */
  592. /** @defgroup TIM_LL_EC_TRGO Trigger Output
  593. * @{
  594. */
  595. #define LL_TIM_TRGO_RESET 0x00000000U /*!< UG bit from the TIMx_EGR register is used as trigger output */
  596. #define LL_TIM_TRGO_ENABLE TIM_CR2_MMS_0 /*!< Counter Enable signal (CNT_EN) is used as trigger output */
  597. #define LL_TIM_TRGO_UPDATE TIM_CR2_MMS_1 /*!< Update event is used as trigger output */
  598. #define LL_TIM_TRGO_CC1IF (TIM_CR2_MMS_1 | TIM_CR2_MMS_0) /*!< CC1 capture or a compare match is used as trigger output */
  599. #define LL_TIM_TRGO_OC1REF TIM_CR2_MMS_2 /*!< OC1REF signal is used as trigger output */
  600. #define LL_TIM_TRGO_OC2REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_0) /*!< OC2REF signal is used as trigger output */
  601. #define LL_TIM_TRGO_OC3REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_1) /*!< OC3REF signal is used as trigger output */
  602. #define LL_TIM_TRGO_OC4REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_1 | TIM_CR2_MMS_0) /*!< OC4REF signal is used as trigger output */
  603. /**
  604. * @}
  605. */
  606. /** @defgroup TIM_LL_EC_SLAVEMODE Slave Mode
  607. * @{
  608. */
  609. #define LL_TIM_SLAVEMODE_DISABLED 0x00000000U /*!< Slave mode disabled */
  610. #define LL_TIM_SLAVEMODE_RESET TIM_SMCR_SMS_2 /*!< Reset Mode - Rising edge of the selected trigger input (TRGI) reinitializes the counter */
  611. #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 */
  612. #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 */
  613. /**
  614. * @}
  615. */
  616. /** @defgroup TIM_LL_EC_TS Trigger Selection
  617. * @{
  618. */
  619. #define LL_TIM_TS_ITR0 0x00000000U /*!< Internal Trigger 0 (ITR0) is used as trigger input */
  620. #define LL_TIM_TS_ITR1 TIM_SMCR_TS_0 /*!< Internal Trigger 1 (ITR1) is used as trigger input */
  621. #define LL_TIM_TS_ITR2 TIM_SMCR_TS_1 /*!< Internal Trigger 2 (ITR2) is used as trigger input */
  622. #define LL_TIM_TS_ITR3 (TIM_SMCR_TS_0 | TIM_SMCR_TS_1) /*!< Internal Trigger 3 (ITR3) is used as trigger input */
  623. #define LL_TIM_TS_TI1F_ED TIM_SMCR_TS_2 /*!< TI1 Edge Detector (TI1F_ED) is used as trigger input */
  624. #define LL_TIM_TS_TI1FP1 (TIM_SMCR_TS_2 | TIM_SMCR_TS_0) /*!< Filtered Timer Input 1 (TI1FP1) is used as trigger input */
  625. #define LL_TIM_TS_TI2FP2 (TIM_SMCR_TS_2 | TIM_SMCR_TS_1) /*!< Filtered Timer Input 2 (TI12P2) is used as trigger input */
  626. #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 */
  627. /**
  628. * @}
  629. */
  630. /** @defgroup TIM_LL_EC_ETR_POLARITY External Trigger Polarity
  631. * @{
  632. */
  633. #define LL_TIM_ETR_POLARITY_NONINVERTED 0x00000000U /*!< ETR is non-inverted, active at high level or rising edge */
  634. #define LL_TIM_ETR_POLARITY_INVERTED TIM_SMCR_ETP /*!< ETR is inverted, active at low level or falling edge */
  635. /**
  636. * @}
  637. */
  638. /** @defgroup TIM_LL_EC_ETR_PRESCALER External Trigger Prescaler
  639. * @{
  640. */
  641. #define LL_TIM_ETR_PRESCALER_DIV1 0x00000000U /*!< ETR prescaler OFF */
  642. #define LL_TIM_ETR_PRESCALER_DIV2 TIM_SMCR_ETPS_0 /*!< ETR frequency is divided by 2 */
  643. #define LL_TIM_ETR_PRESCALER_DIV4 TIM_SMCR_ETPS_1 /*!< ETR frequency is divided by 4 */
  644. #define LL_TIM_ETR_PRESCALER_DIV8 TIM_SMCR_ETPS /*!< ETR frequency is divided by 8 */
  645. /**
  646. * @}
  647. */
  648. /** @defgroup TIM_LL_EC_ETR_FILTER External Trigger Filter
  649. * @{
  650. */
  651. #define LL_TIM_ETR_FILTER_FDIV1 0x00000000U /*!< No filter, sampling is done at fDTS */
  652. #define LL_TIM_ETR_FILTER_FDIV1_N2 TIM_SMCR_ETF_0 /*!< fSAMPLING=fCK_INT, N=2 */
  653. #define LL_TIM_ETR_FILTER_FDIV1_N4 TIM_SMCR_ETF_1 /*!< fSAMPLING=fCK_INT, N=4 */
  654. #define LL_TIM_ETR_FILTER_FDIV1_N8 (TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fCK_INT, N=8 */
  655. #define LL_TIM_ETR_FILTER_FDIV2_N6 TIM_SMCR_ETF_2 /*!< fSAMPLING=fDTS/2, N=6 */
  656. #define LL_TIM_ETR_FILTER_FDIV2_N8 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/2, N=8 */
  657. #define LL_TIM_ETR_FILTER_FDIV4_N6 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/4, N=6 */
  658. #define LL_TIM_ETR_FILTER_FDIV4_N8 (TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/4, N=8 */
  659. #define LL_TIM_ETR_FILTER_FDIV8_N6 TIM_SMCR_ETF_3 /*!< fSAMPLING=fDTS/8, N=8 */
  660. #define LL_TIM_ETR_FILTER_FDIV8_N8 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/16, N=5 */
  661. #define LL_TIM_ETR_FILTER_FDIV16_N5 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/16, N=6 */
  662. #define LL_TIM_ETR_FILTER_FDIV16_N6 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_1 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/16, N=8 */
  663. #define LL_TIM_ETR_FILTER_FDIV16_N8 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2) /*!< fSAMPLING=fDTS/16, N=5 */
  664. #define LL_TIM_ETR_FILTER_FDIV32_N5 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2 | TIM_SMCR_ETF_0) /*!< fSAMPLING=fDTS/32, N=5 */
  665. #define LL_TIM_ETR_FILTER_FDIV32_N6 (TIM_SMCR_ETF_3 | TIM_SMCR_ETF_2 | TIM_SMCR_ETF_1) /*!< fSAMPLING=fDTS/32, N=6 */
  666. #define LL_TIM_ETR_FILTER_FDIV32_N8 TIM_SMCR_ETF /*!< fSAMPLING=fDTS/32, N=8 */
  667. /**
  668. * @}
  669. */
  670. /** @defgroup TIM_LL_EC_BREAK_POLARITY break polarity
  671. * @{
  672. */
  673. #define LL_TIM_BREAK_POLARITY_LOW 0x00000000U /*!< Break input BRK is active low */
  674. #define LL_TIM_BREAK_POLARITY_HIGH TIM_BDTR_BKP /*!< Break input BRK is active high */
  675. /**
  676. * @}
  677. */
  678. /** @defgroup TIM_LL_EC_OSSI OSSI
  679. * @{
  680. */
  681. #define LL_TIM_OSSI_DISABLE 0x00000000U /*!< When inactive, OCx/OCxN outputs are disabled */
  682. #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 */
  683. /**
  684. * @}
  685. */
  686. /** @defgroup TIM_LL_EC_OSSR OSSR
  687. * @{
  688. */
  689. #define LL_TIM_OSSR_DISABLE 0x00000000U /*!< When inactive, OCx/OCxN outputs are disabled */
  690. #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 */
  691. /**
  692. * @}
  693. */
  694. /** @defgroup TIM_LL_EC_DMABURST_BASEADDR DMA Burst Base Address
  695. * @{
  696. */
  697. #define LL_TIM_DMABURST_BASEADDR_CR1 0x00000000U /*!< TIMx_CR1 register is the DMA base address for DMA burst */
  698. #define LL_TIM_DMABURST_BASEADDR_CR2 TIM_DCR_DBA_0 /*!< TIMx_CR2 register is the DMA base address for DMA burst */
  699. #define LL_TIM_DMABURST_BASEADDR_SMCR TIM_DCR_DBA_1 /*!< TIMx_SMCR register is the DMA base address for DMA burst */
  700. #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 */
  701. #define LL_TIM_DMABURST_BASEADDR_SR TIM_DCR_DBA_2 /*!< TIMx_SR register is the DMA base address for DMA burst */
  702. #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 */
  703. #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 */
  704. #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 */
  705. #define LL_TIM_DMABURST_BASEADDR_CCER TIM_DCR_DBA_3 /*!< TIMx_CCER register is the DMA base address for DMA burst */
  706. #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 */
  707. #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 */
  708. #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 */
  709. #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 */
  710. #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 */
  711. #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 */
  712. #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 */
  713. #define LL_TIM_DMABURST_BASEADDR_CCR4 TIM_DCR_DBA_4 /*!< TIMx_CCR4 register is the DMA base address for DMA burst */
  714. #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 */
  715. #define LL_TIM_DMABURST_BASEADDR_OR (TIM_DCR_DBA_4 | TIM_DCR_DBA_2 | TIM_DCR_DBA_0)
  716. /**
  717. * @}
  718. */
  719. /** @defgroup TIM_LL_EC_DMABURST_LENGTH DMA Burst Length
  720. * @{
  721. */
  722. #define LL_TIM_DMABURST_LENGTH_1TRANSFER 0x00000000U /*!< Transfer is done to 1 register starting from the DMA burst base address */
  723. #define LL_TIM_DMABURST_LENGTH_2TRANSFERS TIM_DCR_DBL_0 /*!< Transfer is done to 2 registers starting from the DMA burst base address */
  724. #define LL_TIM_DMABURST_LENGTH_3TRANSFERS TIM_DCR_DBL_1 /*!< Transfer is done to 3 registers starting from the DMA burst base address */
  725. #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 */
  726. #define LL_TIM_DMABURST_LENGTH_5TRANSFERS TIM_DCR_DBL_2 /*!< Transfer is done to 5 registers starting from the DMA burst base address */
  727. #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 */
  728. #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 */
  729. #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 */
  730. #define LL_TIM_DMABURST_LENGTH_9TRANSFERS TIM_DCR_DBL_3 /*!< Transfer is done to 9 registers starting from the DMA burst base address */
  731. #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 */
  732. #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 */
  733. #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 */
  734. #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 */
  735. #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 */
  736. #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 */
  737. #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 */
  738. #define LL_TIM_DMABURST_LENGTH_17TRANSFERS TIM_DCR_DBL_4 /*!< Transfer is done to 17 registers starting from the DMA burst base address */
  739. #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 */
  740. /**
  741. * @}
  742. */
  743. /** @defgroup TIM_LL_EC_TIM2_ITR1_RMP_TIM8 TIM2 Internal Trigger1 Remap TIM8
  744. * @{
  745. */
  746. #define LL_TIM_TIM2_ITR1_RMP_TIM8_TRGO TIM2_OR_RMP_MASK /*!< TIM2_ITR1 is connected to TIM8_TRGO */
  747. #define LL_TIM_TIM2_ITR1_RMP_OTG_FS_SOF (TIM_OR_ITR1_RMP_1 | TIM2_OR_RMP_MASK) /*!< TIM2_ITR1 is connected to OTG_FS SOF */
  748. #define LL_TIM_TIM2_ITR1_RMP_OTG_HS_SOF (TIM_OR_ITR1_RMP | TIM2_OR_RMP_MASK) /*!< TIM2_ITR1 is connected to OTG_HS SOF */
  749. /**
  750. * @}
  751. */
  752. /** @defgroup TIM_LL_EC_TIM5_TI4_RMP TIM5 External Input Ch4 Remap
  753. * @{
  754. */
  755. #define LL_TIM_TIM5_TI4_RMP_GPIO TIM5_OR_RMP_MASK /*!< TIM5 channel 4 is connected to GPIO */
  756. #define LL_TIM_TIM5_TI4_RMP_LSI (TIM_OR_TI4_RMP_0 | TIM5_OR_RMP_MASK) /*!< TIM5 channel 4 is connected to LSI internal clock */
  757. #define LL_TIM_TIM5_TI4_RMP_LSE (TIM_OR_TI4_RMP_1 | TIM5_OR_RMP_MASK) /*!< TIM5 channel 4 is connected to LSE */
  758. #define LL_TIM_TIM5_TI4_RMP_RTC (TIM_OR_TI4_RMP | TIM5_OR_RMP_MASK) /*!< TIM5 channel 4 is connected to RTC wakeup interrupt */
  759. /**
  760. * @}
  761. */
  762. /** @defgroup TIM_LL_EC_TIM11_TI1_RMP TIM11 External Input Capture 1 Remap
  763. * @{
  764. */
  765. #define LL_TIM_TIM11_TI1_RMP_GPIO TIM11_OR_RMP_MASK /*!< TIM11 channel 1 is connected to GPIO */
  766. #define LL_TIM_TIM11_TI1_RMP_GPIO1 (TIM_OR_TI1_RMP_0 | TIM11_OR_RMP_MASK) /*!< TIM11 channel 1 is connected to GPIO */
  767. #define LL_TIM_TIM11_TI1_RMP_GPIO2 (TIM_OR_TI1_RMP | TIM11_OR_RMP_MASK) /*!< TIM11 channel 1 is connected to GPIO */
  768. #define LL_TIM_TIM11_TI1_RMP_HSE_RTC (TIM_OR_TI1_RMP_1 | TIM11_OR_RMP_MASK) /*!< TIM11 channel 1 is connected to HSE_RTC */
  769. /**
  770. * @}
  771. */
  772. /**
  773. * @}
  774. */
  775. /* Exported macro ------------------------------------------------------------*/
  776. /** @defgroup TIM_LL_Exported_Macros TIM Exported Macros
  777. * @{
  778. */
  779. /** @defgroup TIM_LL_EM_WRITE_READ Common Write and read registers Macros
  780. * @{
  781. */
  782. /**
  783. * @brief Write a value in TIM register.
  784. * @param __INSTANCE__ TIM Instance
  785. * @param __REG__ Register to be written
  786. * @param __VALUE__ Value to be written in the register
  787. * @retval None
  788. */
  789. #define LL_TIM_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  790. /**
  791. * @brief Read a value in TIM register.
  792. * @param __INSTANCE__ TIM Instance
  793. * @param __REG__ Register to be read
  794. * @retval Register value
  795. */
  796. #define LL_TIM_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  797. /**
  798. * @}
  799. */
  800. /** @defgroup TIM_LL_EM_Exported_Macros Exported_Macros
  801. * @{
  802. */
  803. /**
  804. * @brief HELPER macro calculating DTG[0:7] in the TIMx_BDTR register to achieve the requested dead time duration.
  805. * @note ex: @ref __LL_TIM_CALC_DEADTIME (80000000, @ref LL_TIM_GetClockDivision (), 120);
  806. * @param __TIMCLK__ timer input clock frequency (in Hz)
  807. * @param __CKD__ This parameter can be one of the following values:
  808. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  809. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  810. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  811. * @param __DT__ deadtime duration (in ns)
  812. * @retval DTG[0:7]
  813. */
  814. #define __LL_TIM_CALC_DEADTIME(__TIMCLK__, __CKD__, __DT__) \
  815. ( (((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) : \
  816. (((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) 64U) & DT_DELAY_2)) :\
  817. (((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) 32U) & DT_DELAY_3)) :\
  818. (((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) 32U) & DT_DELAY_4)) :\
  819. 0U)
  820. /**
  821. * @brief HELPER macro calculating the prescaler value to achieve the required counter clock frequency.
  822. * @note ex: @ref __LL_TIM_CALC_PSC (80000000, 1000000);
  823. * @param __TIMCLK__ timer input clock frequency (in Hz)
  824. * @param __CNTCLK__ counter clock frequency (in Hz)
  825. * @retval Prescaler value (between Min_Data=0 and Max_Data=65535)
  826. */
  827. #define __LL_TIM_CALC_PSC(__TIMCLK__, __CNTCLK__) \
  828. ((__TIMCLK__) >= (__CNTCLK__)) ? (uint32_t)((__TIMCLK__)/(__CNTCLK__) - 1U) : 0U
  829. /**
  830. * @brief HELPER macro calculating the auto-reload value to achieve the required output signal frequency.
  831. * @note ex: @ref __LL_TIM_CALC_ARR (1000000, @ref LL_TIM_GetPrescaler (), 10000);
  832. * @param __TIMCLK__ timer input clock frequency (in Hz)
  833. * @param __PSC__ prescaler
  834. * @param __FREQ__ output signal frequency (in Hz)
  835. * @retval Auto-reload value (between Min_Data=0 and Max_Data=65535)
  836. */
  837. #define __LL_TIM_CALC_ARR(__TIMCLK__, __PSC__, __FREQ__) \
  838. (((__TIMCLK__)/((__PSC__) + 1U)) >= (__FREQ__)) ? ((__TIMCLK__)/((__FREQ__) * ((__PSC__) + 1U)) - 1U) : 0U
  839. /**
  840. * @brief HELPER macro calculating the compare value required to achieve the required timer output compare active/inactive delay.
  841. * @note ex: @ref __LL_TIM_CALC_DELAY (1000000, @ref LL_TIM_GetPrescaler (), 10);
  842. * @param __TIMCLK__ timer input clock frequency (in Hz)
  843. * @param __PSC__ prescaler
  844. * @param __DELAY__ timer output compare active/inactive delay (in us)
  845. * @retval Compare value (between Min_Data=0 and Max_Data=65535)
  846. */
  847. #define __LL_TIM_CALC_DELAY(__TIMCLK__, __PSC__, __DELAY__) \
  848. ((uint32_t)(((uint64_t)(__TIMCLK__) * (uint64_t)(__DELAY__)) \
  849. / ((uint64_t)1000000U * (uint64_t)((__PSC__) + 1U))))
  850. /**
  851. * @brief HELPER macro calculating the auto-reload value to achieve the required pulse duration (when the timer operates in one pulse mode).
  852. * @note ex: @ref __LL_TIM_CALC_PULSE (1000000, @ref LL_TIM_GetPrescaler (), 10, 20);
  853. * @param __TIMCLK__ timer input clock frequency (in Hz)
  854. * @param __PSC__ prescaler
  855. * @param __DELAY__ timer output compare active/inactive delay (in us)
  856. * @param __PULSE__ pulse duration (in us)
  857. * @retval Auto-reload value (between Min_Data=0 and Max_Data=65535)
  858. */
  859. #define __LL_TIM_CALC_PULSE(__TIMCLK__, __PSC__, __DELAY__, __PULSE__) \
  860. ((uint32_t)(__LL_TIM_CALC_DELAY((__TIMCLK__), (__PSC__), (__PULSE__)) \
  861. + __LL_TIM_CALC_DELAY((__TIMCLK__), (__PSC__), (__DELAY__))))
  862. /**
  863. * @brief HELPER macro retrieving the ratio of the input capture prescaler
  864. * @note ex: @ref __LL_TIM_GET_ICPSC_RATIO (@ref LL_TIM_IC_GetPrescaler ());
  865. * @param __ICPSC__ This parameter can be one of the following values:
  866. * @arg @ref LL_TIM_ICPSC_DIV1
  867. * @arg @ref LL_TIM_ICPSC_DIV2
  868. * @arg @ref LL_TIM_ICPSC_DIV4
  869. * @arg @ref LL_TIM_ICPSC_DIV8
  870. * @retval Input capture prescaler ratio (1, 2, 4 or 8)
  871. */
  872. #define __LL_TIM_GET_ICPSC_RATIO(__ICPSC__) \
  873. ((uint32_t)(0x01U << (((__ICPSC__) >> 16U) >> TIM_CCMR1_IC1PSC_Pos)))
  874. /**
  875. * @}
  876. */
  877. /**
  878. * @}
  879. */
  880. /* Exported functions --------------------------------------------------------*/
  881. /** @defgroup TIM_LL_Exported_Functions TIM Exported Functions
  882. * @{
  883. */
  884. /** @defgroup TIM_LL_EF_Time_Base Time Base configuration
  885. * @{
  886. */
  887. /**
  888. * @brief Enable timer counter.
  889. * @rmtoll CR1 CEN LL_TIM_EnableCounter
  890. * @param TIMx Timer instance
  891. * @retval None
  892. */
  893. __STATIC_INLINE void LL_TIM_EnableCounter(TIM_TypeDef *TIMx)
  894. {
  895. SET_BIT(TIMx->CR1, TIM_CR1_CEN);
  896. }
  897. /**
  898. * @brief Disable timer counter.
  899. * @rmtoll CR1 CEN LL_TIM_DisableCounter
  900. * @param TIMx Timer instance
  901. * @retval None
  902. */
  903. __STATIC_INLINE void LL_TIM_DisableCounter(TIM_TypeDef *TIMx)
  904. {
  905. CLEAR_BIT(TIMx->CR1, TIM_CR1_CEN);
  906. }
  907. /**
  908. * @brief Indicates whether the timer counter is enabled.
  909. * @rmtoll CR1 CEN LL_TIM_IsEnabledCounter
  910. * @param TIMx Timer instance
  911. * @retval State of bit (1 or 0).
  912. */
  913. __STATIC_INLINE uint32_t LL_TIM_IsEnabledCounter(TIM_TypeDef *TIMx)
  914. {
  915. return (READ_BIT(TIMx->CR1, TIM_CR1_CEN) == (TIM_CR1_CEN));
  916. }
  917. /**
  918. * @brief Enable update event generation.
  919. * @rmtoll CR1 UDIS LL_TIM_EnableUpdateEvent
  920. * @param TIMx Timer instance
  921. * @retval None
  922. */
  923. __STATIC_INLINE void LL_TIM_EnableUpdateEvent(TIM_TypeDef *TIMx)
  924. {
  925. SET_BIT(TIMx->CR1, TIM_CR1_UDIS);
  926. }
  927. /**
  928. * @brief Disable update event generation.
  929. * @rmtoll CR1 UDIS LL_TIM_DisableUpdateEvent
  930. * @param TIMx Timer instance
  931. * @retval None
  932. */
  933. __STATIC_INLINE void LL_TIM_DisableUpdateEvent(TIM_TypeDef *TIMx)
  934. {
  935. CLEAR_BIT(TIMx->CR1, TIM_CR1_UDIS);
  936. }
  937. /**
  938. * @brief Indicates whether update event generation is enabled.
  939. * @rmtoll CR1 UDIS LL_TIM_IsEnabledUpdateEvent
  940. * @param TIMx Timer instance
  941. * @retval State of bit (1 or 0).
  942. */
  943. __STATIC_INLINE uint32_t LL_TIM_IsEnabledUpdateEvent(TIM_TypeDef *TIMx)
  944. {
  945. return (READ_BIT(TIMx->CR1, TIM_CR1_UDIS) == (TIM_CR1_UDIS));
  946. }
  947. /**
  948. * @brief Set update event source
  949. * @note Update event source set to LL_TIM_UPDATESOURCE_REGULAR: any of the following events
  950. * generate an update interrupt or DMA request if enabled:
  951. * - Counter overflow/underflow
  952. * - Setting the UG bit
  953. * - Update generation through the slave mode controller
  954. * @note Update event source set to LL_TIM_UPDATESOURCE_COUNTER: only counter
  955. * overflow/underflow generates an update interrupt or DMA request if enabled.
  956. * @rmtoll CR1 URS LL_TIM_SetUpdateSource
  957. * @param TIMx Timer instance
  958. * @param UpdateSource This parameter can be one of the following values:
  959. * @arg @ref LL_TIM_UPDATESOURCE_REGULAR
  960. * @arg @ref LL_TIM_UPDATESOURCE_COUNTER
  961. * @retval None
  962. */
  963. __STATIC_INLINE void LL_TIM_SetUpdateSource(TIM_TypeDef *TIMx, uint32_t UpdateSource)
  964. {
  965. MODIFY_REG(TIMx->CR1, TIM_CR1_URS, UpdateSource);
  966. }
  967. /**
  968. * @brief Get actual event update source
  969. * @rmtoll CR1 URS LL_TIM_GetUpdateSource
  970. * @param TIMx Timer instance
  971. * @retval Returned value can be one of the following values:
  972. * @arg @ref LL_TIM_UPDATESOURCE_REGULAR
  973. * @arg @ref LL_TIM_UPDATESOURCE_COUNTER
  974. */
  975. __STATIC_INLINE uint32_t LL_TIM_GetUpdateSource(TIM_TypeDef *TIMx)
  976. {
  977. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_URS));
  978. }
  979. /**
  980. * @brief Set one pulse mode (one shot v.s. repetitive).
  981. * @rmtoll CR1 OPM LL_TIM_SetOnePulseMode
  982. * @param TIMx Timer instance
  983. * @param OnePulseMode This parameter can be one of the following values:
  984. * @arg @ref LL_TIM_ONEPULSEMODE_SINGLE
  985. * @arg @ref LL_TIM_ONEPULSEMODE_REPETITIVE
  986. * @retval None
  987. */
  988. __STATIC_INLINE void LL_TIM_SetOnePulseMode(TIM_TypeDef *TIMx, uint32_t OnePulseMode)
  989. {
  990. MODIFY_REG(TIMx->CR1, TIM_CR1_OPM, OnePulseMode);
  991. }
  992. /**
  993. * @brief Get actual one pulse mode.
  994. * @rmtoll CR1 OPM LL_TIM_GetOnePulseMode
  995. * @param TIMx Timer instance
  996. * @retval Returned value can be one of the following values:
  997. * @arg @ref LL_TIM_ONEPULSEMODE_SINGLE
  998. * @arg @ref LL_TIM_ONEPULSEMODE_REPETITIVE
  999. */
  1000. __STATIC_INLINE uint32_t LL_TIM_GetOnePulseMode(TIM_TypeDef *TIMx)
  1001. {
  1002. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_OPM));
  1003. }
  1004. /**
  1005. * @brief Set the timer counter counting mode.
  1006. * @note Macro @ref IS_TIM_COUNTER_MODE_SELECT_INSTANCE(TIMx) can be used to
  1007. * check whether or not the counter mode selection feature is supported
  1008. * by a timer instance.
  1009. * @rmtoll CR1 DIR LL_TIM_SetCounterMode\n
  1010. * CR1 CMS LL_TIM_SetCounterMode
  1011. * @param TIMx Timer instance
  1012. * @param CounterMode This parameter can be one of the following values:
  1013. * @arg @ref LL_TIM_COUNTERMODE_UP
  1014. * @arg @ref LL_TIM_COUNTERMODE_DOWN
  1015. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP
  1016. * @arg @ref LL_TIM_COUNTERMODE_CENTER_DOWN
  1017. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP_DOWN
  1018. * @retval None
  1019. */
  1020. __STATIC_INLINE void LL_TIM_SetCounterMode(TIM_TypeDef *TIMx, uint32_t CounterMode)
  1021. {
  1022. MODIFY_REG(TIMx->CR1, TIM_CR1_DIR | TIM_CR1_CMS, CounterMode);
  1023. }
  1024. /**
  1025. * @brief Get actual counter mode.
  1026. * @note Macro @ref IS_TIM_COUNTER_MODE_SELECT_INSTANCE(TIMx) can be used to
  1027. * check whether or not the counter mode selection feature is supported
  1028. * by a timer instance.
  1029. * @rmtoll CR1 DIR LL_TIM_GetCounterMode\n
  1030. * CR1 CMS LL_TIM_GetCounterMode
  1031. * @param TIMx Timer instance
  1032. * @retval Returned value can be one of the following values:
  1033. * @arg @ref LL_TIM_COUNTERMODE_UP
  1034. * @arg @ref LL_TIM_COUNTERMODE_DOWN
  1035. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP
  1036. * @arg @ref LL_TIM_COUNTERMODE_CENTER_DOWN
  1037. * @arg @ref LL_TIM_COUNTERMODE_CENTER_UP_DOWN
  1038. */
  1039. __STATIC_INLINE uint32_t LL_TIM_GetCounterMode(TIM_TypeDef *TIMx)
  1040. {
  1041. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_DIR | TIM_CR1_CMS));
  1042. }
  1043. /**
  1044. * @brief Enable auto-reload (ARR) preload.
  1045. * @rmtoll CR1 ARPE LL_TIM_EnableARRPreload
  1046. * @param TIMx Timer instance
  1047. * @retval None
  1048. */
  1049. __STATIC_INLINE void LL_TIM_EnableARRPreload(TIM_TypeDef *TIMx)
  1050. {
  1051. SET_BIT(TIMx->CR1, TIM_CR1_ARPE);
  1052. }
  1053. /**
  1054. * @brief Disable auto-reload (ARR) preload.
  1055. * @rmtoll CR1 ARPE LL_TIM_DisableARRPreload
  1056. * @param TIMx Timer instance
  1057. * @retval None
  1058. */
  1059. __STATIC_INLINE void LL_TIM_DisableARRPreload(TIM_TypeDef *TIMx)
  1060. {
  1061. CLEAR_BIT(TIMx->CR1, TIM_CR1_ARPE);
  1062. }
  1063. /**
  1064. * @brief Indicates whether auto-reload (ARR) preload is enabled.
  1065. * @rmtoll CR1 ARPE LL_TIM_IsEnabledARRPreload
  1066. * @param TIMx Timer instance
  1067. * @retval State of bit (1 or 0).
  1068. */
  1069. __STATIC_INLINE uint32_t LL_TIM_IsEnabledARRPreload(TIM_TypeDef *TIMx)
  1070. {
  1071. return (READ_BIT(TIMx->CR1, TIM_CR1_ARPE) == (TIM_CR1_ARPE));
  1072. }
  1073. /**
  1074. * @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.
  1075. * @note Macro @ref IS_TIM_CLOCK_DIVISION_INSTANCE(TIMx) can be used to check
  1076. * whether or not the clock division feature is supported by the timer
  1077. * instance.
  1078. * @rmtoll CR1 CKD LL_TIM_SetClockDivision
  1079. * @param TIMx Timer instance
  1080. * @param ClockDivision This parameter can be one of the following values:
  1081. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  1082. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  1083. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  1084. * @retval None
  1085. */
  1086. __STATIC_INLINE void LL_TIM_SetClockDivision(TIM_TypeDef *TIMx, uint32_t ClockDivision)
  1087. {
  1088. MODIFY_REG(TIMx->CR1, TIM_CR1_CKD, ClockDivision);
  1089. }
  1090. /**
  1091. * @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.
  1092. * @note Macro @ref IS_TIM_CLOCK_DIVISION_INSTANCE(TIMx) can be used to check
  1093. * whether or not the clock division feature is supported by the timer
  1094. * instance.
  1095. * @rmtoll CR1 CKD LL_TIM_GetClockDivision
  1096. * @param TIMx Timer instance
  1097. * @retval Returned value can be one of the following values:
  1098. * @arg @ref LL_TIM_CLOCKDIVISION_DIV1
  1099. * @arg @ref LL_TIM_CLOCKDIVISION_DIV2
  1100. * @arg @ref LL_TIM_CLOCKDIVISION_DIV4
  1101. */
  1102. __STATIC_INLINE uint32_t LL_TIM_GetClockDivision(TIM_TypeDef *TIMx)
  1103. {
  1104. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_CKD));
  1105. }
  1106. /**
  1107. * @brief Set the counter value.
  1108. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1109. * whether or not a timer instance supports a 32 bits counter.
  1110. * @rmtoll CNT CNT LL_TIM_SetCounter
  1111. * @param TIMx Timer instance
  1112. * @param Counter Counter value (between Min_Data=0 and Max_Data=0xFFFF or 0xFFFFFFFF)
  1113. * @retval None
  1114. */
  1115. __STATIC_INLINE void LL_TIM_SetCounter(TIM_TypeDef *TIMx, uint32_t Counter)
  1116. {
  1117. WRITE_REG(TIMx->CNT, Counter);
  1118. }
  1119. /**
  1120. * @brief Get the counter value.
  1121. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1122. * whether or not a timer instance supports a 32 bits counter.
  1123. * @rmtoll CNT CNT LL_TIM_GetCounter
  1124. * @param TIMx Timer instance
  1125. * @retval Counter value (between Min_Data=0 and Max_Data=0xFFFF or 0xFFFFFFFF)
  1126. */
  1127. __STATIC_INLINE uint32_t LL_TIM_GetCounter(TIM_TypeDef *TIMx)
  1128. {
  1129. return (uint32_t)(READ_REG(TIMx->CNT));
  1130. }
  1131. /**
  1132. * @brief Get the current direction of the counter
  1133. * @rmtoll CR1 DIR LL_TIM_GetDirection
  1134. * @param TIMx Timer instance
  1135. * @retval Returned value can be one of the following values:
  1136. * @arg @ref LL_TIM_COUNTERDIRECTION_UP
  1137. * @arg @ref LL_TIM_COUNTERDIRECTION_DOWN
  1138. */
  1139. __STATIC_INLINE uint32_t LL_TIM_GetDirection(TIM_TypeDef *TIMx)
  1140. {
  1141. return (uint32_t)(READ_BIT(TIMx->CR1, TIM_CR1_DIR));
  1142. }
  1143. /**
  1144. * @brief Set the prescaler value.
  1145. * @note The counter clock frequency CK_CNT is equal to fCK_PSC / (PSC[15:0] + 1).
  1146. * @note The prescaler can be changed on the fly as this control register is buffered. The new
  1147. * prescaler ratio is taken into account at the next update event.
  1148. * @note Helper macro @ref __LL_TIM_CALC_PSC can be used to calculate the Prescaler parameter
  1149. * @rmtoll PSC PSC LL_TIM_SetPrescaler
  1150. * @param TIMx Timer instance
  1151. * @param Prescaler between Min_Data=0 and Max_Data=65535
  1152. * @retval None
  1153. */
  1154. __STATIC_INLINE void LL_TIM_SetPrescaler(TIM_TypeDef *TIMx, uint32_t Prescaler)
  1155. {
  1156. WRITE_REG(TIMx->PSC, Prescaler);
  1157. }
  1158. /**
  1159. * @brief Get the prescaler value.
  1160. * @rmtoll PSC PSC LL_TIM_GetPrescaler
  1161. * @param TIMx Timer instance
  1162. * @retval Prescaler value between Min_Data=0 and Max_Data=65535
  1163. */
  1164. __STATIC_INLINE uint32_t LL_TIM_GetPrescaler(TIM_TypeDef *TIMx)
  1165. {
  1166. return (uint32_t)(READ_REG(TIMx->PSC));
  1167. }
  1168. /**
  1169. * @brief Set the auto-reload value.
  1170. * @note The counter is blocked while the auto-reload value is null.
  1171. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1172. * whether or not a timer instance supports a 32 bits counter.
  1173. * @note Helper macro @ref __LL_TIM_CALC_ARR can be used to calculate the AutoReload parameter
  1174. * @rmtoll ARR ARR LL_TIM_SetAutoReload
  1175. * @param TIMx Timer instance
  1176. * @param AutoReload between Min_Data=0 and Max_Data=65535
  1177. * @retval None
  1178. */
  1179. __STATIC_INLINE void LL_TIM_SetAutoReload(TIM_TypeDef *TIMx, uint32_t AutoReload)
  1180. {
  1181. WRITE_REG(TIMx->ARR, AutoReload);
  1182. }
  1183. /**
  1184. * @brief Get the auto-reload value.
  1185. * @rmtoll ARR ARR LL_TIM_GetAutoReload
  1186. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1187. * whether or not a timer instance supports a 32 bits counter.
  1188. * @param TIMx Timer instance
  1189. * @retval Auto-reload value
  1190. */
  1191. __STATIC_INLINE uint32_t LL_TIM_GetAutoReload(TIM_TypeDef *TIMx)
  1192. {
  1193. return (uint32_t)(READ_REG(TIMx->ARR));
  1194. }
  1195. /**
  1196. * @brief Set the repetition counter value.
  1197. * @note Macro @ref IS_TIM_REPETITION_COUNTER_INSTANCE(TIMx) can be used to check
  1198. * whether or not a timer instance supports a repetition counter.
  1199. * @rmtoll RCR REP LL_TIM_SetRepetitionCounter
  1200. * @param TIMx Timer instance
  1201. * @param RepetitionCounter between Min_Data=0 and Max_Data=255
  1202. * @retval None
  1203. */
  1204. __STATIC_INLINE void LL_TIM_SetRepetitionCounter(TIM_TypeDef *TIMx, uint32_t RepetitionCounter)
  1205. {
  1206. WRITE_REG(TIMx->RCR, RepetitionCounter);
  1207. }
  1208. /**
  1209. * @brief Get the repetition counter value.
  1210. * @note Macro @ref IS_TIM_REPETITION_COUNTER_INSTANCE(TIMx) can be used to check
  1211. * whether or not a timer instance supports a repetition counter.
  1212. * @rmtoll RCR REP LL_TIM_GetRepetitionCounter
  1213. * @param TIMx Timer instance
  1214. * @retval Repetition counter value
  1215. */
  1216. __STATIC_INLINE uint32_t LL_TIM_GetRepetitionCounter(TIM_TypeDef *TIMx)
  1217. {
  1218. return (uint32_t)(READ_REG(TIMx->RCR));
  1219. }
  1220. /**
  1221. * @}
  1222. */
  1223. /** @defgroup TIM_LL_EF_Capture_Compare Capture Compare configuration
  1224. * @{
  1225. */
  1226. /**
  1227. * @brief Enable the capture/compare control bits (CCxE, CCxNE and OCxM) preload.
  1228. * @note CCxE, CCxNE and OCxM bits are preloaded, after having been written,
  1229. * they are updated only when a commutation event (COM) occurs.
  1230. * @note Only on channels that have a complementary output.
  1231. * @note Macro @ref IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
  1232. * whether or not a timer instance is able to generate a commutation event.
  1233. * @rmtoll CR2 CCPC LL_TIM_CC_EnablePreload
  1234. * @param TIMx Timer instance
  1235. * @retval None
  1236. */
  1237. __STATIC_INLINE void LL_TIM_CC_EnablePreload(TIM_TypeDef *TIMx)
  1238. {
  1239. SET_BIT(TIMx->CR2, TIM_CR2_CCPC);
  1240. }
  1241. /**
  1242. * @brief Disable the capture/compare control bits (CCxE, CCxNE and OCxM) preload.
  1243. * @note Macro @ref IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
  1244. * whether or not a timer instance is able to generate a commutation event.
  1245. * @rmtoll CR2 CCPC LL_TIM_CC_DisablePreload
  1246. * @param TIMx Timer instance
  1247. * @retval None
  1248. */
  1249. __STATIC_INLINE void LL_TIM_CC_DisablePreload(TIM_TypeDef *TIMx)
  1250. {
  1251. CLEAR_BIT(TIMx->CR2, TIM_CR2_CCPC);
  1252. }
  1253. /**
  1254. * @brief Set the updated source of the capture/compare control bits (CCxE, CCxNE and OCxM).
  1255. * @note Macro @ref IS_TIM_COMMUTATION_EVENT_INSTANCE(TIMx) can be used to check
  1256. * whether or not a timer instance is able to generate a commutation event.
  1257. * @rmtoll CR2 CCUS LL_TIM_CC_SetUpdate
  1258. * @param TIMx Timer instance
  1259. * @param CCUpdateSource This parameter can be one of the following values:
  1260. * @arg @ref LL_TIM_CCUPDATESOURCE_COMG_ONLY
  1261. * @arg @ref LL_TIM_CCUPDATESOURCE_COMG_AND_TRGI
  1262. * @retval None
  1263. */
  1264. __STATIC_INLINE void LL_TIM_CC_SetUpdate(TIM_TypeDef *TIMx, uint32_t CCUpdateSource)
  1265. {
  1266. MODIFY_REG(TIMx->CR2, TIM_CR2_CCUS, CCUpdateSource);
  1267. }
  1268. /**
  1269. * @brief Set the trigger of the capture/compare DMA request.
  1270. * @rmtoll CR2 CCDS LL_TIM_CC_SetDMAReqTrigger
  1271. * @param TIMx Timer instance
  1272. * @param DMAReqTrigger This parameter can be one of the following values:
  1273. * @arg @ref LL_TIM_CCDMAREQUEST_CC
  1274. * @arg @ref LL_TIM_CCDMAREQUEST_UPDATE
  1275. * @retval None
  1276. */
  1277. __STATIC_INLINE void LL_TIM_CC_SetDMAReqTrigger(TIM_TypeDef *TIMx, uint32_t DMAReqTrigger)
  1278. {
  1279. MODIFY_REG(TIMx->CR2, TIM_CR2_CCDS, DMAReqTrigger);
  1280. }
  1281. /**
  1282. * @brief Get actual trigger of the capture/compare DMA request.
  1283. * @rmtoll CR2 CCDS LL_TIM_CC_GetDMAReqTrigger
  1284. * @param TIMx Timer instance
  1285. * @retval Returned value can be one of the following values:
  1286. * @arg @ref LL_TIM_CCDMAREQUEST_CC
  1287. * @arg @ref LL_TIM_CCDMAREQUEST_UPDATE
  1288. */
  1289. __STATIC_INLINE uint32_t LL_TIM_CC_GetDMAReqTrigger(TIM_TypeDef *TIMx)
  1290. {
  1291. return (uint32_t)(READ_BIT(TIMx->CR2, TIM_CR2_CCDS));
  1292. }
  1293. /**
  1294. * @brief Set the lock level to freeze the
  1295. * configuration of several capture/compare parameters.
  1296. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  1297. * the lock mechanism is supported by a timer instance.
  1298. * @rmtoll BDTR LOCK LL_TIM_CC_SetLockLevel
  1299. * @param TIMx Timer instance
  1300. * @param LockLevel This parameter can be one of the following values:
  1301. * @arg @ref LL_TIM_LOCKLEVEL_OFF
  1302. * @arg @ref LL_TIM_LOCKLEVEL_1
  1303. * @arg @ref LL_TIM_LOCKLEVEL_2
  1304. * @arg @ref LL_TIM_LOCKLEVEL_3
  1305. * @retval None
  1306. */
  1307. __STATIC_INLINE void LL_TIM_CC_SetLockLevel(TIM_TypeDef *TIMx, uint32_t LockLevel)
  1308. {
  1309. MODIFY_REG(TIMx->BDTR, TIM_BDTR_LOCK, LockLevel);
  1310. }
  1311. /**
  1312. * @brief Enable capture/compare channels.
  1313. * @rmtoll CCER CC1E LL_TIM_CC_EnableChannel\n
  1314. * CCER CC1NE LL_TIM_CC_EnableChannel\n
  1315. * CCER CC2E LL_TIM_CC_EnableChannel\n
  1316. * CCER CC2NE LL_TIM_CC_EnableChannel\n
  1317. * CCER CC3E LL_TIM_CC_EnableChannel\n
  1318. * CCER CC3NE LL_TIM_CC_EnableChannel\n
  1319. * CCER CC4E LL_TIM_CC_EnableChannel
  1320. * @param TIMx Timer instance
  1321. * @param Channels This parameter can be a combination of the following values:
  1322. * @arg @ref LL_TIM_CHANNEL_CH1
  1323. * @arg @ref LL_TIM_CHANNEL_CH1N
  1324. * @arg @ref LL_TIM_CHANNEL_CH2
  1325. * @arg @ref LL_TIM_CHANNEL_CH2N
  1326. * @arg @ref LL_TIM_CHANNEL_CH3
  1327. * @arg @ref LL_TIM_CHANNEL_CH3N
  1328. * @arg @ref LL_TIM_CHANNEL_CH4
  1329. * @retval None
  1330. */
  1331. __STATIC_INLINE void LL_TIM_CC_EnableChannel(TIM_TypeDef *TIMx, uint32_t Channels)
  1332. {
  1333. SET_BIT(TIMx->CCER, Channels);
  1334. }
  1335. /**
  1336. * @brief Disable capture/compare channels.
  1337. * @rmtoll CCER CC1E LL_TIM_CC_DisableChannel\n
  1338. * CCER CC1NE LL_TIM_CC_DisableChannel\n
  1339. * CCER CC2E LL_TIM_CC_DisableChannel\n
  1340. * CCER CC2NE LL_TIM_CC_DisableChannel\n
  1341. * CCER CC3E LL_TIM_CC_DisableChannel\n
  1342. * CCER CC3NE LL_TIM_CC_DisableChannel\n
  1343. * CCER CC4E LL_TIM_CC_DisableChannel
  1344. * @param TIMx Timer instance
  1345. * @param Channels This parameter can be a combination of the following values:
  1346. * @arg @ref LL_TIM_CHANNEL_CH1
  1347. * @arg @ref LL_TIM_CHANNEL_CH1N
  1348. * @arg @ref LL_TIM_CHANNEL_CH2
  1349. * @arg @ref LL_TIM_CHANNEL_CH2N
  1350. * @arg @ref LL_TIM_CHANNEL_CH3
  1351. * @arg @ref LL_TIM_CHANNEL_CH3N
  1352. * @arg @ref LL_TIM_CHANNEL_CH4
  1353. * @retval None
  1354. */
  1355. __STATIC_INLINE void LL_TIM_CC_DisableChannel(TIM_TypeDef *TIMx, uint32_t Channels)
  1356. {
  1357. CLEAR_BIT(TIMx->CCER, Channels);
  1358. }
  1359. /**
  1360. * @brief Indicate whether channel(s) is(are) enabled.
  1361. * @rmtoll CCER CC1E LL_TIM_CC_IsEnabledChannel\n
  1362. * CCER CC1NE LL_TIM_CC_IsEnabledChannel\n
  1363. * CCER CC2E LL_TIM_CC_IsEnabledChannel\n
  1364. * CCER CC2NE LL_TIM_CC_IsEnabledChannel\n
  1365. * CCER CC3E LL_TIM_CC_IsEnabledChannel\n
  1366. * CCER CC3NE LL_TIM_CC_IsEnabledChannel\n
  1367. * CCER CC4E LL_TIM_CC_IsEnabledChannel
  1368. * @param TIMx Timer instance
  1369. * @param Channels This parameter can be a combination of the following values:
  1370. * @arg @ref LL_TIM_CHANNEL_CH1
  1371. * @arg @ref LL_TIM_CHANNEL_CH1N
  1372. * @arg @ref LL_TIM_CHANNEL_CH2
  1373. * @arg @ref LL_TIM_CHANNEL_CH2N
  1374. * @arg @ref LL_TIM_CHANNEL_CH3
  1375. * @arg @ref LL_TIM_CHANNEL_CH3N
  1376. * @arg @ref LL_TIM_CHANNEL_CH4
  1377. * @retval State of bit (1 or 0).
  1378. */
  1379. __STATIC_INLINE uint32_t LL_TIM_CC_IsEnabledChannel(TIM_TypeDef *TIMx, uint32_t Channels)
  1380. {
  1381. return (READ_BIT(TIMx->CCER, Channels) == (Channels));
  1382. }
  1383. /**
  1384. * @}
  1385. */
  1386. /** @defgroup TIM_LL_EF_Output_Channel Output channel configuration
  1387. * @{
  1388. */
  1389. /**
  1390. * @brief Configure an output channel.
  1391. * @rmtoll CCMR1 CC1S LL_TIM_OC_ConfigOutput\n
  1392. * CCMR1 CC2S LL_TIM_OC_ConfigOutput\n
  1393. * CCMR2 CC3S LL_TIM_OC_ConfigOutput\n
  1394. * CCMR2 CC4S LL_TIM_OC_ConfigOutput\n
  1395. * CCER CC1P LL_TIM_OC_ConfigOutput\n
  1396. * CCER CC2P LL_TIM_OC_ConfigOutput\n
  1397. * CCER CC3P LL_TIM_OC_ConfigOutput\n
  1398. * CCER CC4P LL_TIM_OC_ConfigOutput\n
  1399. * CR2 OIS1 LL_TIM_OC_ConfigOutput\n
  1400. * CR2 OIS2 LL_TIM_OC_ConfigOutput\n
  1401. * CR2 OIS3 LL_TIM_OC_ConfigOutput\n
  1402. * CR2 OIS4 LL_TIM_OC_ConfigOutput
  1403. * @param TIMx Timer instance
  1404. * @param Channel This parameter can be one of the following values:
  1405. * @arg @ref LL_TIM_CHANNEL_CH1
  1406. * @arg @ref LL_TIM_CHANNEL_CH2
  1407. * @arg @ref LL_TIM_CHANNEL_CH3
  1408. * @arg @ref LL_TIM_CHANNEL_CH4
  1409. * @param Configuration This parameter must be a combination of all the following values:
  1410. * @arg @ref LL_TIM_OCPOLARITY_HIGH or @ref LL_TIM_OCPOLARITY_LOW
  1411. * @arg @ref LL_TIM_OCIDLESTATE_LOW or @ref LL_TIM_OCIDLESTATE_HIGH
  1412. * @retval None
  1413. */
  1414. __STATIC_INLINE void LL_TIM_OC_ConfigOutput(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Configuration)
  1415. {
  1416. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1417. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1418. CLEAR_BIT(*pReg, (TIM_CCMR1_CC1S << SHIFT_TAB_OCxx[iChannel]));
  1419. MODIFY_REG(TIMx->CCER, (TIM_CCER_CC1P << SHIFT_TAB_CCxP[iChannel]),
  1420. (Configuration & TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel]);
  1421. MODIFY_REG(TIMx->CR2, (TIM_CR2_OIS1 << SHIFT_TAB_OISx[iChannel]),
  1422. (Configuration & TIM_CR2_OIS1) << SHIFT_TAB_OISx[iChannel]);
  1423. }
  1424. /**
  1425. * @brief Define the behavior of the output reference signal OCxREF from which
  1426. * OCx and OCxN (when relevant) are derived.
  1427. * @rmtoll CCMR1 OC1M LL_TIM_OC_SetMode\n
  1428. * CCMR1 OC2M LL_TIM_OC_SetMode\n
  1429. * CCMR2 OC3M LL_TIM_OC_SetMode\n
  1430. * CCMR2 OC4M LL_TIM_OC_SetMode
  1431. * @param TIMx Timer instance
  1432. * @param Channel This parameter can be one of the following values:
  1433. * @arg @ref LL_TIM_CHANNEL_CH1
  1434. * @arg @ref LL_TIM_CHANNEL_CH2
  1435. * @arg @ref LL_TIM_CHANNEL_CH3
  1436. * @arg @ref LL_TIM_CHANNEL_CH4
  1437. * @param Mode This parameter can be one of the following values:
  1438. * @arg @ref LL_TIM_OCMODE_FROZEN
  1439. * @arg @ref LL_TIM_OCMODE_ACTIVE
  1440. * @arg @ref LL_TIM_OCMODE_INACTIVE
  1441. * @arg @ref LL_TIM_OCMODE_TOGGLE
  1442. * @arg @ref LL_TIM_OCMODE_FORCED_INACTIVE
  1443. * @arg @ref LL_TIM_OCMODE_FORCED_ACTIVE
  1444. * @arg @ref LL_TIM_OCMODE_PWM1
  1445. * @arg @ref LL_TIM_OCMODE_PWM2
  1446. * @retval None
  1447. */
  1448. __STATIC_INLINE void LL_TIM_OC_SetMode(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Mode)
  1449. {
  1450. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1451. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1452. MODIFY_REG(*pReg, ((TIM_CCMR1_OC1M | TIM_CCMR1_CC1S) << SHIFT_TAB_OCxx[iChannel]), Mode << SHIFT_TAB_OCxx[iChannel]);
  1453. }
  1454. /**
  1455. * @brief Get the output compare mode of an output channel.
  1456. * @rmtoll CCMR1 OC1M LL_TIM_OC_GetMode\n
  1457. * CCMR1 OC2M LL_TIM_OC_GetMode\n
  1458. * CCMR2 OC3M LL_TIM_OC_GetMode\n
  1459. * CCMR2 OC4M LL_TIM_OC_GetMode
  1460. * @param TIMx Timer instance
  1461. * @param Channel This parameter can be one of the following values:
  1462. * @arg @ref LL_TIM_CHANNEL_CH1
  1463. * @arg @ref LL_TIM_CHANNEL_CH2
  1464. * @arg @ref LL_TIM_CHANNEL_CH3
  1465. * @arg @ref LL_TIM_CHANNEL_CH4
  1466. * @retval Returned value can be one of the following values:
  1467. * @arg @ref LL_TIM_OCMODE_FROZEN
  1468. * @arg @ref LL_TIM_OCMODE_ACTIVE
  1469. * @arg @ref LL_TIM_OCMODE_INACTIVE
  1470. * @arg @ref LL_TIM_OCMODE_TOGGLE
  1471. * @arg @ref LL_TIM_OCMODE_FORCED_INACTIVE
  1472. * @arg @ref LL_TIM_OCMODE_FORCED_ACTIVE
  1473. * @arg @ref LL_TIM_OCMODE_PWM1
  1474. * @arg @ref LL_TIM_OCMODE_PWM2
  1475. */
  1476. __STATIC_INLINE uint32_t LL_TIM_OC_GetMode(TIM_TypeDef *TIMx, uint32_t Channel)
  1477. {
  1478. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1479. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1480. return (READ_BIT(*pReg, ((TIM_CCMR1_OC1M | TIM_CCMR1_CC1S) << SHIFT_TAB_OCxx[iChannel])) >> SHIFT_TAB_OCxx[iChannel]);
  1481. }
  1482. /**
  1483. * @brief Set the polarity of an output channel.
  1484. * @rmtoll CCER CC1P LL_TIM_OC_SetPolarity\n
  1485. * CCER CC1NP LL_TIM_OC_SetPolarity\n
  1486. * CCER CC2P LL_TIM_OC_SetPolarity\n
  1487. * CCER CC2NP LL_TIM_OC_SetPolarity\n
  1488. * CCER CC3P LL_TIM_OC_SetPolarity\n
  1489. * CCER CC3NP LL_TIM_OC_SetPolarity\n
  1490. * CCER CC4P LL_TIM_OC_SetPolarity
  1491. * @param TIMx Timer instance
  1492. * @param Channel This parameter can be one of the following values:
  1493. * @arg @ref LL_TIM_CHANNEL_CH1
  1494. * @arg @ref LL_TIM_CHANNEL_CH1N
  1495. * @arg @ref LL_TIM_CHANNEL_CH2
  1496. * @arg @ref LL_TIM_CHANNEL_CH2N
  1497. * @arg @ref LL_TIM_CHANNEL_CH3
  1498. * @arg @ref LL_TIM_CHANNEL_CH3N
  1499. * @arg @ref LL_TIM_CHANNEL_CH4
  1500. * @param Polarity This parameter can be one of the following values:
  1501. * @arg @ref LL_TIM_OCPOLARITY_HIGH
  1502. * @arg @ref LL_TIM_OCPOLARITY_LOW
  1503. * @retval None
  1504. */
  1505. __STATIC_INLINE void LL_TIM_OC_SetPolarity(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Polarity)
  1506. {
  1507. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1508. MODIFY_REG(TIMx->CCER, (TIM_CCER_CC1P << SHIFT_TAB_CCxP[iChannel]), Polarity << SHIFT_TAB_CCxP[iChannel]);
  1509. }
  1510. /**
  1511. * @brief Get the polarity of an output channel.
  1512. * @rmtoll CCER CC1P LL_TIM_OC_GetPolarity\n
  1513. * CCER CC1NP LL_TIM_OC_GetPolarity\n
  1514. * CCER CC2P LL_TIM_OC_GetPolarity\n
  1515. * CCER CC2NP LL_TIM_OC_GetPolarity\n
  1516. * CCER CC3P LL_TIM_OC_GetPolarity\n
  1517. * CCER CC3NP LL_TIM_OC_GetPolarity\n
  1518. * CCER CC4P LL_TIM_OC_GetPolarity
  1519. * @param TIMx Timer instance
  1520. * @param Channel This parameter can be one of the following values:
  1521. * @arg @ref LL_TIM_CHANNEL_CH1
  1522. * @arg @ref LL_TIM_CHANNEL_CH1N
  1523. * @arg @ref LL_TIM_CHANNEL_CH2
  1524. * @arg @ref LL_TIM_CHANNEL_CH2N
  1525. * @arg @ref LL_TIM_CHANNEL_CH3
  1526. * @arg @ref LL_TIM_CHANNEL_CH3N
  1527. * @arg @ref LL_TIM_CHANNEL_CH4
  1528. * @retval Returned value can be one of the following values:
  1529. * @arg @ref LL_TIM_OCPOLARITY_HIGH
  1530. * @arg @ref LL_TIM_OCPOLARITY_LOW
  1531. */
  1532. __STATIC_INLINE uint32_t LL_TIM_OC_GetPolarity(TIM_TypeDef *TIMx, uint32_t Channel)
  1533. {
  1534. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1535. return (READ_BIT(TIMx->CCER, (TIM_CCER_CC1P << SHIFT_TAB_CCxP[iChannel])) >> SHIFT_TAB_CCxP[iChannel]);
  1536. }
  1537. /**
  1538. * @brief Set the IDLE state of an output channel
  1539. * @note This function is significant only for the timer instances
  1540. * supporting the break feature. Macro @ref IS_TIM_BREAK_INSTANCE(TIMx)
  1541. * can be used to check whether or not a timer instance provides
  1542. * a break input.
  1543. * @rmtoll CR2 OIS1 LL_TIM_OC_SetIdleState\n
  1544. * CR2 OIS1N LL_TIM_OC_SetIdleState\n
  1545. * CR2 OIS2 LL_TIM_OC_SetIdleState\n
  1546. * CR2 OIS2N LL_TIM_OC_SetIdleState\n
  1547. * CR2 OIS3 LL_TIM_OC_SetIdleState\n
  1548. * CR2 OIS3N LL_TIM_OC_SetIdleState\n
  1549. * CR2 OIS4 LL_TIM_OC_SetIdleState
  1550. * @param TIMx Timer instance
  1551. * @param Channel This parameter can be one of the following values:
  1552. * @arg @ref LL_TIM_CHANNEL_CH1
  1553. * @arg @ref LL_TIM_CHANNEL_CH1N
  1554. * @arg @ref LL_TIM_CHANNEL_CH2
  1555. * @arg @ref LL_TIM_CHANNEL_CH2N
  1556. * @arg @ref LL_TIM_CHANNEL_CH3
  1557. * @arg @ref LL_TIM_CHANNEL_CH3N
  1558. * @arg @ref LL_TIM_CHANNEL_CH4
  1559. * @param IdleState This parameter can be one of the following values:
  1560. * @arg @ref LL_TIM_OCIDLESTATE_LOW
  1561. * @arg @ref LL_TIM_OCIDLESTATE_HIGH
  1562. * @retval None
  1563. */
  1564. __STATIC_INLINE void LL_TIM_OC_SetIdleState(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t IdleState)
  1565. {
  1566. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1567. MODIFY_REG(TIMx->CR2, (TIM_CR2_OIS1 << SHIFT_TAB_OISx[iChannel]), IdleState << SHIFT_TAB_OISx[iChannel]);
  1568. }
  1569. /**
  1570. * @brief Get the IDLE state of an output channel
  1571. * @rmtoll CR2 OIS1 LL_TIM_OC_GetIdleState\n
  1572. * CR2 OIS1N LL_TIM_OC_GetIdleState\n
  1573. * CR2 OIS2 LL_TIM_OC_GetIdleState\n
  1574. * CR2 OIS2N LL_TIM_OC_GetIdleState\n
  1575. * CR2 OIS3 LL_TIM_OC_GetIdleState\n
  1576. * CR2 OIS3N LL_TIM_OC_GetIdleState\n
  1577. * CR2 OIS4 LL_TIM_OC_GetIdleState
  1578. * @param TIMx Timer instance
  1579. * @param Channel This parameter can be one of the following values:
  1580. * @arg @ref LL_TIM_CHANNEL_CH1
  1581. * @arg @ref LL_TIM_CHANNEL_CH1N
  1582. * @arg @ref LL_TIM_CHANNEL_CH2
  1583. * @arg @ref LL_TIM_CHANNEL_CH2N
  1584. * @arg @ref LL_TIM_CHANNEL_CH3
  1585. * @arg @ref LL_TIM_CHANNEL_CH3N
  1586. * @arg @ref LL_TIM_CHANNEL_CH4
  1587. * @retval Returned value can be one of the following values:
  1588. * @arg @ref LL_TIM_OCIDLESTATE_LOW
  1589. * @arg @ref LL_TIM_OCIDLESTATE_HIGH
  1590. */
  1591. __STATIC_INLINE uint32_t LL_TIM_OC_GetIdleState(TIM_TypeDef *TIMx, uint32_t Channel)
  1592. {
  1593. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1594. return (READ_BIT(TIMx->CR2, (TIM_CR2_OIS1 << SHIFT_TAB_OISx[iChannel])) >> SHIFT_TAB_OISx[iChannel]);
  1595. }
  1596. /**
  1597. * @brief Enable fast mode for the output channel.
  1598. * @note Acts only if the channel is configured in PWM1 or PWM2 mode.
  1599. * @rmtoll CCMR1 OC1FE LL_TIM_OC_EnableFast\n
  1600. * CCMR1 OC2FE LL_TIM_OC_EnableFast\n
  1601. * CCMR2 OC3FE LL_TIM_OC_EnableFast\n
  1602. * CCMR2 OC4FE LL_TIM_OC_EnableFast
  1603. * @param TIMx Timer instance
  1604. * @param Channel This parameter can be one of the following values:
  1605. * @arg @ref LL_TIM_CHANNEL_CH1
  1606. * @arg @ref LL_TIM_CHANNEL_CH2
  1607. * @arg @ref LL_TIM_CHANNEL_CH3
  1608. * @arg @ref LL_TIM_CHANNEL_CH4
  1609. * @retval None
  1610. */
  1611. __STATIC_INLINE void LL_TIM_OC_EnableFast(TIM_TypeDef *TIMx, uint32_t Channel)
  1612. {
  1613. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1614. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1615. SET_BIT(*pReg, (TIM_CCMR1_OC1FE << SHIFT_TAB_OCxx[iChannel]));
  1616. }
  1617. /**
  1618. * @brief Disable fast mode for the output channel.
  1619. * @rmtoll CCMR1 OC1FE LL_TIM_OC_DisableFast\n
  1620. * CCMR1 OC2FE LL_TIM_OC_DisableFast\n
  1621. * CCMR2 OC3FE LL_TIM_OC_DisableFast\n
  1622. * CCMR2 OC4FE LL_TIM_OC_DisableFast
  1623. * @param TIMx Timer instance
  1624. * @param Channel This parameter can be one of the following values:
  1625. * @arg @ref LL_TIM_CHANNEL_CH1
  1626. * @arg @ref LL_TIM_CHANNEL_CH2
  1627. * @arg @ref LL_TIM_CHANNEL_CH3
  1628. * @arg @ref LL_TIM_CHANNEL_CH4
  1629. * @retval None
  1630. */
  1631. __STATIC_INLINE void LL_TIM_OC_DisableFast(TIM_TypeDef *TIMx, uint32_t Channel)
  1632. {
  1633. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1634. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1635. CLEAR_BIT(*pReg, (TIM_CCMR1_OC1FE << SHIFT_TAB_OCxx[iChannel]));
  1636. }
  1637. /**
  1638. * @brief Indicates whether fast mode is enabled for the output channel.
  1639. * @rmtoll CCMR1 OC1FE LL_TIM_OC_IsEnabledFast\n
  1640. * CCMR1 OC2FE LL_TIM_OC_IsEnabledFast\n
  1641. * CCMR2 OC3FE LL_TIM_OC_IsEnabledFast\n
  1642. * CCMR2 OC4FE LL_TIM_OC_IsEnabledFast\n
  1643. * @param TIMx Timer instance
  1644. * @param Channel This parameter can be one of the following values:
  1645. * @arg @ref LL_TIM_CHANNEL_CH1
  1646. * @arg @ref LL_TIM_CHANNEL_CH2
  1647. * @arg @ref LL_TIM_CHANNEL_CH3
  1648. * @arg @ref LL_TIM_CHANNEL_CH4
  1649. * @retval State of bit (1 or 0).
  1650. */
  1651. __STATIC_INLINE uint32_t LL_TIM_OC_IsEnabledFast(TIM_TypeDef *TIMx, uint32_t Channel)
  1652. {
  1653. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1654. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1655. register uint32_t bitfield = TIM_CCMR1_OC1FE << SHIFT_TAB_OCxx[iChannel];
  1656. return (READ_BIT(*pReg, bitfield) == bitfield);
  1657. }
  1658. /**
  1659. * @brief Enable compare register (TIMx_CCRx) preload for the output channel.
  1660. * @rmtoll CCMR1 OC1PE LL_TIM_OC_EnablePreload\n
  1661. * CCMR1 OC2PE LL_TIM_OC_EnablePreload\n
  1662. * CCMR2 OC3PE LL_TIM_OC_EnablePreload\n
  1663. * CCMR2 OC4PE LL_TIM_OC_EnablePreload
  1664. * @param TIMx Timer instance
  1665. * @param Channel This parameter can be one of the following values:
  1666. * @arg @ref LL_TIM_CHANNEL_CH1
  1667. * @arg @ref LL_TIM_CHANNEL_CH2
  1668. * @arg @ref LL_TIM_CHANNEL_CH3
  1669. * @arg @ref LL_TIM_CHANNEL_CH4
  1670. * @retval None
  1671. */
  1672. __STATIC_INLINE void LL_TIM_OC_EnablePreload(TIM_TypeDef *TIMx, uint32_t Channel)
  1673. {
  1674. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1675. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1676. SET_BIT(*pReg, (TIM_CCMR1_OC1PE << SHIFT_TAB_OCxx[iChannel]));
  1677. }
  1678. /**
  1679. * @brief Disable compare register (TIMx_CCRx) preload for the output channel.
  1680. * @rmtoll CCMR1 OC1PE LL_TIM_OC_DisablePreload\n
  1681. * CCMR1 OC2PE LL_TIM_OC_DisablePreload\n
  1682. * CCMR2 OC3PE LL_TIM_OC_DisablePreload\n
  1683. * CCMR2 OC4PE LL_TIM_OC_DisablePreload
  1684. * @param TIMx Timer instance
  1685. * @param Channel This parameter can be one of the following values:
  1686. * @arg @ref LL_TIM_CHANNEL_CH1
  1687. * @arg @ref LL_TIM_CHANNEL_CH2
  1688. * @arg @ref LL_TIM_CHANNEL_CH3
  1689. * @arg @ref LL_TIM_CHANNEL_CH4
  1690. * @retval None
  1691. */
  1692. __STATIC_INLINE void LL_TIM_OC_DisablePreload(TIM_TypeDef *TIMx, uint32_t Channel)
  1693. {
  1694. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1695. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1696. CLEAR_BIT(*pReg, (TIM_CCMR1_OC1PE << SHIFT_TAB_OCxx[iChannel]));
  1697. }
  1698. /**
  1699. * @brief Indicates whether compare register (TIMx_CCRx) preload is enabled for the output channel.
  1700. * @rmtoll CCMR1 OC1PE LL_TIM_OC_IsEnabledPreload\n
  1701. * CCMR1 OC2PE LL_TIM_OC_IsEnabledPreload\n
  1702. * CCMR2 OC3PE LL_TIM_OC_IsEnabledPreload\n
  1703. * CCMR2 OC4PE LL_TIM_OC_IsEnabledPreload\n
  1704. * @param TIMx Timer instance
  1705. * @param Channel This parameter can be one of the following values:
  1706. * @arg @ref LL_TIM_CHANNEL_CH1
  1707. * @arg @ref LL_TIM_CHANNEL_CH2
  1708. * @arg @ref LL_TIM_CHANNEL_CH3
  1709. * @arg @ref LL_TIM_CHANNEL_CH4
  1710. * @retval State of bit (1 or 0).
  1711. */
  1712. __STATIC_INLINE uint32_t LL_TIM_OC_IsEnabledPreload(TIM_TypeDef *TIMx, uint32_t Channel)
  1713. {
  1714. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1715. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1716. register uint32_t bitfield = TIM_CCMR1_OC1PE << SHIFT_TAB_OCxx[iChannel];
  1717. return (READ_BIT(*pReg, bitfield) == bitfield);
  1718. }
  1719. /**
  1720. * @brief Enable clearing the output channel on an external event.
  1721. * @note This function can only be used in Output compare and PWM modes. It does not work in Forced mode.
  1722. * @note Macro @ref IS_TIM_OCXREF_CLEAR_INSTANCE(TIMx) can be used to check whether
  1723. * or not a timer instance can clear the OCxREF signal on an external event.
  1724. * @rmtoll CCMR1 OC1CE LL_TIM_OC_EnableClear\n
  1725. * CCMR1 OC2CE LL_TIM_OC_EnableClear\n
  1726. * CCMR2 OC3CE LL_TIM_OC_EnableClear\n
  1727. * CCMR2 OC4CE LL_TIM_OC_EnableClear
  1728. * @param TIMx Timer instance
  1729. * @param Channel This parameter can be one of the following values:
  1730. * @arg @ref LL_TIM_CHANNEL_CH1
  1731. * @arg @ref LL_TIM_CHANNEL_CH2
  1732. * @arg @ref LL_TIM_CHANNEL_CH3
  1733. * @arg @ref LL_TIM_CHANNEL_CH4
  1734. * @retval None
  1735. */
  1736. __STATIC_INLINE void LL_TIM_OC_EnableClear(TIM_TypeDef *TIMx, uint32_t Channel)
  1737. {
  1738. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1739. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1740. SET_BIT(*pReg, (TIM_CCMR1_OC1CE << SHIFT_TAB_OCxx[iChannel]));
  1741. }
  1742. /**
  1743. * @brief Disable clearing the output channel on an external event.
  1744. * @note Macro @ref IS_TIM_OCXREF_CLEAR_INSTANCE(TIMx) can be used to check whether
  1745. * or not a timer instance can clear the OCxREF signal on an external event.
  1746. * @rmtoll CCMR1 OC1CE LL_TIM_OC_DisableClear\n
  1747. * CCMR1 OC2CE LL_TIM_OC_DisableClear\n
  1748. * CCMR2 OC3CE LL_TIM_OC_DisableClear\n
  1749. * CCMR2 OC4CE LL_TIM_OC_DisableClear
  1750. * @param TIMx Timer instance
  1751. * @param Channel This parameter can be one of the following values:
  1752. * @arg @ref LL_TIM_CHANNEL_CH1
  1753. * @arg @ref LL_TIM_CHANNEL_CH2
  1754. * @arg @ref LL_TIM_CHANNEL_CH3
  1755. * @arg @ref LL_TIM_CHANNEL_CH4
  1756. * @retval None
  1757. */
  1758. __STATIC_INLINE void LL_TIM_OC_DisableClear(TIM_TypeDef *TIMx, uint32_t Channel)
  1759. {
  1760. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1761. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1762. CLEAR_BIT(*pReg, (TIM_CCMR1_OC1CE << SHIFT_TAB_OCxx[iChannel]));
  1763. }
  1764. /**
  1765. * @brief Indicates clearing the output channel on an external event is enabled for the output channel.
  1766. * @note This function enables clearing the output channel on an external event.
  1767. * @note This function can only be used in Output compare and PWM modes. It does not work in Forced mode.
  1768. * @note Macro @ref IS_TIM_OCXREF_CLEAR_INSTANCE(TIMx) can be used to check whether
  1769. * or not a timer instance can clear the OCxREF signal on an external event.
  1770. * @rmtoll CCMR1 OC1CE LL_TIM_OC_IsEnabledClear\n
  1771. * CCMR1 OC2CE LL_TIM_OC_IsEnabledClear\n
  1772. * CCMR2 OC3CE LL_TIM_OC_IsEnabledClear\n
  1773. * CCMR2 OC4CE LL_TIM_OC_IsEnabledClear\n
  1774. * @param TIMx Timer instance
  1775. * @param Channel This parameter can be one of the following values:
  1776. * @arg @ref LL_TIM_CHANNEL_CH1
  1777. * @arg @ref LL_TIM_CHANNEL_CH2
  1778. * @arg @ref LL_TIM_CHANNEL_CH3
  1779. * @arg @ref LL_TIM_CHANNEL_CH4
  1780. * @retval State of bit (1 or 0).
  1781. */
  1782. __STATIC_INLINE uint32_t LL_TIM_OC_IsEnabledClear(TIM_TypeDef *TIMx, uint32_t Channel)
  1783. {
  1784. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1785. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1786. register uint32_t bitfield = TIM_CCMR1_OC1CE << SHIFT_TAB_OCxx[iChannel];
  1787. return (READ_BIT(*pReg, bitfield) == bitfield);
  1788. }
  1789. /**
  1790. * @brief Set the dead-time delay (delay inserted between the rising edge of the OCxREF signal and the rising edge if the Ocx and OCxN signals).
  1791. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  1792. * dead-time insertion feature is supported by a timer instance.
  1793. * @note Helper macro @ref __LL_TIM_CALC_DEADTIME can be used to calculate the DeadTime parameter
  1794. * @rmtoll BDTR DTG LL_TIM_OC_SetDeadTime
  1795. * @param TIMx Timer instance
  1796. * @param DeadTime between Min_Data=0 and Max_Data=255
  1797. * @retval None
  1798. */
  1799. __STATIC_INLINE void LL_TIM_OC_SetDeadTime(TIM_TypeDef *TIMx, uint32_t DeadTime)
  1800. {
  1801. MODIFY_REG(TIMx->BDTR, TIM_BDTR_DTG, DeadTime);
  1802. }
  1803. /**
  1804. * @brief Set compare value for output channel 1 (TIMx_CCR1).
  1805. * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
  1806. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1807. * whether or not a timer instance supports a 32 bits counter.
  1808. * @note Macro @ref IS_TIM_CC1_INSTANCE(TIMx) can be used to check whether or not
  1809. * output channel 1 is supported by a timer instance.
  1810. * @rmtoll CCR1 CCR1 LL_TIM_OC_SetCompareCH1
  1811. * @param TIMx Timer instance
  1812. * @param CompareValue between Min_Data=0 and Max_Data=65535
  1813. * @retval None
  1814. */
  1815. __STATIC_INLINE void LL_TIM_OC_SetCompareCH1(TIM_TypeDef *TIMx, uint32_t CompareValue)
  1816. {
  1817. WRITE_REG(TIMx->CCR1, CompareValue);
  1818. }
  1819. /**
  1820. * @brief Set compare value for output channel 2 (TIMx_CCR2).
  1821. * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
  1822. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1823. * whether or not a timer instance supports a 32 bits counter.
  1824. * @note Macro @ref IS_TIM_CC2_INSTANCE(TIMx) can be used to check whether or not
  1825. * output channel 2 is supported by a timer instance.
  1826. * @rmtoll CCR2 CCR2 LL_TIM_OC_SetCompareCH2
  1827. * @param TIMx Timer instance
  1828. * @param CompareValue between Min_Data=0 and Max_Data=65535
  1829. * @retval None
  1830. */
  1831. __STATIC_INLINE void LL_TIM_OC_SetCompareCH2(TIM_TypeDef *TIMx, uint32_t CompareValue)
  1832. {
  1833. WRITE_REG(TIMx->CCR2, CompareValue);
  1834. }
  1835. /**
  1836. * @brief Set compare value for output channel 3 (TIMx_CCR3).
  1837. * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
  1838. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1839. * whether or not a timer instance supports a 32 bits counter.
  1840. * @note Macro @ref IS_TIM_CC3_INSTANCE(TIMx) can be used to check whether or not
  1841. * output channel is supported by a timer instance.
  1842. * @rmtoll CCR3 CCR3 LL_TIM_OC_SetCompareCH3
  1843. * @param TIMx Timer instance
  1844. * @param CompareValue between Min_Data=0 and Max_Data=65535
  1845. * @retval None
  1846. */
  1847. __STATIC_INLINE void LL_TIM_OC_SetCompareCH3(TIM_TypeDef *TIMx, uint32_t CompareValue)
  1848. {
  1849. WRITE_REG(TIMx->CCR3, CompareValue);
  1850. }
  1851. /**
  1852. * @brief Set compare value for output channel 4 (TIMx_CCR4).
  1853. * @note In 32-bit timer implementations compare value can be between 0x00000000 and 0xFFFFFFFF.
  1854. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1855. * whether or not a timer instance supports a 32 bits counter.
  1856. * @note Macro @ref IS_TIM_CC4_INSTANCE(TIMx) can be used to check whether or not
  1857. * output channel 4 is supported by a timer instance.
  1858. * @rmtoll CCR4 CCR4 LL_TIM_OC_SetCompareCH4
  1859. * @param TIMx Timer instance
  1860. * @param CompareValue between Min_Data=0 and Max_Data=65535
  1861. * @retval None
  1862. */
  1863. __STATIC_INLINE void LL_TIM_OC_SetCompareCH4(TIM_TypeDef *TIMx, uint32_t CompareValue)
  1864. {
  1865. WRITE_REG(TIMx->CCR4, CompareValue);
  1866. }
  1867. /**
  1868. * @brief Get compare value (TIMx_CCR1) set for output channel 1.
  1869. * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
  1870. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1871. * whether or not a timer instance supports a 32 bits counter.
  1872. * @note Macro @ref IS_TIM_CC1_INSTANCE(TIMx) can be used to check whether or not
  1873. * output channel 1 is supported by a timer instance.
  1874. * @rmtoll CCR1 CCR1 LL_TIM_OC_GetCompareCH1
  1875. * @param TIMx Timer instance
  1876. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  1877. */
  1878. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH1(TIM_TypeDef *TIMx)
  1879. {
  1880. return (uint32_t)(READ_REG(TIMx->CCR1));
  1881. }
  1882. /**
  1883. * @brief Get compare value (TIMx_CCR2) set for output channel 2.
  1884. * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
  1885. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1886. * whether or not a timer instance supports a 32 bits counter.
  1887. * @note Macro @ref IS_TIM_CC2_INSTANCE(TIMx) can be used to check whether or not
  1888. * output channel 2 is supported by a timer instance.
  1889. * @rmtoll CCR2 CCR2 LL_TIM_OC_GetCompareCH2
  1890. * @param TIMx Timer instance
  1891. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  1892. */
  1893. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH2(TIM_TypeDef *TIMx)
  1894. {
  1895. return (uint32_t)(READ_REG(TIMx->CCR2));
  1896. }
  1897. /**
  1898. * @brief Get compare value (TIMx_CCR3) set for output channel 3.
  1899. * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
  1900. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1901. * whether or not a timer instance supports a 32 bits counter.
  1902. * @note Macro @ref IS_TIM_CC3_INSTANCE(TIMx) can be used to check whether or not
  1903. * output channel 3 is supported by a timer instance.
  1904. * @rmtoll CCR3 CCR3 LL_TIM_OC_GetCompareCH3
  1905. * @param TIMx Timer instance
  1906. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  1907. */
  1908. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH3(TIM_TypeDef *TIMx)
  1909. {
  1910. return (uint32_t)(READ_REG(TIMx->CCR3));
  1911. }
  1912. /**
  1913. * @brief Get compare value (TIMx_CCR4) set for output channel 4.
  1914. * @note In 32-bit timer implementations returned compare value can be between 0x00000000 and 0xFFFFFFFF.
  1915. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  1916. * whether or not a timer instance supports a 32 bits counter.
  1917. * @note Macro @ref IS_TIM_CC4_INSTANCE(TIMx) can be used to check whether or not
  1918. * output channel 4 is supported by a timer instance.
  1919. * @rmtoll CCR4 CCR4 LL_TIM_OC_GetCompareCH4
  1920. * @param TIMx Timer instance
  1921. * @retval CompareValue (between Min_Data=0 and Max_Data=65535)
  1922. */
  1923. __STATIC_INLINE uint32_t LL_TIM_OC_GetCompareCH4(TIM_TypeDef *TIMx)
  1924. {
  1925. return (uint32_t)(READ_REG(TIMx->CCR4));
  1926. }
  1927. /**
  1928. * @}
  1929. */
  1930. /** @defgroup TIM_LL_EF_Input_Channel Input channel configuration
  1931. * @{
  1932. */
  1933. /**
  1934. * @brief Configure input channel.
  1935. * @rmtoll CCMR1 CC1S LL_TIM_IC_Config\n
  1936. * CCMR1 IC1PSC LL_TIM_IC_Config\n
  1937. * CCMR1 IC1F LL_TIM_IC_Config\n
  1938. * CCMR1 CC2S LL_TIM_IC_Config\n
  1939. * CCMR1 IC2PSC LL_TIM_IC_Config\n
  1940. * CCMR1 IC2F LL_TIM_IC_Config\n
  1941. * CCMR2 CC3S LL_TIM_IC_Config\n
  1942. * CCMR2 IC3PSC LL_TIM_IC_Config\n
  1943. * CCMR2 IC3F LL_TIM_IC_Config\n
  1944. * CCMR2 CC4S LL_TIM_IC_Config\n
  1945. * CCMR2 IC4PSC LL_TIM_IC_Config\n
  1946. * CCMR2 IC4F LL_TIM_IC_Config\n
  1947. * CCER CC1P LL_TIM_IC_Config\n
  1948. * CCER CC1NP LL_TIM_IC_Config\n
  1949. * CCER CC2P LL_TIM_IC_Config\n
  1950. * CCER CC2NP LL_TIM_IC_Config\n
  1951. * CCER CC3P LL_TIM_IC_Config\n
  1952. * CCER CC3NP LL_TIM_IC_Config\n
  1953. * CCER CC4P LL_TIM_IC_Config\n
  1954. * CCER CC4NP LL_TIM_IC_Config
  1955. * @param TIMx Timer instance
  1956. * @param Channel This parameter can be one of the following values:
  1957. * @arg @ref LL_TIM_CHANNEL_CH1
  1958. * @arg @ref LL_TIM_CHANNEL_CH2
  1959. * @arg @ref LL_TIM_CHANNEL_CH3
  1960. * @arg @ref LL_TIM_CHANNEL_CH4
  1961. * @param Configuration This parameter must be a combination of all the following values:
  1962. * @arg @ref LL_TIM_ACTIVEINPUT_DIRECTTI or @ref LL_TIM_ACTIVEINPUT_INDIRECTTI or @ref LL_TIM_ACTIVEINPUT_TRC
  1963. * @arg @ref LL_TIM_ICPSC_DIV1 or ... or @ref LL_TIM_ICPSC_DIV8
  1964. * @arg @ref LL_TIM_IC_FILTER_FDIV1 or ... or @ref LL_TIM_IC_FILTER_FDIV32_N8
  1965. * @arg @ref LL_TIM_IC_POLARITY_RISING or @ref LL_TIM_IC_POLARITY_FALLING or @ref LL_TIM_IC_POLARITY_BOTHEDGE
  1966. * @retval None
  1967. */
  1968. __STATIC_INLINE void LL_TIM_IC_Config(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t Configuration)
  1969. {
  1970. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1971. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1972. MODIFY_REG(*pReg, ((TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC | TIM_CCMR1_CC1S) << SHIFT_TAB_ICxx[iChannel]),
  1973. ((Configuration >> 16U) & (TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC | TIM_CCMR1_CC1S)) << SHIFT_TAB_ICxx[iChannel]);
  1974. MODIFY_REG(TIMx->CCER, ((TIM_CCER_CC1NP | TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel]),
  1975. (Configuration & (TIM_CCER_CC1NP | TIM_CCER_CC1P)) << SHIFT_TAB_CCxP[iChannel]);
  1976. }
  1977. /**
  1978. * @brief Set the active input.
  1979. * @rmtoll CCMR1 CC1S LL_TIM_IC_SetActiveInput\n
  1980. * CCMR1 CC2S LL_TIM_IC_SetActiveInput\n
  1981. * CCMR2 CC3S LL_TIM_IC_SetActiveInput\n
  1982. * CCMR2 CC4S LL_TIM_IC_SetActiveInput
  1983. * @param TIMx Timer instance
  1984. * @param Channel This parameter can be one of the following values:
  1985. * @arg @ref LL_TIM_CHANNEL_CH1
  1986. * @arg @ref LL_TIM_CHANNEL_CH2
  1987. * @arg @ref LL_TIM_CHANNEL_CH3
  1988. * @arg @ref LL_TIM_CHANNEL_CH4
  1989. * @param ICActiveInput This parameter can be one of the following values:
  1990. * @arg @ref LL_TIM_ACTIVEINPUT_DIRECTTI
  1991. * @arg @ref LL_TIM_ACTIVEINPUT_INDIRECTTI
  1992. * @arg @ref LL_TIM_ACTIVEINPUT_TRC
  1993. * @retval None
  1994. */
  1995. __STATIC_INLINE void LL_TIM_IC_SetActiveInput(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICActiveInput)
  1996. {
  1997. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  1998. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  1999. MODIFY_REG(*pReg, ((TIM_CCMR1_CC1S) << SHIFT_TAB_ICxx[iChannel]), (ICActiveInput >> 16U) << SHIFT_TAB_ICxx[iChannel]);
  2000. }
  2001. /**
  2002. * @brief Get the current active input.
  2003. * @rmtoll CCMR1 CC1S LL_TIM_IC_GetActiveInput\n
  2004. * CCMR1 CC2S LL_TIM_IC_GetActiveInput\n
  2005. * CCMR2 CC3S LL_TIM_IC_GetActiveInput\n
  2006. * CCMR2 CC4S LL_TIM_IC_GetActiveInput
  2007. * @param TIMx Timer instance
  2008. * @param Channel This parameter can be one of the following values:
  2009. * @arg @ref LL_TIM_CHANNEL_CH1
  2010. * @arg @ref LL_TIM_CHANNEL_CH2
  2011. * @arg @ref LL_TIM_CHANNEL_CH3
  2012. * @arg @ref LL_TIM_CHANNEL_CH4
  2013. * @retval Returned value can be one of the following values:
  2014. * @arg @ref LL_TIM_ACTIVEINPUT_DIRECTTI
  2015. * @arg @ref LL_TIM_ACTIVEINPUT_INDIRECTTI
  2016. * @arg @ref LL_TIM_ACTIVEINPUT_TRC
  2017. */
  2018. __STATIC_INLINE uint32_t LL_TIM_IC_GetActiveInput(TIM_TypeDef *TIMx, uint32_t Channel)
  2019. {
  2020. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2021. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2022. return ((READ_BIT(*pReg, ((TIM_CCMR1_CC1S) << SHIFT_TAB_ICxx[iChannel])) >> SHIFT_TAB_ICxx[iChannel]) << 16U);
  2023. }
  2024. /**
  2025. * @brief Set the prescaler of input channel.
  2026. * @rmtoll CCMR1 IC1PSC LL_TIM_IC_SetPrescaler\n
  2027. * CCMR1 IC2PSC LL_TIM_IC_SetPrescaler\n
  2028. * CCMR2 IC3PSC LL_TIM_IC_SetPrescaler\n
  2029. * CCMR2 IC4PSC LL_TIM_IC_SetPrescaler
  2030. * @param TIMx Timer instance
  2031. * @param Channel This parameter can be one of the following values:
  2032. * @arg @ref LL_TIM_CHANNEL_CH1
  2033. * @arg @ref LL_TIM_CHANNEL_CH2
  2034. * @arg @ref LL_TIM_CHANNEL_CH3
  2035. * @arg @ref LL_TIM_CHANNEL_CH4
  2036. * @param ICPrescaler This parameter can be one of the following values:
  2037. * @arg @ref LL_TIM_ICPSC_DIV1
  2038. * @arg @ref LL_TIM_ICPSC_DIV2
  2039. * @arg @ref LL_TIM_ICPSC_DIV4
  2040. * @arg @ref LL_TIM_ICPSC_DIV8
  2041. * @retval None
  2042. */
  2043. __STATIC_INLINE void LL_TIM_IC_SetPrescaler(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICPrescaler)
  2044. {
  2045. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2046. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2047. MODIFY_REG(*pReg, ((TIM_CCMR1_IC1PSC) << SHIFT_TAB_ICxx[iChannel]), (ICPrescaler >> 16U) << SHIFT_TAB_ICxx[iChannel]);
  2048. }
  2049. /**
  2050. * @brief Get the current prescaler value acting on an input channel.
  2051. * @rmtoll CCMR1 IC1PSC LL_TIM_IC_GetPrescaler\n
  2052. * CCMR1 IC2PSC LL_TIM_IC_GetPrescaler\n
  2053. * CCMR2 IC3PSC LL_TIM_IC_GetPrescaler\n
  2054. * CCMR2 IC4PSC LL_TIM_IC_GetPrescaler
  2055. * @param TIMx Timer instance
  2056. * @param Channel This parameter can be one of the following values:
  2057. * @arg @ref LL_TIM_CHANNEL_CH1
  2058. * @arg @ref LL_TIM_CHANNEL_CH2
  2059. * @arg @ref LL_TIM_CHANNEL_CH3
  2060. * @arg @ref LL_TIM_CHANNEL_CH4
  2061. * @retval Returned value can be one of the following values:
  2062. * @arg @ref LL_TIM_ICPSC_DIV1
  2063. * @arg @ref LL_TIM_ICPSC_DIV2
  2064. * @arg @ref LL_TIM_ICPSC_DIV4
  2065. * @arg @ref LL_TIM_ICPSC_DIV8
  2066. */
  2067. __STATIC_INLINE uint32_t LL_TIM_IC_GetPrescaler(TIM_TypeDef *TIMx, uint32_t Channel)
  2068. {
  2069. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2070. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2071. return ((READ_BIT(*pReg, ((TIM_CCMR1_IC1PSC) << SHIFT_TAB_ICxx[iChannel])) >> SHIFT_TAB_ICxx[iChannel]) << 16U);
  2072. }
  2073. /**
  2074. * @brief Set the input filter duration.
  2075. * @rmtoll CCMR1 IC1F LL_TIM_IC_SetFilter\n
  2076. * CCMR1 IC2F LL_TIM_IC_SetFilter\n
  2077. * CCMR2 IC3F LL_TIM_IC_SetFilter\n
  2078. * CCMR2 IC4F LL_TIM_IC_SetFilter
  2079. * @param TIMx Timer instance
  2080. * @param Channel This parameter can be one of the following values:
  2081. * @arg @ref LL_TIM_CHANNEL_CH1
  2082. * @arg @ref LL_TIM_CHANNEL_CH2
  2083. * @arg @ref LL_TIM_CHANNEL_CH3
  2084. * @arg @ref LL_TIM_CHANNEL_CH4
  2085. * @param ICFilter This parameter can be one of the following values:
  2086. * @arg @ref LL_TIM_IC_FILTER_FDIV1
  2087. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N2
  2088. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N4
  2089. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N8
  2090. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N6
  2091. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N8
  2092. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N6
  2093. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N8
  2094. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N6
  2095. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N8
  2096. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N5
  2097. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N6
  2098. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N8
  2099. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N5
  2100. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N6
  2101. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N8
  2102. * @retval None
  2103. */
  2104. __STATIC_INLINE void LL_TIM_IC_SetFilter(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICFilter)
  2105. {
  2106. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2107. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2108. MODIFY_REG(*pReg, ((TIM_CCMR1_IC1F) << SHIFT_TAB_ICxx[iChannel]), (ICFilter >> 16U) << SHIFT_TAB_ICxx[iChannel]);
  2109. }
  2110. /**
  2111. * @brief Get the input filter duration.
  2112. * @rmtoll CCMR1 IC1F LL_TIM_IC_GetFilter\n
  2113. * CCMR1 IC2F LL_TIM_IC_GetFilter\n
  2114. * CCMR2 IC3F LL_TIM_IC_GetFilter\n
  2115. * CCMR2 IC4F LL_TIM_IC_GetFilter
  2116. * @param TIMx Timer instance
  2117. * @param Channel This parameter can be one of the following values:
  2118. * @arg @ref LL_TIM_CHANNEL_CH1
  2119. * @arg @ref LL_TIM_CHANNEL_CH2
  2120. * @arg @ref LL_TIM_CHANNEL_CH3
  2121. * @arg @ref LL_TIM_CHANNEL_CH4
  2122. * @retval Returned value can be one of the following values:
  2123. * @arg @ref LL_TIM_IC_FILTER_FDIV1
  2124. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N2
  2125. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N4
  2126. * @arg @ref LL_TIM_IC_FILTER_FDIV1_N8
  2127. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N6
  2128. * @arg @ref LL_TIM_IC_FILTER_FDIV2_N8
  2129. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N6
  2130. * @arg @ref LL_TIM_IC_FILTER_FDIV4_N8
  2131. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N6
  2132. * @arg @ref LL_TIM_IC_FILTER_FDIV8_N8
  2133. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N5
  2134. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N6
  2135. * @arg @ref LL_TIM_IC_FILTER_FDIV16_N8
  2136. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N5
  2137. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N6
  2138. * @arg @ref LL_TIM_IC_FILTER_FDIV32_N8
  2139. */
  2140. __STATIC_INLINE uint32_t LL_TIM_IC_GetFilter(TIM_TypeDef *TIMx, uint32_t Channel)
  2141. {
  2142. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2143. register uint32_t *pReg = (uint32_t *)((uint32_t)((uint32_t)(&TIMx->CCMR1) + OFFSET_TAB_CCMRx[iChannel]));
  2144. return ((READ_BIT(*pReg, ((TIM_CCMR1_IC1F) << SHIFT_TAB_ICxx[iChannel])) >> SHIFT_TAB_ICxx[iChannel]) << 16U);
  2145. }
  2146. /**
  2147. * @brief Set the input channel polarity.
  2148. * @rmtoll CCER CC1P LL_TIM_IC_SetPolarity\n
  2149. * CCER CC1NP LL_TIM_IC_SetPolarity\n
  2150. * CCER CC2P LL_TIM_IC_SetPolarity\n
  2151. * CCER CC2NP LL_TIM_IC_SetPolarity\n
  2152. * CCER CC3P LL_TIM_IC_SetPolarity\n
  2153. * CCER CC3NP LL_TIM_IC_SetPolarity\n
  2154. * CCER CC4P LL_TIM_IC_SetPolarity\n
  2155. * CCER CC4NP LL_TIM_IC_SetPolarity
  2156. * @param TIMx Timer instance
  2157. * @param Channel This parameter can be one of the following values:
  2158. * @arg @ref LL_TIM_CHANNEL_CH1
  2159. * @arg @ref LL_TIM_CHANNEL_CH2
  2160. * @arg @ref LL_TIM_CHANNEL_CH3
  2161. * @arg @ref LL_TIM_CHANNEL_CH4
  2162. * @param ICPolarity This parameter can be one of the following values:
  2163. * @arg @ref LL_TIM_IC_POLARITY_RISING
  2164. * @arg @ref LL_TIM_IC_POLARITY_FALLING
  2165. * @arg @ref LL_TIM_IC_POLARITY_BOTHEDGE
  2166. * @retval None
  2167. */
  2168. __STATIC_INLINE void LL_TIM_IC_SetPolarity(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ICPolarity)
  2169. {
  2170. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2171. MODIFY_REG(TIMx->CCER, ((TIM_CCER_CC1NP | TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel]),
  2172. ICPolarity << SHIFT_TAB_CCxP[iChannel]);
  2173. }
  2174. /**
  2175. * @brief Get the current input channel polarity.
  2176. * @rmtoll CCER CC1P LL_TIM_IC_GetPolarity\n
  2177. * CCER CC1NP LL_TIM_IC_GetPolarity\n
  2178. * CCER CC2P LL_TIM_IC_GetPolarity\n
  2179. * CCER CC2NP LL_TIM_IC_GetPolarity\n
  2180. * CCER CC3P LL_TIM_IC_GetPolarity\n
  2181. * CCER CC3NP LL_TIM_IC_GetPolarity\n
  2182. * CCER CC4P LL_TIM_IC_GetPolarity\n
  2183. * CCER CC4NP LL_TIM_IC_GetPolarity
  2184. * @param TIMx Timer instance
  2185. * @param Channel This parameter can be one of the following values:
  2186. * @arg @ref LL_TIM_CHANNEL_CH1
  2187. * @arg @ref LL_TIM_CHANNEL_CH2
  2188. * @arg @ref LL_TIM_CHANNEL_CH3
  2189. * @arg @ref LL_TIM_CHANNEL_CH4
  2190. * @retval Returned value can be one of the following values:
  2191. * @arg @ref LL_TIM_IC_POLARITY_RISING
  2192. * @arg @ref LL_TIM_IC_POLARITY_FALLING
  2193. * @arg @ref LL_TIM_IC_POLARITY_BOTHEDGE
  2194. */
  2195. __STATIC_INLINE uint32_t LL_TIM_IC_GetPolarity(TIM_TypeDef *TIMx, uint32_t Channel)
  2196. {
  2197. register uint8_t iChannel = TIM_GET_CHANNEL_INDEX(Channel);
  2198. return (READ_BIT(TIMx->CCER, ((TIM_CCER_CC1NP | TIM_CCER_CC1P) << SHIFT_TAB_CCxP[iChannel])) >>
  2199. SHIFT_TAB_CCxP[iChannel]);
  2200. }
  2201. /**
  2202. * @brief Connect the TIMx_CH1, CH2 and CH3 pins to the TI1 input (XOR combination).
  2203. * @note Macro @ref IS_TIM_XOR_INSTANCE(TIMx) can be used to check whether or not
  2204. * a timer instance provides an XOR input.
  2205. * @rmtoll CR2 TI1S LL_TIM_IC_EnableXORCombination
  2206. * @param TIMx Timer instance
  2207. * @retval None
  2208. */
  2209. __STATIC_INLINE void LL_TIM_IC_EnableXORCombination(TIM_TypeDef *TIMx)
  2210. {
  2211. SET_BIT(TIMx->CR2, TIM_CR2_TI1S);
  2212. }
  2213. /**
  2214. * @brief Disconnect the TIMx_CH1, CH2 and CH3 pins from the TI1 input.
  2215. * @note Macro @ref IS_TIM_XOR_INSTANCE(TIMx) can be used to check whether or not
  2216. * a timer instance provides an XOR input.
  2217. * @rmtoll CR2 TI1S LL_TIM_IC_DisableXORCombination
  2218. * @param TIMx Timer instance
  2219. * @retval None
  2220. */
  2221. __STATIC_INLINE void LL_TIM_IC_DisableXORCombination(TIM_TypeDef *TIMx)
  2222. {
  2223. CLEAR_BIT(TIMx->CR2, TIM_CR2_TI1S);
  2224. }
  2225. /**
  2226. * @brief Indicates whether the TIMx_CH1, CH2 and CH3 pins are connectected to the TI1 input.
  2227. * @note Macro @ref IS_TIM_XOR_INSTANCE(TIMx) can be used to check whether or not
  2228. * a timer instance provides an XOR input.
  2229. * @rmtoll CR2 TI1S LL_TIM_IC_IsEnabledXORCombination
  2230. * @param TIMx Timer instance
  2231. * @retval State of bit (1 or 0).
  2232. */
  2233. __STATIC_INLINE uint32_t LL_TIM_IC_IsEnabledXORCombination(TIM_TypeDef *TIMx)
  2234. {
  2235. return (READ_BIT(TIMx->CR2, TIM_CR2_TI1S) == (TIM_CR2_TI1S));
  2236. }
  2237. /**
  2238. * @brief Get captured value for input channel 1.
  2239. * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
  2240. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2241. * whether or not a timer instance supports a 32 bits counter.
  2242. * @note Macro @ref IS_TIM_CC1_INSTANCE(TIMx) can be used to check whether or not
  2243. * input channel 1 is supported by a timer instance.
  2244. * @rmtoll CCR1 CCR1 LL_TIM_IC_GetCaptureCH1
  2245. * @param TIMx Timer instance
  2246. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  2247. */
  2248. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH1(TIM_TypeDef *TIMx)
  2249. {
  2250. return (uint32_t)(READ_REG(TIMx->CCR1));
  2251. }
  2252. /**
  2253. * @brief Get captured value for input channel 2.
  2254. * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
  2255. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2256. * whether or not a timer instance supports a 32 bits counter.
  2257. * @note Macro @ref IS_TIM_CC2_INSTANCE(TIMx) can be used to check whether or not
  2258. * input channel 2 is supported by a timer instance.
  2259. * @rmtoll CCR2 CCR2 LL_TIM_IC_GetCaptureCH2
  2260. * @param TIMx Timer instance
  2261. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  2262. */
  2263. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH2(TIM_TypeDef *TIMx)
  2264. {
  2265. return (uint32_t)(READ_REG(TIMx->CCR2));
  2266. }
  2267. /**
  2268. * @brief Get captured value for input channel 3.
  2269. * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
  2270. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2271. * whether or not a timer instance supports a 32 bits counter.
  2272. * @note Macro @ref IS_TIM_CC3_INSTANCE(TIMx) can be used to check whether or not
  2273. * input channel 3 is supported by a timer instance.
  2274. * @rmtoll CCR3 CCR3 LL_TIM_IC_GetCaptureCH3
  2275. * @param TIMx Timer instance
  2276. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  2277. */
  2278. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH3(TIM_TypeDef *TIMx)
  2279. {
  2280. return (uint32_t)(READ_REG(TIMx->CCR3));
  2281. }
  2282. /**
  2283. * @brief Get captured value for input channel 4.
  2284. * @note In 32-bit timer implementations returned captured value can be between 0x00000000 and 0xFFFFFFFF.
  2285. * @note Macro @ref IS_TIM_32B_COUNTER_INSTANCE(TIMx) can be used to check
  2286. * whether or not a timer instance supports a 32 bits counter.
  2287. * @note Macro @ref IS_TIM_CC4_INSTANCE(TIMx) can be used to check whether or not
  2288. * input channel 4 is supported by a timer instance.
  2289. * @rmtoll CCR4 CCR4 LL_TIM_IC_GetCaptureCH4
  2290. * @param TIMx Timer instance
  2291. * @retval CapturedValue (between Min_Data=0 and Max_Data=65535)
  2292. */
  2293. __STATIC_INLINE uint32_t LL_TIM_IC_GetCaptureCH4(TIM_TypeDef *TIMx)
  2294. {
  2295. return (uint32_t)(READ_REG(TIMx->CCR4));
  2296. }
  2297. /**
  2298. * @}
  2299. */
  2300. /** @defgroup TIM_LL_EF_Clock_Selection Counter clock selection
  2301. * @{
  2302. */
  2303. /**
  2304. * @brief Enable external clock mode 2.
  2305. * @note When external clock mode 2 is enabled the counter is clocked by any active edge on the ETRF signal.
  2306. * @note Macro @ref IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  2307. * whether or not a timer instance supports external clock mode2.
  2308. * @rmtoll SMCR ECE LL_TIM_EnableExternalClock
  2309. * @param TIMx Timer instance
  2310. * @retval None
  2311. */
  2312. __STATIC_INLINE void LL_TIM_EnableExternalClock(TIM_TypeDef *TIMx)
  2313. {
  2314. SET_BIT(TIMx->SMCR, TIM_SMCR_ECE);
  2315. }
  2316. /**
  2317. * @brief Disable external clock mode 2.
  2318. * @note Macro @ref IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  2319. * whether or not a timer instance supports external clock mode2.
  2320. * @rmtoll SMCR ECE LL_TIM_DisableExternalClock
  2321. * @param TIMx Timer instance
  2322. * @retval None
  2323. */
  2324. __STATIC_INLINE void LL_TIM_DisableExternalClock(TIM_TypeDef *TIMx)
  2325. {
  2326. CLEAR_BIT(TIMx->SMCR, TIM_SMCR_ECE);
  2327. }
  2328. /**
  2329. * @brief Indicate whether external clock mode 2 is enabled.
  2330. * @note Macro @ref IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  2331. * whether or not a timer instance supports external clock mode2.
  2332. * @rmtoll SMCR ECE LL_TIM_IsEnabledExternalClock
  2333. * @param TIMx Timer instance
  2334. * @retval State of bit (1 or 0).
  2335. */
  2336. __STATIC_INLINE uint32_t LL_TIM_IsEnabledExternalClock(TIM_TypeDef *TIMx)
  2337. {
  2338. return (READ_BIT(TIMx->SMCR, TIM_SMCR_ECE) == (TIM_SMCR_ECE));
  2339. }
  2340. /**
  2341. * @brief Set the clock source of the counter clock.
  2342. * @note when selected clock source is external clock mode 1, the timer input
  2343. * the external clock is applied is selected by calling the @ref LL_TIM_SetTriggerInput()
  2344. * function. This timer input must be configured by calling
  2345. * the @ref LL_TIM_IC_Config() function.
  2346. * @note Macro @ref IS_TIM_CLOCKSOURCE_ETRMODE1_INSTANCE(TIMx) can be used to check
  2347. * whether or not a timer instance supports external clock mode1.
  2348. * @note Macro @ref IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(TIMx) can be used to check
  2349. * whether or not a timer instance supports external clock mode2.
  2350. * @rmtoll SMCR SMS LL_TIM_SetClockSource\n
  2351. * SMCR ECE LL_TIM_SetClockSource
  2352. * @param TIMx Timer instance
  2353. * @param ClockSource This parameter can be one of the following values:
  2354. * @arg @ref LL_TIM_CLOCKSOURCE_INTERNAL
  2355. * @arg @ref LL_TIM_CLOCKSOURCE_EXT_MODE1
  2356. * @arg @ref LL_TIM_CLOCKSOURCE_EXT_MODE2
  2357. * @retval None
  2358. */
  2359. __STATIC_INLINE void LL_TIM_SetClockSource(TIM_TypeDef *TIMx, uint32_t ClockSource)
  2360. {
  2361. MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMS | TIM_SMCR_ECE, ClockSource);
  2362. }
  2363. /**
  2364. * @brief Set the encoder interface mode.
  2365. * @note Macro @ref IS_TIM_ENCODER_INTERFACE_INSTANCE(TIMx) can be used to check
  2366. * whether or not a timer instance supports the encoder mode.
  2367. * @rmtoll SMCR SMS LL_TIM_SetEncoderMode
  2368. * @param TIMx Timer instance
  2369. * @param EncoderMode This parameter can be one of the following values:
  2370. * @arg @ref LL_TIM_ENCODERMODE_X2_TI1
  2371. * @arg @ref LL_TIM_ENCODERMODE_X2_TI2
  2372. * @arg @ref LL_TIM_ENCODERMODE_X4_TI12
  2373. * @retval None
  2374. */
  2375. __STATIC_INLINE void LL_TIM_SetEncoderMode(TIM_TypeDef *TIMx, uint32_t EncoderMode)
  2376. {
  2377. MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMS, EncoderMode);
  2378. }
  2379. /**
  2380. * @}
  2381. */
  2382. /** @defgroup TIM_LL_EF_Timer_Synchronization Timer synchronisation configuration
  2383. * @{
  2384. */
  2385. /**
  2386. * @brief Set the trigger output (TRGO) used for timer synchronization .
  2387. * @note Macro @ref IS_TIM_MASTER_INSTANCE(TIMx) can be used to check
  2388. * whether or not a timer instance can operate as a master timer.
  2389. * @rmtoll CR2 MMS LL_TIM_SetTriggerOutput
  2390. * @param TIMx Timer instance
  2391. * @param TimerSynchronization This parameter can be one of the following values:
  2392. * @arg @ref LL_TIM_TRGO_RESET
  2393. * @arg @ref LL_TIM_TRGO_ENABLE
  2394. * @arg @ref LL_TIM_TRGO_UPDATE
  2395. * @arg @ref LL_TIM_TRGO_CC1IF
  2396. * @arg @ref LL_TIM_TRGO_OC1REF
  2397. * @arg @ref LL_TIM_TRGO_OC2REF
  2398. * @arg @ref LL_TIM_TRGO_OC3REF
  2399. * @arg @ref LL_TIM_TRGO_OC4REF
  2400. * @retval None
  2401. */
  2402. __STATIC_INLINE void LL_TIM_SetTriggerOutput(TIM_TypeDef *TIMx, uint32_t TimerSynchronization)
  2403. {
  2404. MODIFY_REG(TIMx->CR2, TIM_CR2_MMS, TimerSynchronization);
  2405. }
  2406. /**
  2407. * @brief Set the synchronization mode of a slave timer.
  2408. * @note Macro @ref IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  2409. * a timer instance can operate as a slave timer.
  2410. * @rmtoll SMCR SMS LL_TIM_SetSlaveMode
  2411. * @param TIMx Timer instance
  2412. * @param SlaveMode This parameter can be one of the following values:
  2413. * @arg @ref LL_TIM_SLAVEMODE_DISABLED
  2414. * @arg @ref LL_TIM_SLAVEMODE_RESET
  2415. * @arg @ref LL_TIM_SLAVEMODE_GATED
  2416. * @arg @ref LL_TIM_SLAVEMODE_TRIGGER
  2417. * @retval None
  2418. */
  2419. __STATIC_INLINE void LL_TIM_SetSlaveMode(TIM_TypeDef *TIMx, uint32_t SlaveMode)
  2420. {
  2421. MODIFY_REG(TIMx->SMCR, TIM_SMCR_SMS, SlaveMode);
  2422. }
  2423. /**
  2424. * @brief Set the selects the trigger input to be used to synchronize the counter.
  2425. * @note Macro @ref IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  2426. * a timer instance can operate as a slave timer.
  2427. * @rmtoll SMCR TS LL_TIM_SetTriggerInput
  2428. * @param TIMx Timer instance
  2429. * @param TriggerInput This parameter can be one of the following values:
  2430. * @arg @ref LL_TIM_TS_ITR0
  2431. * @arg @ref LL_TIM_TS_ITR1
  2432. * @arg @ref LL_TIM_TS_ITR2
  2433. * @arg @ref LL_TIM_TS_ITR3
  2434. * @arg @ref LL_TIM_TS_TI1F_ED
  2435. * @arg @ref LL_TIM_TS_TI1FP1
  2436. * @arg @ref LL_TIM_TS_TI2FP2
  2437. * @arg @ref LL_TIM_TS_ETRF
  2438. * @retval None
  2439. */
  2440. __STATIC_INLINE void LL_TIM_SetTriggerInput(TIM_TypeDef *TIMx, uint32_t TriggerInput)
  2441. {
  2442. MODIFY_REG(TIMx->SMCR, TIM_SMCR_TS, TriggerInput);
  2443. }
  2444. /**
  2445. * @brief Enable the Master/Slave mode.
  2446. * @note Macro @ref IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  2447. * a timer instance can operate as a slave timer.
  2448. * @rmtoll SMCR MSM LL_TIM_EnableMasterSlaveMode
  2449. * @param TIMx Timer instance
  2450. * @retval None
  2451. */
  2452. __STATIC_INLINE void LL_TIM_EnableMasterSlaveMode(TIM_TypeDef *TIMx)
  2453. {
  2454. SET_BIT(TIMx->SMCR, TIM_SMCR_MSM);
  2455. }
  2456. /**
  2457. * @brief Disable the Master/Slave mode.
  2458. * @note Macro @ref IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  2459. * a timer instance can operate as a slave timer.
  2460. * @rmtoll SMCR MSM LL_TIM_DisableMasterSlaveMode
  2461. * @param TIMx Timer instance
  2462. * @retval None
  2463. */
  2464. __STATIC_INLINE void LL_TIM_DisableMasterSlaveMode(TIM_TypeDef *TIMx)
  2465. {
  2466. CLEAR_BIT(TIMx->SMCR, TIM_SMCR_MSM);
  2467. }
  2468. /**
  2469. * @brief Indicates whether the Master/Slave mode is enabled.
  2470. * @note Macro @ref IS_TIM_SLAVE_INSTANCE(TIMx) can be used to check whether or not
  2471. * a timer instance can operate as a slave timer.
  2472. * @rmtoll SMCR MSM LL_TIM_IsEnabledMasterSlaveMode
  2473. * @param TIMx Timer instance
  2474. * @retval State of bit (1 or 0).
  2475. */
  2476. __STATIC_INLINE uint32_t LL_TIM_IsEnabledMasterSlaveMode(TIM_TypeDef *TIMx)
  2477. {
  2478. return (READ_BIT(TIMx->SMCR, TIM_SMCR_MSM) == (TIM_SMCR_MSM));
  2479. }
  2480. /**
  2481. * @brief Configure the external trigger (ETR) input.
  2482. * @note Macro @ref IS_TIM_ETR_INSTANCE(TIMx) can be used to check whether or not
  2483. * a timer instance provides an external trigger input.
  2484. * @rmtoll SMCR ETP LL_TIM_ConfigETR\n
  2485. * SMCR ETPS LL_TIM_ConfigETR\n
  2486. * SMCR ETF LL_TIM_ConfigETR
  2487. * @param TIMx Timer instance
  2488. * @param ETRPolarity This parameter can be one of the following values:
  2489. * @arg @ref LL_TIM_ETR_POLARITY_NONINVERTED
  2490. * @arg @ref LL_TIM_ETR_POLARITY_INVERTED
  2491. * @param ETRPrescaler This parameter can be one of the following values:
  2492. * @arg @ref LL_TIM_ETR_PRESCALER_DIV1
  2493. * @arg @ref LL_TIM_ETR_PRESCALER_DIV2
  2494. * @arg @ref LL_TIM_ETR_PRESCALER_DIV4
  2495. * @arg @ref LL_TIM_ETR_PRESCALER_DIV8
  2496. * @param ETRFilter This parameter can be one of the following values:
  2497. * @arg @ref LL_TIM_ETR_FILTER_FDIV1
  2498. * @arg @ref LL_TIM_ETR_FILTER_FDIV1_N2
  2499. * @arg @ref LL_TIM_ETR_FILTER_FDIV1_N4
  2500. * @arg @ref LL_TIM_ETR_FILTER_FDIV1_N8
  2501. * @arg @ref LL_TIM_ETR_FILTER_FDIV2_N6
  2502. * @arg @ref LL_TIM_ETR_FILTER_FDIV2_N8
  2503. * @arg @ref LL_TIM_ETR_FILTER_FDIV4_N6
  2504. * @arg @ref LL_TIM_ETR_FILTER_FDIV4_N8
  2505. * @arg @ref LL_TIM_ETR_FILTER_FDIV8_N6
  2506. * @arg @ref LL_TIM_ETR_FILTER_FDIV8_N8
  2507. * @arg @ref LL_TIM_ETR_FILTER_FDIV16_N5
  2508. * @arg @ref LL_TIM_ETR_FILTER_FDIV16_N6
  2509. * @arg @ref LL_TIM_ETR_FILTER_FDIV16_N8
  2510. * @arg @ref LL_TIM_ETR_FILTER_FDIV32_N5
  2511. * @arg @ref LL_TIM_ETR_FILTER_FDIV32_N6
  2512. * @arg @ref LL_TIM_ETR_FILTER_FDIV32_N8
  2513. * @retval None
  2514. */
  2515. __STATIC_INLINE void LL_TIM_ConfigETR(TIM_TypeDef *TIMx, uint32_t ETRPolarity, uint32_t ETRPrescaler,
  2516. uint32_t ETRFilter)
  2517. {
  2518. MODIFY_REG(TIMx->SMCR, TIM_SMCR_ETP | TIM_SMCR_ETPS | TIM_SMCR_ETF, ETRPolarity | ETRPrescaler | ETRFilter);
  2519. }
  2520. /**
  2521. * @}
  2522. */
  2523. /** @defgroup TIM_LL_EF_Break_Function Break function configuration
  2524. * @{
  2525. */
  2526. /**
  2527. * @brief Enable the break function.
  2528. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2529. * a timer instance provides a break input.
  2530. * @rmtoll BDTR BKE LL_TIM_EnableBRK
  2531. * @param TIMx Timer instance
  2532. * @retval None
  2533. */
  2534. __STATIC_INLINE void LL_TIM_EnableBRK(TIM_TypeDef *TIMx)
  2535. {
  2536. SET_BIT(TIMx->BDTR, TIM_BDTR_BKE);
  2537. }
  2538. /**
  2539. * @brief Disable the break function.
  2540. * @rmtoll BDTR BKE LL_TIM_DisableBRK
  2541. * @param TIMx Timer instance
  2542. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2543. * a timer instance provides a break input.
  2544. * @retval None
  2545. */
  2546. __STATIC_INLINE void LL_TIM_DisableBRK(TIM_TypeDef *TIMx)
  2547. {
  2548. CLEAR_BIT(TIMx->BDTR, TIM_BDTR_BKE);
  2549. }
  2550. /**
  2551. * @brief Configure the break input.
  2552. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2553. * a timer instance provides a break input.
  2554. * @rmtoll BDTR BKP LL_TIM_ConfigBRK
  2555. * @param TIMx Timer instance
  2556. * @param BreakPolarity This parameter can be one of the following values:
  2557. * @arg @ref LL_TIM_BREAK_POLARITY_LOW
  2558. * @arg @ref LL_TIM_BREAK_POLARITY_HIGH
  2559. * @retval None
  2560. */
  2561. __STATIC_INLINE void LL_TIM_ConfigBRK(TIM_TypeDef *TIMx, uint32_t BreakPolarity)
  2562. {
  2563. MODIFY_REG(TIMx->BDTR, TIM_BDTR_BKP, BreakPolarity);
  2564. }
  2565. /**
  2566. * @brief Select the outputs off state (enabled v.s. disabled) in Idle and Run modes.
  2567. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2568. * a timer instance provides a break input.
  2569. * @rmtoll BDTR OSSI LL_TIM_SetOffStates\n
  2570. * BDTR OSSR LL_TIM_SetOffStates
  2571. * @param TIMx Timer instance
  2572. * @param OffStateIdle This parameter can be one of the following values:
  2573. * @arg @ref LL_TIM_OSSI_DISABLE
  2574. * @arg @ref LL_TIM_OSSI_ENABLE
  2575. * @param OffStateRun This parameter can be one of the following values:
  2576. * @arg @ref LL_TIM_OSSR_DISABLE
  2577. * @arg @ref LL_TIM_OSSR_ENABLE
  2578. * @retval None
  2579. */
  2580. __STATIC_INLINE void LL_TIM_SetOffStates(TIM_TypeDef *TIMx, uint32_t OffStateIdle, uint32_t OffStateRun)
  2581. {
  2582. MODIFY_REG(TIMx->BDTR, TIM_BDTR_OSSI | TIM_BDTR_OSSR, OffStateIdle | OffStateRun);
  2583. }
  2584. /**
  2585. * @brief Enable automatic output (MOE can be set by software or automatically when a break input is active).
  2586. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2587. * a timer instance provides a break input.
  2588. * @rmtoll BDTR AOE LL_TIM_EnableAutomaticOutput
  2589. * @param TIMx Timer instance
  2590. * @retval None
  2591. */
  2592. __STATIC_INLINE void LL_TIM_EnableAutomaticOutput(TIM_TypeDef *TIMx)
  2593. {
  2594. SET_BIT(TIMx->BDTR, TIM_BDTR_AOE);
  2595. }
  2596. /**
  2597. * @brief Disable automatic output (MOE can be set only by software).
  2598. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2599. * a timer instance provides a break input.
  2600. * @rmtoll BDTR AOE LL_TIM_DisableAutomaticOutput
  2601. * @param TIMx Timer instance
  2602. * @retval None
  2603. */
  2604. __STATIC_INLINE void LL_TIM_DisableAutomaticOutput(TIM_TypeDef *TIMx)
  2605. {
  2606. CLEAR_BIT(TIMx->BDTR, TIM_BDTR_AOE);
  2607. }
  2608. /**
  2609. * @brief Indicate whether automatic output is enabled.
  2610. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2611. * a timer instance provides a break input.
  2612. * @rmtoll BDTR AOE LL_TIM_IsEnabledAutomaticOutput
  2613. * @param TIMx Timer instance
  2614. * @retval State of bit (1 or 0).
  2615. */
  2616. __STATIC_INLINE uint32_t LL_TIM_IsEnabledAutomaticOutput(TIM_TypeDef *TIMx)
  2617. {
  2618. return (READ_BIT(TIMx->BDTR, TIM_BDTR_AOE) == (TIM_BDTR_AOE));
  2619. }
  2620. /**
  2621. * @brief Enable the outputs (set the MOE bit in TIMx_BDTR register).
  2622. * @note The MOE bit in TIMx_BDTR register allows to enable /disable the outputs by
  2623. * software and is reset in case of break or break2 event
  2624. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2625. * a timer instance provides a break input.
  2626. * @rmtoll BDTR MOE LL_TIM_EnableAllOutputs
  2627. * @param TIMx Timer instance
  2628. * @retval None
  2629. */
  2630. __STATIC_INLINE void LL_TIM_EnableAllOutputs(TIM_TypeDef *TIMx)
  2631. {
  2632. SET_BIT(TIMx->BDTR, TIM_BDTR_MOE);
  2633. }
  2634. /**
  2635. * @brief Disable the outputs (reset the MOE bit in TIMx_BDTR register).
  2636. * @note The MOE bit in TIMx_BDTR register allows to enable /disable the outputs by
  2637. * software and is reset in case of break or break2 event.
  2638. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2639. * a timer instance provides a break input.
  2640. * @rmtoll BDTR MOE LL_TIM_DisableAllOutputs
  2641. * @param TIMx Timer instance
  2642. * @retval None
  2643. */
  2644. __STATIC_INLINE void LL_TIM_DisableAllOutputs(TIM_TypeDef *TIMx)
  2645. {
  2646. CLEAR_BIT(TIMx->BDTR, TIM_BDTR_MOE);
  2647. }
  2648. /**
  2649. * @brief Indicates whether outputs are enabled.
  2650. * @note Macro @ref IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
  2651. * a timer instance provides a break input.
  2652. * @rmtoll BDTR MOE LL_TIM_IsEnabledAllOutputs
  2653. * @param TIMx Timer instance
  2654. * @retval State of bit (1 or 0).
  2655. */
  2656. __STATIC_INLINE uint32_t LL_TIM_IsEnabledAllOutputs(TIM_TypeDef *TIMx)
  2657. {
  2658. return (READ_BIT(TIMx->BDTR, TIM_BDTR_MOE) == (TIM_BDTR_MOE));
  2659. }
  2660. /**
  2661. * @}
  2662. */
  2663. /** @defgroup TIM_LL_EF_DMA_Burst_Mode DMA burst mode configuration
  2664. * @{
  2665. */
  2666. /**
  2667. * @brief Configures the timer DMA burst feature.
  2668. * @note Macro @ref IS_TIM_DMABURST_INSTANCE(TIMx) can be used to check whether or
  2669. * not a timer instance supports the DMA burst mode.
  2670. * @rmtoll DCR DBL LL_TIM_ConfigDMABurst\n
  2671. * DCR DBA LL_TIM_ConfigDMABurst
  2672. * @param TIMx Timer instance
  2673. * @param DMABurstBaseAddress This parameter can be one of the following values:
  2674. * @arg @ref LL_TIM_DMABURST_BASEADDR_CR1
  2675. * @arg @ref LL_TIM_DMABURST_BASEADDR_CR2
  2676. * @arg @ref LL_TIM_DMABURST_BASEADDR_SMCR
  2677. * @arg @ref LL_TIM_DMABURST_BASEADDR_DIER
  2678. * @arg @ref LL_TIM_DMABURST_BASEADDR_SR
  2679. * @arg @ref LL_TIM_DMABURST_BASEADDR_EGR
  2680. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCMR1
  2681. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCMR2
  2682. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCER
  2683. * @arg @ref LL_TIM_DMABURST_BASEADDR_CNT
  2684. * @arg @ref LL_TIM_DMABURST_BASEADDR_PSC
  2685. * @arg @ref LL_TIM_DMABURST_BASEADDR_ARR
  2686. * @arg @ref LL_TIM_DMABURST_BASEADDR_RCR
  2687. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR1
  2688. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR2
  2689. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR3
  2690. * @arg @ref LL_TIM_DMABURST_BASEADDR_CCR4
  2691. * @arg @ref LL_TIM_DMABURST_BASEADDR_BDTR
  2692. * @arg @ref LL_TIM_DMABURST_BASEADDR_OR
  2693. * @param DMABurstLength This parameter can be one of the following values:
  2694. * @arg @ref LL_TIM_DMABURST_LENGTH_1TRANSFER
  2695. * @arg @ref LL_TIM_DMABURST_LENGTH_2TRANSFERS
  2696. * @arg @ref LL_TIM_DMABURST_LENGTH_3TRANSFERS
  2697. * @arg @ref LL_TIM_DMABURST_LENGTH_4TRANSFERS
  2698. * @arg @ref LL_TIM_DMABURST_LENGTH_5TRANSFERS
  2699. * @arg @ref LL_TIM_DMABURST_LENGTH_6TRANSFERS
  2700. * @arg @ref LL_TIM_DMABURST_LENGTH_7TRANSFERS
  2701. * @arg @ref LL_TIM_DMABURST_LENGTH_8TRANSFERS
  2702. * @arg @ref LL_TIM_DMABURST_LENGTH_9TRANSFERS
  2703. * @arg @ref LL_TIM_DMABURST_LENGTH_10TRANSFERS
  2704. * @arg @ref LL_TIM_DMABURST_LENGTH_11TRANSFERS
  2705. * @arg @ref LL_TIM_DMABURST_LENGTH_12TRANSFERS
  2706. * @arg @ref LL_TIM_DMABURST_LENGTH_13TRANSFERS
  2707. * @arg @ref LL_TIM_DMABURST_LENGTH_14TRANSFERS
  2708. * @arg @ref LL_TIM_DMABURST_LENGTH_15TRANSFERS
  2709. * @arg @ref LL_TIM_DMABURST_LENGTH_16TRANSFERS
  2710. * @arg @ref LL_TIM_DMABURST_LENGTH_17TRANSFERS
  2711. * @arg @ref LL_TIM_DMABURST_LENGTH_18TRANSFERS
  2712. * @retval None
  2713. */
  2714. __STATIC_INLINE void LL_TIM_ConfigDMABurst(TIM_TypeDef *TIMx, uint32_t DMABurstBaseAddress, uint32_t DMABurstLength)
  2715. {
  2716. MODIFY_REG(TIMx->DCR, TIM_DCR_DBL | TIM_DCR_DBA, DMABurstBaseAddress | DMABurstLength);
  2717. }
  2718. /**
  2719. * @}
  2720. */
  2721. /** @defgroup TIM_LL_EF_Timer_Inputs_Remapping Timer input remapping
  2722. * @{
  2723. */
  2724. /**
  2725. * @brief Remap TIM inputs (input channel, internal/external triggers).
  2726. * @note Macro @ref IS_TIM_REMAP_INSTANCE(TIMx) can be used to check whether or not
  2727. * a some timer inputs can be remapped.
  2728. * @rmtoll TIM2_OR ITR1_RMP LL_TIM_SetRemap\n
  2729. * TIM5_OR TI4_RMP LL_TIM_SetRemap\n
  2730. * TIM11_OR TI1_RMP LL_TIM_SetRemap
  2731. * @param TIMx Timer instance
  2732. * @param Remap Remap param depends on the TIMx. Description available only
  2733. * in CHM version of the User Manual (not in .pdf).
  2734. * Otherwise see Reference Manual description of OR registers.
  2735. *
  2736. * Below description summarizes "Timer Instance" and "Remap" param combinations:
  2737. *
  2738. * TIM2: one of the following values
  2739. *
  2740. * ITR1_RMP can be one of the following values
  2741. * @arg @ref LL_TIM_TIM2_ITR1_RMP_TIM8_TRGO
  2742. * @arg @ref LL_TIM_TIM2_ITR1_RMP_OTG_FS_SOF
  2743. * @arg @ref LL_TIM_TIM2_ITR1_RMP_OTG_HS_SOF
  2744. *
  2745. * TIM5: one of the following values
  2746. *
  2747. * @arg @ref LL_TIM_TIM5_TI4_RMP_GPIO
  2748. * @arg @ref LL_TIM_TIM5_TI4_RMP_LSI
  2749. * @arg @ref LL_TIM_TIM5_TI4_RMP_LSE
  2750. * @arg @ref LL_TIM_TIM5_TI4_RMP_RTC
  2751. *
  2752. * TIM11: one of the following values
  2753. *
  2754. * @arg @ref LL_TIM_TIM11_TI1_RMP_GPIO
  2755. * @arg @ref LL_TIM_TIM11_TI1_RMP_GPIO1
  2756. * @arg @ref LL_TIM_TIM11_TI1_RMP_HSE_RTC
  2757. * @arg @ref LL_TIM_TIM11_TI1_RMP_GPIO2
  2758. *
  2759. * @retval None
  2760. */
  2761. __STATIC_INLINE void LL_TIM_SetRemap(TIM_TypeDef *TIMx, uint32_t Remap)
  2762. {
  2763. MODIFY_REG(TIMx->OR, (Remap >> TIMx_OR_RMP_SHIFT), (Remap & TIMx_OR_RMP_MASK));
  2764. }
  2765. /**
  2766. * @}
  2767. */
  2768. /** @defgroup TIM_LL_EF_FLAG_Management FLAG-Management
  2769. * @{
  2770. */
  2771. /**
  2772. * @brief Clear the update interrupt flag (UIF).
  2773. * @rmtoll SR UIF LL_TIM_ClearFlag_UPDATE
  2774. * @param TIMx Timer instance
  2775. * @retval None
  2776. */
  2777. __STATIC_INLINE void LL_TIM_ClearFlag_UPDATE(TIM_TypeDef *TIMx)
  2778. {
  2779. WRITE_REG(TIMx->SR, ~(TIM_SR_UIF));
  2780. }
  2781. /**
  2782. * @brief Indicate whether update interrupt flag (UIF) is set (update interrupt is pending).
  2783. * @rmtoll SR UIF LL_TIM_IsActiveFlag_UPDATE
  2784. * @param TIMx Timer instance
  2785. * @retval State of bit (1 or 0).
  2786. */
  2787. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_UPDATE(TIM_TypeDef *TIMx)
  2788. {
  2789. return (READ_BIT(TIMx->SR, TIM_SR_UIF) == (TIM_SR_UIF));
  2790. }
  2791. /**
  2792. * @brief Clear the Capture/Compare 1 interrupt flag (CC1F).
  2793. * @rmtoll SR CC1IF LL_TIM_ClearFlag_CC1
  2794. * @param TIMx Timer instance
  2795. * @retval None
  2796. */
  2797. __STATIC_INLINE void LL_TIM_ClearFlag_CC1(TIM_TypeDef *TIMx)
  2798. {
  2799. WRITE_REG(TIMx->SR, ~(TIM_SR_CC1IF));
  2800. }
  2801. /**
  2802. * @brief Indicate whether Capture/Compare 1 interrupt flag (CC1F) is set (Capture/Compare 1 interrupt is pending).
  2803. * @rmtoll SR CC1IF LL_TIM_IsActiveFlag_CC1
  2804. * @param TIMx Timer instance
  2805. * @retval State of bit (1 or 0).
  2806. */
  2807. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC1(TIM_TypeDef *TIMx)
  2808. {
  2809. return (READ_BIT(TIMx->SR, TIM_SR_CC1IF) == (TIM_SR_CC1IF));
  2810. }
  2811. /**
  2812. * @brief Clear the Capture/Compare 2 interrupt flag (CC2F).
  2813. * @rmtoll SR CC2IF LL_TIM_ClearFlag_CC2
  2814. * @param TIMx Timer instance
  2815. * @retval None
  2816. */
  2817. __STATIC_INLINE void LL_TIM_ClearFlag_CC2(TIM_TypeDef *TIMx)
  2818. {
  2819. WRITE_REG(TIMx->SR, ~(TIM_SR_CC2IF));
  2820. }
  2821. /**
  2822. * @brief Indicate whether Capture/Compare 2 interrupt flag (CC2F) is set (Capture/Compare 2 interrupt is pending).
  2823. * @rmtoll SR CC2IF LL_TIM_IsActiveFlag_CC2
  2824. * @param TIMx Timer instance
  2825. * @retval State of bit (1 or 0).
  2826. */
  2827. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC2(TIM_TypeDef *TIMx)
  2828. {
  2829. return (READ_BIT(TIMx->SR, TIM_SR_CC2IF) == (TIM_SR_CC2IF));
  2830. }
  2831. /**
  2832. * @brief Clear the Capture/Compare 3 interrupt flag (CC3F).
  2833. * @rmtoll SR CC3IF LL_TIM_ClearFlag_CC3
  2834. * @param TIMx Timer instance
  2835. * @retval None
  2836. */
  2837. __STATIC_INLINE void LL_TIM_ClearFlag_CC3(TIM_TypeDef *TIMx)
  2838. {
  2839. WRITE_REG(TIMx->SR, ~(TIM_SR_CC3IF));
  2840. }
  2841. /**
  2842. * @brief Indicate whether Capture/Compare 3 interrupt flag (CC3F) is set (Capture/Compare 3 interrupt is pending).
  2843. * @rmtoll SR CC3IF LL_TIM_IsActiveFlag_CC3
  2844. * @param TIMx Timer instance
  2845. * @retval State of bit (1 or 0).
  2846. */
  2847. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC3(TIM_TypeDef *TIMx)
  2848. {
  2849. return (READ_BIT(TIMx->SR, TIM_SR_CC3IF) == (TIM_SR_CC3IF));
  2850. }
  2851. /**
  2852. * @brief Clear the Capture/Compare 4 interrupt flag (CC4F).
  2853. * @rmtoll SR CC4IF LL_TIM_ClearFlag_CC4
  2854. * @param TIMx Timer instance
  2855. * @retval None
  2856. */
  2857. __STATIC_INLINE void LL_TIM_ClearFlag_CC4(TIM_TypeDef *TIMx)
  2858. {
  2859. WRITE_REG(TIMx->SR, ~(TIM_SR_CC4IF));
  2860. }
  2861. /**
  2862. * @brief Indicate whether Capture/Compare 4 interrupt flag (CC4F) is set (Capture/Compare 4 interrupt is pending).
  2863. * @rmtoll SR CC4IF LL_TIM_IsActiveFlag_CC4
  2864. * @param TIMx Timer instance
  2865. * @retval State of bit (1 or 0).
  2866. */
  2867. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC4(TIM_TypeDef *TIMx)
  2868. {
  2869. return (READ_BIT(TIMx->SR, TIM_SR_CC4IF) == (TIM_SR_CC4IF));
  2870. }
  2871. /**
  2872. * @brief Clear the commutation interrupt flag (COMIF).
  2873. * @rmtoll SR COMIF LL_TIM_ClearFlag_COM
  2874. * @param TIMx Timer instance
  2875. * @retval None
  2876. */
  2877. __STATIC_INLINE void LL_TIM_ClearFlag_COM(TIM_TypeDef *TIMx)
  2878. {
  2879. WRITE_REG(TIMx->SR, ~(TIM_SR_COMIF));
  2880. }
  2881. /**
  2882. * @brief Indicate whether commutation interrupt flag (COMIF) is set (commutation interrupt is pending).
  2883. * @rmtoll SR COMIF LL_TIM_IsActiveFlag_COM
  2884. * @param TIMx Timer instance
  2885. * @retval State of bit (1 or 0).
  2886. */
  2887. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_COM(TIM_TypeDef *TIMx)
  2888. {
  2889. return (READ_BIT(TIMx->SR, TIM_SR_COMIF) == (TIM_SR_COMIF));
  2890. }
  2891. /**
  2892. * @brief Clear the trigger interrupt flag (TIF).
  2893. * @rmtoll SR TIF LL_TIM_ClearFlag_TRIG
  2894. * @param TIMx Timer instance
  2895. * @retval None
  2896. */
  2897. __STATIC_INLINE void LL_TIM_ClearFlag_TRIG(TIM_TypeDef *TIMx)
  2898. {
  2899. WRITE_REG(TIMx->SR, ~(TIM_SR_TIF));
  2900. }
  2901. /**
  2902. * @brief Indicate whether trigger interrupt flag (TIF) is set (trigger interrupt is pending).
  2903. * @rmtoll SR TIF LL_TIM_IsActiveFlag_TRIG
  2904. * @param TIMx Timer instance
  2905. * @retval State of bit (1 or 0).
  2906. */
  2907. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_TRIG(TIM_TypeDef *TIMx)
  2908. {
  2909. return (READ_BIT(TIMx->SR, TIM_SR_TIF) == (TIM_SR_TIF));
  2910. }
  2911. /**
  2912. * @brief Clear the break interrupt flag (BIF).
  2913. * @rmtoll SR BIF LL_TIM_ClearFlag_BRK
  2914. * @param TIMx Timer instance
  2915. * @retval None
  2916. */
  2917. __STATIC_INLINE void LL_TIM_ClearFlag_BRK(TIM_TypeDef *TIMx)
  2918. {
  2919. WRITE_REG(TIMx->SR, ~(TIM_SR_BIF));
  2920. }
  2921. /**
  2922. * @brief Indicate whether break interrupt flag (BIF) is set (break interrupt is pending).
  2923. * @rmtoll SR BIF LL_TIM_IsActiveFlag_BRK
  2924. * @param TIMx Timer instance
  2925. * @retval State of bit (1 or 0).
  2926. */
  2927. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_BRK(TIM_TypeDef *TIMx)
  2928. {
  2929. return (READ_BIT(TIMx->SR, TIM_SR_BIF) == (TIM_SR_BIF));
  2930. }
  2931. /**
  2932. * @brief Clear the Capture/Compare 1 over-capture interrupt flag (CC1OF).
  2933. * @rmtoll SR CC1OF LL_TIM_ClearFlag_CC1OVR
  2934. * @param TIMx Timer instance
  2935. * @retval None
  2936. */
  2937. __STATIC_INLINE void LL_TIM_ClearFlag_CC1OVR(TIM_TypeDef *TIMx)
  2938. {
  2939. WRITE_REG(TIMx->SR, ~(TIM_SR_CC1OF));
  2940. }
  2941. /**
  2942. * @brief Indicate whether Capture/Compare 1 over-capture interrupt flag (CC1OF) is set (Capture/Compare 1 interrupt is pending).
  2943. * @rmtoll SR CC1OF LL_TIM_IsActiveFlag_CC1OVR
  2944. * @param TIMx Timer instance
  2945. * @retval State of bit (1 or 0).
  2946. */
  2947. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC1OVR(TIM_TypeDef *TIMx)
  2948. {
  2949. return (READ_BIT(TIMx->SR, TIM_SR_CC1OF) == (TIM_SR_CC1OF));
  2950. }
  2951. /**
  2952. * @brief Clear the Capture/Compare 2 over-capture interrupt flag (CC2OF).
  2953. * @rmtoll SR CC2OF LL_TIM_ClearFlag_CC2OVR
  2954. * @param TIMx Timer instance
  2955. * @retval None
  2956. */
  2957. __STATIC_INLINE void LL_TIM_ClearFlag_CC2OVR(TIM_TypeDef *TIMx)
  2958. {
  2959. WRITE_REG(TIMx->SR, ~(TIM_SR_CC2OF));
  2960. }
  2961. /**
  2962. * @brief Indicate whether Capture/Compare 2 over-capture interrupt flag (CC2OF) is set (Capture/Compare 2 over-capture interrupt is pending).
  2963. * @rmtoll SR CC2OF LL_TIM_IsActiveFlag_CC2OVR
  2964. * @param TIMx Timer instance
  2965. * @retval State of bit (1 or 0).
  2966. */
  2967. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC2OVR(TIM_TypeDef *TIMx)
  2968. {
  2969. return (READ_BIT(TIMx->SR, TIM_SR_CC2OF) == (TIM_SR_CC2OF));
  2970. }
  2971. /**
  2972. * @brief Clear the Capture/Compare 3 over-capture interrupt flag (CC3OF).
  2973. * @rmtoll SR CC3OF LL_TIM_ClearFlag_CC3OVR
  2974. * @param TIMx Timer instance
  2975. * @retval None
  2976. */
  2977. __STATIC_INLINE void LL_TIM_ClearFlag_CC3OVR(TIM_TypeDef *TIMx)
  2978. {
  2979. WRITE_REG(TIMx->SR, ~(TIM_SR_CC3OF));
  2980. }
  2981. /**
  2982. * @brief Indicate whether Capture/Compare 3 over-capture interrupt flag (CC3OF) is set (Capture/Compare 3 over-capture interrupt is pending).
  2983. * @rmtoll SR CC3OF LL_TIM_IsActiveFlag_CC3OVR
  2984. * @param TIMx Timer instance
  2985. * @retval State of bit (1 or 0).
  2986. */
  2987. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC3OVR(TIM_TypeDef *TIMx)
  2988. {
  2989. return (READ_BIT(TIMx->SR, TIM_SR_CC3OF) == (TIM_SR_CC3OF));
  2990. }
  2991. /**
  2992. * @brief Clear the Capture/Compare 4 over-capture interrupt flag (CC4OF).
  2993. * @rmtoll SR CC4OF LL_TIM_ClearFlag_CC4OVR
  2994. * @param TIMx Timer instance
  2995. * @retval None
  2996. */
  2997. __STATIC_INLINE void LL_TIM_ClearFlag_CC4OVR(TIM_TypeDef *TIMx)
  2998. {
  2999. WRITE_REG(TIMx->SR, ~(TIM_SR_CC4OF));
  3000. }
  3001. /**
  3002. * @brief Indicate whether Capture/Compare 4 over-capture interrupt flag (CC4OF) is set (Capture/Compare 4 over-capture interrupt is pending).
  3003. * @rmtoll SR CC4OF LL_TIM_IsActiveFlag_CC4OVR
  3004. * @param TIMx Timer instance
  3005. * @retval State of bit (1 or 0).
  3006. */
  3007. __STATIC_INLINE uint32_t LL_TIM_IsActiveFlag_CC4OVR(TIM_TypeDef *TIMx)
  3008. {
  3009. return (READ_BIT(TIMx->SR, TIM_SR_CC4OF) == (TIM_SR_CC4OF));
  3010. }
  3011. /**
  3012. * @}
  3013. */
  3014. /** @defgroup TIM_LL_EF_IT_Management IT-Management
  3015. * @{
  3016. */
  3017. /**
  3018. * @brief Enable update interrupt (UIE).
  3019. * @rmtoll DIER UIE LL_TIM_EnableIT_UPDATE
  3020. * @param TIMx Timer instance
  3021. * @retval None
  3022. */
  3023. __STATIC_INLINE void LL_TIM_EnableIT_UPDATE(TIM_TypeDef *TIMx)
  3024. {
  3025. SET_BIT(TIMx->DIER, TIM_DIER_UIE);
  3026. }
  3027. /**
  3028. * @brief Disable update interrupt (UIE).
  3029. * @rmtoll DIER UIE LL_TIM_DisableIT_UPDATE
  3030. * @param TIMx Timer instance
  3031. * @retval None
  3032. */
  3033. __STATIC_INLINE void LL_TIM_DisableIT_UPDATE(TIM_TypeDef *TIMx)
  3034. {
  3035. CLEAR_BIT(TIMx->DIER, TIM_DIER_UIE);
  3036. }
  3037. /**
  3038. * @brief Indicates whether the update interrupt (UIE) is enabled.
  3039. * @rmtoll DIER UIE LL_TIM_IsEnabledIT_UPDATE
  3040. * @param TIMx Timer instance
  3041. * @retval State of bit (1 or 0).
  3042. */
  3043. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_UPDATE(TIM_TypeDef *TIMx)
  3044. {
  3045. return (READ_BIT(TIMx->DIER, TIM_DIER_UIE) == (TIM_DIER_UIE));
  3046. }
  3047. /**
  3048. * @brief Enable capture/compare 1 interrupt (CC1IE).
  3049. * @rmtoll DIER CC1IE LL_TIM_EnableIT_CC1
  3050. * @param TIMx Timer instance
  3051. * @retval None
  3052. */
  3053. __STATIC_INLINE void LL_TIM_EnableIT_CC1(TIM_TypeDef *TIMx)
  3054. {
  3055. SET_BIT(TIMx->DIER, TIM_DIER_CC1IE);
  3056. }
  3057. /**
  3058. * @brief Disable capture/compare 1 interrupt (CC1IE).
  3059. * @rmtoll DIER CC1IE LL_TIM_DisableIT_CC1
  3060. * @param TIMx Timer instance
  3061. * @retval None
  3062. */
  3063. __STATIC_INLINE void LL_TIM_DisableIT_CC1(TIM_TypeDef *TIMx)
  3064. {
  3065. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC1IE);
  3066. }
  3067. /**
  3068. * @brief Indicates whether the capture/compare 1 interrupt (CC1IE) is enabled.
  3069. * @rmtoll DIER CC1IE LL_TIM_IsEnabledIT_CC1
  3070. * @param TIMx Timer instance
  3071. * @retval State of bit (1 or 0).
  3072. */
  3073. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC1(TIM_TypeDef *TIMx)
  3074. {
  3075. return (READ_BIT(TIMx->DIER, TIM_DIER_CC1IE) == (TIM_DIER_CC1IE));
  3076. }
  3077. /**
  3078. * @brief Enable capture/compare 2 interrupt (CC2IE).
  3079. * @rmtoll DIER CC2IE LL_TIM_EnableIT_CC2
  3080. * @param TIMx Timer instance
  3081. * @retval None
  3082. */
  3083. __STATIC_INLINE void LL_TIM_EnableIT_CC2(TIM_TypeDef *TIMx)
  3084. {
  3085. SET_BIT(TIMx->DIER, TIM_DIER_CC2IE);
  3086. }
  3087. /**
  3088. * @brief Disable capture/compare 2 interrupt (CC2IE).
  3089. * @rmtoll DIER CC2IE LL_TIM_DisableIT_CC2
  3090. * @param TIMx Timer instance
  3091. * @retval None
  3092. */
  3093. __STATIC_INLINE void LL_TIM_DisableIT_CC2(TIM_TypeDef *TIMx)
  3094. {
  3095. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC2IE);
  3096. }
  3097. /**
  3098. * @brief Indicates whether the capture/compare 2 interrupt (CC2IE) is enabled.
  3099. * @rmtoll DIER CC2IE LL_TIM_IsEnabledIT_CC2
  3100. * @param TIMx Timer instance
  3101. * @retval State of bit (1 or 0).
  3102. */
  3103. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC2(TIM_TypeDef *TIMx)
  3104. {
  3105. return (READ_BIT(TIMx->DIER, TIM_DIER_CC2IE) == (TIM_DIER_CC2IE));
  3106. }
  3107. /**
  3108. * @brief Enable capture/compare 3 interrupt (CC3IE).
  3109. * @rmtoll DIER CC3IE LL_TIM_EnableIT_CC3
  3110. * @param TIMx Timer instance
  3111. * @retval None
  3112. */
  3113. __STATIC_INLINE void LL_TIM_EnableIT_CC3(TIM_TypeDef *TIMx)
  3114. {
  3115. SET_BIT(TIMx->DIER, TIM_DIER_CC3IE);
  3116. }
  3117. /**
  3118. * @brief Disable capture/compare 3 interrupt (CC3IE).
  3119. * @rmtoll DIER CC3IE LL_TIM_DisableIT_CC3
  3120. * @param TIMx Timer instance
  3121. * @retval None
  3122. */
  3123. __STATIC_INLINE void LL_TIM_DisableIT_CC3(TIM_TypeDef *TIMx)
  3124. {
  3125. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC3IE);
  3126. }
  3127. /**
  3128. * @brief Indicates whether the capture/compare 3 interrupt (CC3IE) is enabled.
  3129. * @rmtoll DIER CC3IE LL_TIM_IsEnabledIT_CC3
  3130. * @param TIMx Timer instance
  3131. * @retval State of bit (1 or 0).
  3132. */
  3133. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC3(TIM_TypeDef *TIMx)
  3134. {
  3135. return (READ_BIT(TIMx->DIER, TIM_DIER_CC3IE) == (TIM_DIER_CC3IE));
  3136. }
  3137. /**
  3138. * @brief Enable capture/compare 4 interrupt (CC4IE).
  3139. * @rmtoll DIER CC4IE LL_TIM_EnableIT_CC4
  3140. * @param TIMx Timer instance
  3141. * @retval None
  3142. */
  3143. __STATIC_INLINE void LL_TIM_EnableIT_CC4(TIM_TypeDef *TIMx)
  3144. {
  3145. SET_BIT(TIMx->DIER, TIM_DIER_CC4IE);
  3146. }
  3147. /**
  3148. * @brief Disable capture/compare 4 interrupt (CC4IE).
  3149. * @rmtoll DIER CC4IE LL_TIM_DisableIT_CC4
  3150. * @param TIMx Timer instance
  3151. * @retval None
  3152. */
  3153. __STATIC_INLINE void LL_TIM_DisableIT_CC4(TIM_TypeDef *TIMx)
  3154. {
  3155. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC4IE);
  3156. }
  3157. /**
  3158. * @brief Indicates whether the capture/compare 4 interrupt (CC4IE) is enabled.
  3159. * @rmtoll DIER CC4IE LL_TIM_IsEnabledIT_CC4
  3160. * @param TIMx Timer instance
  3161. * @retval State of bit (1 or 0).
  3162. */
  3163. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_CC4(TIM_TypeDef *TIMx)
  3164. {
  3165. return (READ_BIT(TIMx->DIER, TIM_DIER_CC4IE) == (TIM_DIER_CC4IE));
  3166. }
  3167. /**
  3168. * @brief Enable commutation interrupt (COMIE).
  3169. * @rmtoll DIER COMIE LL_TIM_EnableIT_COM
  3170. * @param TIMx Timer instance
  3171. * @retval None
  3172. */
  3173. __STATIC_INLINE void LL_TIM_EnableIT_COM(TIM_TypeDef *TIMx)
  3174. {
  3175. SET_BIT(TIMx->DIER, TIM_DIER_COMIE);
  3176. }
  3177. /**
  3178. * @brief Disable commutation interrupt (COMIE).
  3179. * @rmtoll DIER COMIE LL_TIM_DisableIT_COM
  3180. * @param TIMx Timer instance
  3181. * @retval None
  3182. */
  3183. __STATIC_INLINE void LL_TIM_DisableIT_COM(TIM_TypeDef *TIMx)
  3184. {
  3185. CLEAR_BIT(TIMx->DIER, TIM_DIER_COMIE);
  3186. }
  3187. /**
  3188. * @brief Indicates whether the commutation interrupt (COMIE) is enabled.
  3189. * @rmtoll DIER COMIE LL_TIM_IsEnabledIT_COM
  3190. * @param TIMx Timer instance
  3191. * @retval State of bit (1 or 0).
  3192. */
  3193. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_COM(TIM_TypeDef *TIMx)
  3194. {
  3195. return (READ_BIT(TIMx->DIER, TIM_DIER_COMIE) == (TIM_DIER_COMIE));
  3196. }
  3197. /**
  3198. * @brief Enable trigger interrupt (TIE).
  3199. * @rmtoll DIER TIE LL_TIM_EnableIT_TRIG
  3200. * @param TIMx Timer instance
  3201. * @retval None
  3202. */
  3203. __STATIC_INLINE void LL_TIM_EnableIT_TRIG(TIM_TypeDef *TIMx)
  3204. {
  3205. SET_BIT(TIMx->DIER, TIM_DIER_TIE);
  3206. }
  3207. /**
  3208. * @brief Disable trigger interrupt (TIE).
  3209. * @rmtoll DIER TIE LL_TIM_DisableIT_TRIG
  3210. * @param TIMx Timer instance
  3211. * @retval None
  3212. */
  3213. __STATIC_INLINE void LL_TIM_DisableIT_TRIG(TIM_TypeDef *TIMx)
  3214. {
  3215. CLEAR_BIT(TIMx->DIER, TIM_DIER_TIE);
  3216. }
  3217. /**
  3218. * @brief Indicates whether the trigger interrupt (TIE) is enabled.
  3219. * @rmtoll DIER TIE LL_TIM_IsEnabledIT_TRIG
  3220. * @param TIMx Timer instance
  3221. * @retval State of bit (1 or 0).
  3222. */
  3223. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_TRIG(TIM_TypeDef *TIMx)
  3224. {
  3225. return (READ_BIT(TIMx->DIER, TIM_DIER_TIE) == (TIM_DIER_TIE));
  3226. }
  3227. /**
  3228. * @brief Enable break interrupt (BIE).
  3229. * @rmtoll DIER BIE LL_TIM_EnableIT_BRK
  3230. * @param TIMx Timer instance
  3231. * @retval None
  3232. */
  3233. __STATIC_INLINE void LL_TIM_EnableIT_BRK(TIM_TypeDef *TIMx)
  3234. {
  3235. SET_BIT(TIMx->DIER, TIM_DIER_BIE);
  3236. }
  3237. /**
  3238. * @brief Disable break interrupt (BIE).
  3239. * @rmtoll DIER BIE LL_TIM_DisableIT_BRK
  3240. * @param TIMx Timer instance
  3241. * @retval None
  3242. */
  3243. __STATIC_INLINE void LL_TIM_DisableIT_BRK(TIM_TypeDef *TIMx)
  3244. {
  3245. CLEAR_BIT(TIMx->DIER, TIM_DIER_BIE);
  3246. }
  3247. /**
  3248. * @brief Indicates whether the break interrupt (BIE) is enabled.
  3249. * @rmtoll DIER BIE LL_TIM_IsEnabledIT_BRK
  3250. * @param TIMx Timer instance
  3251. * @retval State of bit (1 or 0).
  3252. */
  3253. __STATIC_INLINE uint32_t LL_TIM_IsEnabledIT_BRK(TIM_TypeDef *TIMx)
  3254. {
  3255. return (READ_BIT(TIMx->DIER, TIM_DIER_BIE) == (TIM_DIER_BIE));
  3256. }
  3257. /**
  3258. * @}
  3259. */
  3260. /** @defgroup TIM_LL_EF_DMA_Management DMA-Management
  3261. * @{
  3262. */
  3263. /**
  3264. * @brief Enable update DMA request (UDE).
  3265. * @rmtoll DIER UDE LL_TIM_EnableDMAReq_UPDATE
  3266. * @param TIMx Timer instance
  3267. * @retval None
  3268. */
  3269. __STATIC_INLINE void LL_TIM_EnableDMAReq_UPDATE(TIM_TypeDef *TIMx)
  3270. {
  3271. SET_BIT(TIMx->DIER, TIM_DIER_UDE);
  3272. }
  3273. /**
  3274. * @brief Disable update DMA request (UDE).
  3275. * @rmtoll DIER UDE LL_TIM_DisableDMAReq_UPDATE
  3276. * @param TIMx Timer instance
  3277. * @retval None
  3278. */
  3279. __STATIC_INLINE void LL_TIM_DisableDMAReq_UPDATE(TIM_TypeDef *TIMx)
  3280. {
  3281. CLEAR_BIT(TIMx->DIER, TIM_DIER_UDE);
  3282. }
  3283. /**
  3284. * @brief Indicates whether the update DMA request (UDE) is enabled.
  3285. * @rmtoll DIER UDE LL_TIM_IsEnabledDMAReq_UPDATE
  3286. * @param TIMx Timer instance
  3287. * @retval State of bit (1 or 0).
  3288. */
  3289. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_UPDATE(TIM_TypeDef *TIMx)
  3290. {
  3291. return (READ_BIT(TIMx->DIER, TIM_DIER_UDE) == (TIM_DIER_UDE));
  3292. }
  3293. /**
  3294. * @brief Enable capture/compare 1 DMA request (CC1DE).
  3295. * @rmtoll DIER CC1DE LL_TIM_EnableDMAReq_CC1
  3296. * @param TIMx Timer instance
  3297. * @retval None
  3298. */
  3299. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC1(TIM_TypeDef *TIMx)
  3300. {
  3301. SET_BIT(TIMx->DIER, TIM_DIER_CC1DE);
  3302. }
  3303. /**
  3304. * @brief Disable capture/compare 1 DMA request (CC1DE).
  3305. * @rmtoll DIER CC1DE LL_TIM_DisableDMAReq_CC1
  3306. * @param TIMx Timer instance
  3307. * @retval None
  3308. */
  3309. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC1(TIM_TypeDef *TIMx)
  3310. {
  3311. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC1DE);
  3312. }
  3313. /**
  3314. * @brief Indicates whether the capture/compare 1 DMA request (CC1DE) is enabled.
  3315. * @rmtoll DIER CC1DE LL_TIM_IsEnabledDMAReq_CC1
  3316. * @param TIMx Timer instance
  3317. * @retval State of bit (1 or 0).
  3318. */
  3319. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC1(TIM_TypeDef *TIMx)
  3320. {
  3321. return (READ_BIT(TIMx->DIER, TIM_DIER_CC1DE) == (TIM_DIER_CC1DE));
  3322. }
  3323. /**
  3324. * @brief Enable capture/compare 2 DMA request (CC2DE).
  3325. * @rmtoll DIER CC2DE LL_TIM_EnableDMAReq_CC2
  3326. * @param TIMx Timer instance
  3327. * @retval None
  3328. */
  3329. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC2(TIM_TypeDef *TIMx)
  3330. {
  3331. SET_BIT(TIMx->DIER, TIM_DIER_CC2DE);
  3332. }
  3333. /**
  3334. * @brief Disable capture/compare 2 DMA request (CC2DE).
  3335. * @rmtoll DIER CC2DE LL_TIM_DisableDMAReq_CC2
  3336. * @param TIMx Timer instance
  3337. * @retval None
  3338. */
  3339. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC2(TIM_TypeDef *TIMx)
  3340. {
  3341. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC2DE);
  3342. }
  3343. /**
  3344. * @brief Indicates whether the capture/compare 2 DMA request (CC2DE) is enabled.
  3345. * @rmtoll DIER CC2DE LL_TIM_IsEnabledDMAReq_CC2
  3346. * @param TIMx Timer instance
  3347. * @retval State of bit (1 or 0).
  3348. */
  3349. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC2(TIM_TypeDef *TIMx)
  3350. {
  3351. return (READ_BIT(TIMx->DIER, TIM_DIER_CC2DE) == (TIM_DIER_CC2DE));
  3352. }
  3353. /**
  3354. * @brief Enable capture/compare 3 DMA request (CC3DE).
  3355. * @rmtoll DIER CC3DE LL_TIM_EnableDMAReq_CC3
  3356. * @param TIMx Timer instance
  3357. * @retval None
  3358. */
  3359. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC3(TIM_TypeDef *TIMx)
  3360. {
  3361. SET_BIT(TIMx->DIER, TIM_DIER_CC3DE);
  3362. }
  3363. /**
  3364. * @brief Disable capture/compare 3 DMA request (CC3DE).
  3365. * @rmtoll DIER CC3DE LL_TIM_DisableDMAReq_CC3
  3366. * @param TIMx Timer instance
  3367. * @retval None
  3368. */
  3369. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC3(TIM_TypeDef *TIMx)
  3370. {
  3371. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC3DE);
  3372. }
  3373. /**
  3374. * @brief Indicates whether the capture/compare 3 DMA request (CC3DE) is enabled.
  3375. * @rmtoll DIER CC3DE LL_TIM_IsEnabledDMAReq_CC3
  3376. * @param TIMx Timer instance
  3377. * @retval State of bit (1 or 0).
  3378. */
  3379. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC3(TIM_TypeDef *TIMx)
  3380. {
  3381. return (READ_BIT(TIMx->DIER, TIM_DIER_CC3DE) == (TIM_DIER_CC3DE));
  3382. }
  3383. /**
  3384. * @brief Enable capture/compare 4 DMA request (CC4DE).
  3385. * @rmtoll DIER CC4DE LL_TIM_EnableDMAReq_CC4
  3386. * @param TIMx Timer instance
  3387. * @retval None
  3388. */
  3389. __STATIC_INLINE void LL_TIM_EnableDMAReq_CC4(TIM_TypeDef *TIMx)
  3390. {
  3391. SET_BIT(TIMx->DIER, TIM_DIER_CC4DE);
  3392. }
  3393. /**
  3394. * @brief Disable capture/compare 4 DMA request (CC4DE).
  3395. * @rmtoll DIER CC4DE LL_TIM_DisableDMAReq_CC4
  3396. * @param TIMx Timer instance
  3397. * @retval None
  3398. */
  3399. __STATIC_INLINE void LL_TIM_DisableDMAReq_CC4(TIM_TypeDef *TIMx)
  3400. {
  3401. CLEAR_BIT(TIMx->DIER, TIM_DIER_CC4DE);
  3402. }
  3403. /**
  3404. * @brief Indicates whether the capture/compare 4 DMA request (CC4DE) is enabled.
  3405. * @rmtoll DIER CC4DE LL_TIM_IsEnabledDMAReq_CC4
  3406. * @param TIMx Timer instance
  3407. * @retval State of bit (1 or 0).
  3408. */
  3409. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_CC4(TIM_TypeDef *TIMx)
  3410. {
  3411. return (READ_BIT(TIMx->DIER, TIM_DIER_CC4DE) == (TIM_DIER_CC4DE));
  3412. }
  3413. /**
  3414. * @brief Enable commutation DMA request (COMDE).
  3415. * @rmtoll DIER COMDE LL_TIM_EnableDMAReq_COM
  3416. * @param TIMx Timer instance
  3417. * @retval None
  3418. */
  3419. __STATIC_INLINE void LL_TIM_EnableDMAReq_COM(TIM_TypeDef *TIMx)
  3420. {
  3421. SET_BIT(TIMx->DIER, TIM_DIER_COMDE);
  3422. }
  3423. /**
  3424. * @brief Disable commutation DMA request (COMDE).
  3425. * @rmtoll DIER COMDE LL_TIM_DisableDMAReq_COM
  3426. * @param TIMx Timer instance
  3427. * @retval None
  3428. */
  3429. __STATIC_INLINE void LL_TIM_DisableDMAReq_COM(TIM_TypeDef *TIMx)
  3430. {
  3431. CLEAR_BIT(TIMx->DIER, TIM_DIER_COMDE);
  3432. }
  3433. /**
  3434. * @brief Indicates whether the commutation DMA request (COMDE) is enabled.
  3435. * @rmtoll DIER COMDE LL_TIM_IsEnabledDMAReq_COM
  3436. * @param TIMx Timer instance
  3437. * @retval State of bit (1 or 0).
  3438. */
  3439. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_COM(TIM_TypeDef *TIMx)
  3440. {
  3441. return (READ_BIT(TIMx->DIER, TIM_DIER_COMDE) == (TIM_DIER_COMDE));
  3442. }
  3443. /**
  3444. * @brief Enable trigger interrupt (TDE).
  3445. * @rmtoll DIER TDE LL_TIM_EnableDMAReq_TRIG
  3446. * @param TIMx Timer instance
  3447. * @retval None
  3448. */
  3449. __STATIC_INLINE void LL_TIM_EnableDMAReq_TRIG(TIM_TypeDef *TIMx)
  3450. {
  3451. SET_BIT(TIMx->DIER, TIM_DIER_TDE);
  3452. }
  3453. /**
  3454. * @brief Disable trigger interrupt (TDE).
  3455. * @rmtoll DIER TDE LL_TIM_DisableDMAReq_TRIG
  3456. * @param TIMx Timer instance
  3457. * @retval None
  3458. */
  3459. __STATIC_INLINE void LL_TIM_DisableDMAReq_TRIG(TIM_TypeDef *TIMx)
  3460. {
  3461. CLEAR_BIT(TIMx->DIER, TIM_DIER_TDE);
  3462. }
  3463. /**
  3464. * @brief Indicates whether the trigger interrupt (TDE) is enabled.
  3465. * @rmtoll DIER TDE LL_TIM_IsEnabledDMAReq_TRIG
  3466. * @param TIMx Timer instance
  3467. * @retval State of bit (1 or 0).
  3468. */
  3469. __STATIC_INLINE uint32_t LL_TIM_IsEnabledDMAReq_TRIG(TIM_TypeDef *TIMx)
  3470. {
  3471. return (READ_BIT(TIMx->DIER, TIM_DIER_TDE) == (TIM_DIER_TDE));
  3472. }
  3473. /**
  3474. * @}
  3475. */
  3476. /** @defgroup TIM_LL_EF_EVENT_Management EVENT-Management
  3477. * @{
  3478. */
  3479. /**
  3480. * @brief Generate an update event.
  3481. * @rmtoll EGR UG LL_TIM_GenerateEvent_UPDATE
  3482. * @param TIMx Timer instance
  3483. * @retval None
  3484. */
  3485. __STATIC_INLINE void LL_TIM_GenerateEvent_UPDATE(TIM_TypeDef *TIMx)
  3486. {
  3487. SET_BIT(TIMx->EGR, TIM_EGR_UG);
  3488. }
  3489. /**
  3490. * @brief Generate Capture/Compare 1 event.
  3491. * @rmtoll EGR CC1G LL_TIM_GenerateEvent_CC1
  3492. * @param TIMx Timer instance
  3493. * @retval None
  3494. */
  3495. __STATIC_INLINE void LL_TIM_GenerateEvent_CC1(TIM_TypeDef *TIMx)
  3496. {
  3497. SET_BIT(TIMx->EGR, TIM_EGR_CC1G);
  3498. }
  3499. /**
  3500. * @brief Generate Capture/Compare 2 event.
  3501. * @rmtoll EGR CC2G LL_TIM_GenerateEvent_CC2
  3502. * @param TIMx Timer instance
  3503. * @retval None
  3504. */
  3505. __STATIC_INLINE void LL_TIM_GenerateEvent_CC2(TIM_TypeDef *TIMx)
  3506. {
  3507. SET_BIT(TIMx->EGR, TIM_EGR_CC2G);
  3508. }
  3509. /**
  3510. * @brief Generate Capture/Compare 3 event.
  3511. * @rmtoll EGR CC3G LL_TIM_GenerateEvent_CC3
  3512. * @param TIMx Timer instance
  3513. * @retval None
  3514. */
  3515. __STATIC_INLINE void LL_TIM_GenerateEvent_CC3(TIM_TypeDef *TIMx)
  3516. {
  3517. SET_BIT(TIMx->EGR, TIM_EGR_CC3G);
  3518. }
  3519. /**
  3520. * @brief Generate Capture/Compare 4 event.
  3521. * @rmtoll EGR CC4G LL_TIM_GenerateEvent_CC4
  3522. * @param TIMx Timer instance
  3523. * @retval None
  3524. */
  3525. __STATIC_INLINE void LL_TIM_GenerateEvent_CC4(TIM_TypeDef *TIMx)
  3526. {
  3527. SET_BIT(TIMx->EGR, TIM_EGR_CC4G);
  3528. }
  3529. /**
  3530. * @brief Generate commutation event.
  3531. * @rmtoll EGR COMG LL_TIM_GenerateEvent_COM
  3532. * @param TIMx Timer instance
  3533. * @retval None
  3534. */
  3535. __STATIC_INLINE void LL_TIM_GenerateEvent_COM(TIM_TypeDef *TIMx)
  3536. {
  3537. SET_BIT(TIMx->EGR, TIM_EGR_COMG);
  3538. }
  3539. /**
  3540. * @brief Generate trigger event.
  3541. * @rmtoll EGR TG LL_TIM_GenerateEvent_TRIG
  3542. * @param TIMx Timer instance
  3543. * @retval None
  3544. */
  3545. __STATIC_INLINE void LL_TIM_GenerateEvent_TRIG(TIM_TypeDef *TIMx)
  3546. {
  3547. SET_BIT(TIMx->EGR, TIM_EGR_TG);
  3548. }
  3549. /**
  3550. * @brief Generate break event.
  3551. * @rmtoll EGR BG LL_TIM_GenerateEvent_BRK
  3552. * @param TIMx Timer instance
  3553. * @retval None
  3554. */
  3555. __STATIC_INLINE void LL_TIM_GenerateEvent_BRK(TIM_TypeDef *TIMx)
  3556. {
  3557. SET_BIT(TIMx->EGR, TIM_EGR_BG);
  3558. }
  3559. /**
  3560. * @}
  3561. */
  3562. #if defined(USE_FULL_LL_DRIVER)
  3563. /** @defgroup TIM_LL_EF_Init Initialisation and deinitialisation functions
  3564. * @{
  3565. */
  3566. ErrorStatus LL_TIM_DeInit(TIM_TypeDef *TIMx);
  3567. void LL_TIM_StructInit(LL_TIM_InitTypeDef *TIM_InitStruct);
  3568. ErrorStatus LL_TIM_Init(TIM_TypeDef *TIMx, LL_TIM_InitTypeDef *TIM_InitStruct);
  3569. void LL_TIM_OC_StructInit(LL_TIM_OC_InitTypeDef *TIM_OC_InitStruct);
  3570. ErrorStatus LL_TIM_OC_Init(TIM_TypeDef *TIMx, uint32_t Channel, LL_TIM_OC_InitTypeDef *TIM_OC_InitStruct);
  3571. void LL_TIM_IC_StructInit(LL_TIM_IC_InitTypeDef *TIM_ICInitStruct);
  3572. ErrorStatus LL_TIM_IC_Init(TIM_TypeDef *TIMx, uint32_t Channel, LL_TIM_IC_InitTypeDef *TIM_IC_InitStruct);
  3573. void LL_TIM_ENCODER_StructInit(LL_TIM_ENCODER_InitTypeDef *TIM_EncoderInitStruct);
  3574. ErrorStatus LL_TIM_ENCODER_Init(TIM_TypeDef *TIMx, LL_TIM_ENCODER_InitTypeDef *TIM_EncoderInitStruct);
  3575. void LL_TIM_HALLSENSOR_StructInit(LL_TIM_HALLSENSOR_InitTypeDef *TIM_HallSensorInitStruct);
  3576. ErrorStatus LL_TIM_HALLSENSOR_Init(TIM_TypeDef *TIMx, LL_TIM_HALLSENSOR_InitTypeDef *TIM_HallSensorInitStruct);
  3577. void LL_TIM_BDTR_StructInit(LL_TIM_BDTR_InitTypeDef *TIM_BDTRInitStruct);
  3578. ErrorStatus LL_TIM_BDTR_Init(TIM_TypeDef *TIMx, LL_TIM_BDTR_InitTypeDef *TIM_BDTRInitStruct);
  3579. /**
  3580. * @}
  3581. */
  3582. #endif /* USE_FULL_LL_DRIVER */
  3583. /**
  3584. * @}
  3585. */
  3586. /**
  3587. * @}
  3588. */
  3589. #endif /* TIM1 || TIM2 || TIM3 || TIM4 || TIM5 || TIM6 || TIM7 || TIM8 || TIM9 || TIM10 || TIM11 || TIM12 || TIM13 || TIM14 */
  3590. /**
  3591. * @}
  3592. */
  3593. #ifdef __cplusplus
  3594. }
  3595. #endif
  3596. #endif /* __STM32F4xx_LL_TIM_H */
  3597. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/