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.
 
 
 

3965 lines
165 KiB

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