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.
 
 
 

4664 lines
200 KiB

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