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.
 
 
 

464 lines
26 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_hal_tim_ex.h
  4. * @author MCD Application Team
  5. * @version V1.7.2
  6. * @date 16-June-2017
  7. * @brief Header file of TIM HAL Extended 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 __STM32L4xx_HAL_TIM_EX_H
  39. #define __STM32L4xx_HAL_TIM_EX_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32l4xx_hal_def.h"
  45. /** @addtogroup STM32L4xx_HAL_Driver
  46. * @{
  47. */
  48. /** @addtogroup TIMEx
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /** @defgroup TIMEx_Exported_Types TIM Extended Exported Types
  53. * @{
  54. */
  55. /**
  56. * @brief TIM Hall sensor Configuration Structure definition
  57. */
  58. typedef struct
  59. {
  60. uint32_t IC1Polarity; /*!< Specifies the active edge of the input signal.
  61. This parameter can be a value of @ref TIM_Input_Capture_Polarity */
  62. uint32_t IC1Prescaler; /*!< Specifies the Input Capture Prescaler.
  63. This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
  64. uint32_t IC1Filter; /*!< Specifies the input capture filter.
  65. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  66. uint32_t Commutation_Delay; /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
  67. This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
  68. } TIM_HallSensor_InitTypeDef;
  69. /**
  70. * @brief TIM Break/Break2 input configuration
  71. */
  72. typedef struct {
  73. uint32_t Source; /*!< Specifies the source of the timer break input.
  74. This parameter can be a value of @ref TIMEx_Break_Input_Source */
  75. uint32_t Enable; /*!< Specifies whether or not the break input source is enabled.
  76. This parameter can be a value of @ref TIMEx_Break_Input_Source_Enable */
  77. uint32_t Polarity; /*!< Specifies the break input source polarity.
  78. This parameter can be a value of @ref TIMEx_Break_Input_Source_Polarity
  79. Not relevant when analog watchdog output of the DFSDM1 used as break input source */
  80. } TIMEx_BreakInputConfigTypeDef;
  81. /**
  82. * @}
  83. */
  84. /* End of exported types -----------------------------------------------------*/
  85. /* Exported constants --------------------------------------------------------*/
  86. /** @defgroup TIMEx_Exported_Constants TIM Extended Exported Constants
  87. * @{
  88. */
  89. /** @defgroup TIMEx_Remap TIM Extended Remapping
  90. * @{
  91. */
  92. #define TIM_TIM1_ETR_ADC1_NONE ((uint32_t)(0x00000000)) /* !< TIM1_ETR is not connected to any AWD (analog watchdog)*/
  93. #define TIM_TIM1_ETR_ADC1_AWD1 (TIM1_OR1_ETR_ADC1_RMP_0) /* !< TIM1_ETR is connected to ADC1 AWD1 */
  94. #define TIM_TIM1_ETR_ADC1_AWD2 (TIM1_OR1_ETR_ADC1_RMP_1) /* !< TIM1_ETR is connected to ADC1 AWD2 */
  95. #define TIM_TIM1_ETR_ADC1_AWD3 (TIM1_OR1_ETR_ADC1_RMP_1 | TIM1_OR1_ETR_ADC1_RMP_0) /* !< TIM1_ETR is connected to ADC1 AWD3 */
  96. #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \
  97. defined (STM32L496xx) || defined (STM32L4A6xx)
  98. #define TIM_TIM1_ETR_ADC3_NONE ((uint32_t)(0x00000000)) /* !< TIM1_ETR is not connected to any AWD (analog watchdog)*/
  99. #define TIM_TIM1_ETR_ADC3_AWD1 (TIM1_OR1_ETR_ADC3_RMP_0) /* !< TIM1_ETR is connected to ADC3 AWD1 */
  100. #define TIM_TIM1_ETR_ADC3_AWD2 (TIM1_OR1_ETR_ADC3_RMP_1) /* !< TIM1_ETR is connected to ADC3 AWD2 */
  101. #define TIM_TIM1_ETR_ADC3_AWD3 (TIM1_OR1_ETR_ADC3_RMP_1 | TIM1_OR1_ETR_ADC3_RMP_0) /* !< TIM1_ETR is connected to ADC3 AWD3 */
  102. #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx || */
  103. /* STM32L496xx || STM32L4A6xx */
  104. #define TIM_TIM1_TI1_GPIO ((uint32_t)(0x00000000)) /* !< TIM1 TI1 is connected to GPIO */
  105. #define TIM_TIM1_TI1_COMP1 (TIM1_OR1_TI1_RMP) /* !< TIM1 TI1 is connected to COMP1 */
  106. #define TIM_TIM1_ETR_COMP1 (TIM1_OR2_ETRSEL_0) /* !< TIM1_ETR is connected to COMP1 output */
  107. #define TIM_TIM1_ETR_COMP2 (TIM1_OR2_ETRSEL_1) /* !< TIM1_ETR is connected to COMP2 output */
  108. #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \
  109. defined (STM32L496xx) || defined (STM32L4A6xx)
  110. #define TIM_TIM2_ITR1_TIM8_TRGO ((uint32_t)(0x00000000)) /* !< TIM2_ITR1 is connected to TIM8_TRGO */
  111. #define TIM_TIM2_ITR1_OTG_FS_SOF (TIM2_OR1_ITR1_RMP) /* !< TIM2_ITR1 is connected to OTG_FS SOF */
  112. #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx || */
  113. /* STM32L496xx || STM32L4A6xx */
  114. #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) || \
  115. defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx)
  116. #define TIM_TIM2_ITR1_NONE ((uint32_t)(0x00000000)) /* !< No internal trigger on TIM2_ITR1 */
  117. #define TIM_TIM2_ITR1_USB_SOF (TIM2_OR1_ITR1_RMP) /* !< TIM2_ITR1 is connected to USB SOF */
  118. #endif /* STM32L431xx || STM32L432xx || STM32L442xx || STM32L433xx || STM32L443xx || */
  119. /* STM32L451xx || STM32L452xx || STM32L462xx */
  120. #define TIM_TIM2_ETR_GPIO ((uint32_t)(0x00000000)) /* !< TIM2_ETR is connected to GPIO */
  121. #define TIM_TIM2_ETR_LSE (TIM2_OR1_ETR1_RMP) /* !< TIM2_ETR is connected to LSE */
  122. #define TIM_TIM2_ETR_COMP1 (TIM2_OR2_ETRSEL_0) /* !< TIM2_ETR is connected to COMP1 output */
  123. #define TIM_TIM2_ETR_COMP2 (TIM2_OR2_ETRSEL_1) /* !< TIM2_ETR is connected to COMP2 output */
  124. #define TIM_TIM2_TI4_GPIO ((uint32_t)(0x00000000)) /* !< TIM2 TI4 is connected to GPIO */
  125. #define TIM_TIM2_TI4_COMP1 (TIM2_OR1_TI4_RMP_0) /* !< TIM2 TI4 is connected to COMP1 output */
  126. #define TIM_TIM2_TI4_COMP2 (TIM2_OR1_TI4_RMP_1) /* !< TIM2 TI4 is connected to COMP2 output */
  127. #define TIM_TIM2_TI4_COMP1_COMP2 (TIM2_OR1_TI4_RMP_1| TIM2_OR1_TI4_RMP_0) /* !< TIM2 TI4 is connected to logical OR between COMP1 and COMP2 output2 */
  128. #if defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx) || \
  129. defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \
  130. defined (STM32L496xx) || defined (STM32L4A6xx)
  131. #define TIM_TIM3_TI1_GPIO ((uint32_t)(0x00000000)) /* !< TIM3 TI1 is connected to GPIO */
  132. #define TIM_TIM3_TI1_COMP1 (TIM3_OR1_TI1_RMP_0) /* !< TIM3 TI1 is connected to COMP1 output */
  133. #define TIM_TIM3_TI1_COMP2 (TIM3_OR1_TI1_RMP_1) /* !< TIM3 TI1 is connected to COMP2 output */
  134. #define TIM_TIM3_TI1_COMP1_COMP2 (TIM3_OR1_TI1_RMP_1 | TIM3_OR1_TI1_RMP_0) /* !< TIM3 TI1 is connected to logical OR between COMP1 and COMP2 output2 */
  135. #define TIM_TIM3_ETR_GPIO ((uint32_t)(0x00000000)) /* !< TIM3_ETR is connected to GPIO */
  136. #define TIM_TIM3_ETR_COMP1 (TIM3_OR2_ETRSEL_0) /* !< TIM3_ETR is connected to COMP1 output */
  137. #endif /* STM32L451xx || STM32L452xx || STM32L462xx || */
  138. /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx || */
  139. /* STM32L496xx || STM32L4A6xx */
  140. #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \
  141. defined (STM32L496xx) || defined (STM32L4A6xx)
  142. #define TIM_TIM8_ETR_ADC2_NONE ((uint32_t)(0x00000000)) /* !< TIM8_ETR is not connected to any AWD (analog watchdog)*/
  143. #define TIM_TIM8_ETR_ADC2_AWD1 (TIM8_OR1_ETR_ADC2_RMP_0) /* !< TIM8_ETR is connected to ADC2 AWD1 */
  144. #define TIM_TIM8_ETR_ADC2_AWD2 (TIM8_OR1_ETR_ADC2_RMP_1) /* !< TIM8_ETR is connected to ADC2 AWD2 */
  145. #define TIM_TIM8_ETR_ADC2_AWD3 (TIM8_OR1_ETR_ADC2_RMP_1 | TIM8_OR1_ETR_ADC2_RMP_0) /* !< TIM8_ETR is connected to ADC2 AWD3 */
  146. #define TIM_TIM8_ETR_ADC3_NONE ((uint32_t)(0x00000000)) /* !< TIM8_ETR is not connected to any AWD (analog watchdog)*/
  147. #define TIM_TIM8_ETR_ADC3_AWD1 (TIM8_OR1_ETR_ADC3_RMP_0) /* !< TIM8_ETR is connected to ADC3 AWD1 */
  148. #define TIM_TIM8_ETR_ADC3_AWD2 (TIM8_OR1_ETR_ADC3_RMP_1) /* !< TIM8_ETR is connected to ADC3 AWD2 */
  149. #define TIM_TIM8_ETR_ADC3_AWD3 (TIM8_OR1_ETR_ADC3_RMP_1 | TIM8_OR1_ETR_ADC3_RMP_0) /* !< TIM8_ETR is connected to ADC3 AWD3 */
  150. #define TIM_TIM8_ETR_COMP1 (TIM8_OR2_ETRSEL_0) /* !< TIM8_ETR is connected to COMP1 output */
  151. #define TIM_TIM8_ETR_COMP2 (TIM8_OR2_ETRSEL_1) /* !< TIM8_ETR is connected to COMP2 output */
  152. #define TIM_TIM8_TI1_GPIO ((uint32_t)(0x00000000)) /* !< TIM8 TI1 is connected to GPIO */
  153. #define TIM_TIM8_TI1_COMP2 (TIM8_OR1_TI1_RMP) /* !< TIM8 TI1 is connected to COMP1 */
  154. #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx || */
  155. /* STM32L496xx || STM32L4A6xx */
  156. #define TIM_TIM15_TI1_GPIO ((uint32_t)(0x00000000)) /* !< TIM15 TI1 is connected to GPIO */
  157. #define TIM_TIM15_TI1_LSE (TIM15_OR1_TI1_RMP) /* !< TIM15 TI1 is connected to LSE */
  158. #define TIM_TIM15_ENCODERMODE_NONE ((uint32_t)(0x00000000)) /* !< No redirection */
  159. #define TIM_TIM15_ENCODERMODE_TIM2 (TIM15_OR1_ENCODER_MODE_0) /* !< TIM2 IC1 and TIM2 IC2 are connected to TIM15 IC1 and TIM15 IC2 respectively */
  160. #if defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx) || \
  161. defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \
  162. defined (STM32L496xx) || defined (STM32L4A6xx)
  163. #define TIM_TIM15_ENCODERMODE_TIM3 (TIM15_OR1_ENCODER_MODE_1) /* !< TIM3 IC1 and TIM3 IC2 are connected to TIM15 IC1 and TIM15 IC2 respectively */
  164. #endif /* STM32L451xx || STM32L452xx || STM32L462xx */
  165. /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx || */
  166. /* STM32L496xx || STM32L4A6xx */
  167. #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \
  168. defined (STM32L496xx) || defined (STM32L4A6xx)
  169. #define TIM_TIM15_ENCODERMODE_TIM4 (TIM15_OR1_ENCODER_MODE_1 | TIM15_OR1_ENCODER_MODE_0) /* !< TIM4 IC1 and TIM4 IC2 are connected to TIM15 IC1 and TIM15 IC2 respectively */
  170. #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx || */
  171. /* STM32L496xx || STM32L4A6xx */
  172. #define TIM_TIM16_TI1_GPIO ((uint32_t)(0x00000000)) /* !< TIM16 TI1 is connected to GPIO */
  173. #define TIM_TIM16_TI1_LSI (TIM16_OR1_TI1_RMP_0) /* !< TIM16 TI1 is connected to LSI */
  174. #define TIM_TIM16_TI1_LSE (TIM16_OR1_TI1_RMP_1) /* !< TIM16 TI1 is connected to LSE */
  175. #define TIM_TIM16_TI1_RTC (TIM16_OR1_TI1_RMP_1 | TIM16_OR1_TI1_RMP_0) /* !< TIM16 TI1 is connected to RTC wakeup interrupt */
  176. #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) || \
  177. defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx) || \
  178. defined (STM32L496xx) || defined (STM32L4A6xx)
  179. #define TIM_TIM16_TI1_MSI (TIM16_OR1_TI1_RMP_2) /* !< TIM16 TI1 is connected to MSI */
  180. #define TIM_TIM16_TI1_HSE_32 (TIM16_OR1_TI1_RMP_2 | TIM16_OR1_TI1_RMP_0) /* !< TIM16 TI1 is connected to HSE div 32 */
  181. #define TIM_TIM16_TI1_MCO (TIM16_OR1_TI1_RMP_2 | TIM16_OR1_TI1_RMP_1) /* !< TIM16 TI1 is connected to MCO */
  182. #endif /* STM32L431xx || STM32L432xx || STM32L442xx || STM32L433xx || STM32L443xx || */
  183. /* STM32L451xx || STM32L452xx || STM32L462xx || */
  184. /* STM32L496xx || STM32L4A6xx */
  185. #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \
  186. defined (STM32L496xx) || defined (STM32L4A6xx)
  187. #define TIM_TIM17_TI1_GPIO ((uint32_t)(0x00000000)) /* !< TIM17 TI1 is connected to GPIO */
  188. #define TIM_TIM17_TI1_MSI (TIM17_OR1_TI1_RMP_0) /* !< TIM17 TI1 is connected to MSI */
  189. #define TIM_TIM17_TI1_HSE_32 (TIM17_OR1_TI1_RMP_1) /* !< TIM17 TI1 is connected to HSE div 32 */
  190. #define TIM_TIM17_TI1_MCO (TIM17_OR1_TI1_RMP_1 | TIM17_OR1_TI1_RMP_0) /* !< TIM17 TI1 is connected to MCO */
  191. #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx || */
  192. /* STM32L496xx || STM32L4A6xx */
  193. /**
  194. * @}
  195. */
  196. /** @defgroup TIMEx_Break_Input TIM Extended Break input
  197. * @{
  198. */
  199. #define TIM_BREAKINPUT_BRK ((uint32_t)(0x00000001)) /* !< Timer break input */
  200. #define TIM_BREAKINPUT_BRK2 ((uint32_t)(0x00000002)) /* !< Timer break2 input */
  201. /**
  202. * @}
  203. */
  204. /** @defgroup TIMEx_Break_Input_Source TIM Extended Break input source
  205. * @{
  206. */
  207. #define TIM_BREAKINPUTSOURCE_BKIN ((uint32_t)(0x00000001)) /* !< An external source (GPIO) is connected to the BKIN pin */
  208. #define TIM_BREAKINPUTSOURCE_COMP1 ((uint32_t)(0x00000002)) /* !< The COMP1 output is connected to the break input */
  209. #define TIM_BREAKINPUTSOURCE_COMP2 ((uint32_t)(0x00000004)) /* !< The COMP2 output is connected to the break input */
  210. #if defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx) || \
  211. defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \
  212. defined (STM32L496xx) || defined (STM32L4A6xx)
  213. #define TIM_BREAKINPUTSOURCE_DFSDM1 ((uint32_t)(0x00000008)) /* !< The analog watchdog output of the DFSDM1 peripheral is connected to the break input */
  214. #endif /* STM32L451xx || STM32L452xx || STM32L462xx || */
  215. /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx || */
  216. /* STM32L496xx || STM32L4A6xx */
  217. /**
  218. * @}
  219. */
  220. /** @defgroup TIMEx_Break_Input_Source_Enable TIM Extended Break input source enabling
  221. * @{
  222. */
  223. #define TIM_BREAKINPUTSOURCE_DISABLE ((uint32_t)(0x00000000)) /* !< Break input source is disabled */
  224. #define TIM_BREAKINPUTSOURCE_ENABLE ((uint32_t)(0x00000001)) /* !< Break input source is enabled */
  225. /**
  226. * @}
  227. */
  228. /** @defgroup TIMEx_Break_Input_Source_Polarity TIM Extended Break input polarity
  229. * @{
  230. */
  231. #define TIM_BREAKINPUTSOURCE_POLARITY_LOW ((uint32_t)(0x00000001)) /* !< Break input source is active low */
  232. #define TIM_BREAKINPUTSOURCE_POLARITY_HIGH ((uint32_t)(0x00000000)) /* !< Break input source is active_high */
  233. /**
  234. * @}
  235. */
  236. /**
  237. * @}
  238. */
  239. /* End of exported constants -------------------------------------------------*/
  240. /* Exported macro ------------------------------------------------------------*/
  241. /** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros
  242. * @{
  243. */
  244. /**
  245. * @}
  246. */
  247. /* End of exported macro -----------------------------------------------------*/
  248. /* Private macro -------------------------------------------------------------*/
  249. /** @defgroup TIMEx_Private_Macros TIM Extended Private Macros
  250. * @{
  251. */
  252. #define IS_TIM_REMAP(__REMAP__) (((__REMAP__) <= (uint32_t)0x0001C01F))
  253. #define IS_TIM_BREAKINPUT(__BREAKINPUT__) (((__BREAKINPUT__) == TIM_BREAKINPUT_BRK) || \
  254. ((__BREAKINPUT__) == TIM_BREAKINPUT_BRK2))
  255. #if defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx) || \
  256. defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \
  257. defined (STM32L496xx) || defined (STM32L4A6xx)
  258. #define IS_TIM_BREAKINPUTSOURCE(__SOURCE__) (((__SOURCE__) == TIM_BREAKINPUTSOURCE_BKIN) || \
  259. ((__SOURCE__) == TIM_BREAKINPUTSOURCE_COMP1) || \
  260. ((__SOURCE__) == TIM_BREAKINPUTSOURCE_COMP2) || \
  261. ((__SOURCE__) == TIM_BREAKINPUTSOURCE_DFSDM1))
  262. #else
  263. #define IS_TIM_BREAKINPUTSOURCE(__SOURCE__) (((__SOURCE__) == TIM_BREAKINPUTSOURCE_BKIN) || \
  264. ((__SOURCE__) == TIM_BREAKINPUTSOURCE_COMP1) || \
  265. ((__SOURCE__) == TIM_BREAKINPUTSOURCE_COMP2))
  266. #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx || STM32L496xx || STM32L4A6xx */
  267. #define IS_TIM_BREAKINPUTSOURCE_STATE(__STATE__) (((__STATE__) == TIM_BREAKINPUTSOURCE_DISABLE) || \
  268. ((__STATE__) == TIM_BREAKINPUTSOURCE_ENABLE))
  269. #define IS_TIM_BREAKINPUTSOURCE_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_BREAKINPUTSOURCE_POLARITY_LOW) || \
  270. ((__POLARITY__) == TIM_BREAKINPUTSOURCE_POLARITY_HIGH))
  271. /**
  272. * @}
  273. */
  274. /* End of private macro ------------------------------------------------------*/
  275. /* Exported functions --------------------------------------------------------*/
  276. /** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions
  277. * @{
  278. */
  279. /** @addtogroup TIMEx_Exported_Functions_Group1 Extended Timer Hall Sensor functions
  280. * @brief Timer Hall Sensor functions
  281. * @{
  282. */
  283. /* Timer Hall Sensor functions **********************************************/
  284. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, TIM_HallSensor_InitTypeDef* sConfig);
  285. HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim);
  286. void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim);
  287. void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim);
  288. /* Blocking mode: Polling */
  289. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim);
  290. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim);
  291. /* Non-Blocking mode: Interrupt */
  292. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim);
  293. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim);
  294. /* Non-Blocking mode: DMA */
  295. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
  296. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim);
  297. /**
  298. * @}
  299. */
  300. /** @addtogroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions
  301. * @brief Timer Complementary Output Compare functions
  302. * @{
  303. */
  304. /* Timer Complementary Output Compare functions *****************************/
  305. /* Blocking mode: Polling */
  306. HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  307. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  308. /* Non-Blocking mode: Interrupt */
  309. HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  310. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  311. /* Non-Blocking mode: DMA */
  312. HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  313. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  314. /**
  315. * @}
  316. */
  317. /** @addtogroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions
  318. * @brief Timer Complementary PWM functions
  319. * @{
  320. */
  321. /* Timer Complementary PWM functions ****************************************/
  322. /* Blocking mode: Polling */
  323. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  324. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  325. /* Non-Blocking mode: Interrupt */
  326. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  327. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  328. /* Non-Blocking mode: DMA */
  329. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  330. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  331. /**
  332. * @}
  333. */
  334. /** @addtogroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions
  335. * @brief Timer Complementary One Pulse functions
  336. * @{
  337. */
  338. /* Timer Complementary One Pulse functions **********************************/
  339. /* Blocking mode: Polling */
  340. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  341. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  342. /* Non-Blocking mode: Interrupt */
  343. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  344. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  345. /**
  346. * @}
  347. */
  348. /** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions
  349. * @brief Peripheral Control functions
  350. * @{
  351. */
  352. /* Extended Control functions ************************************************/
  353. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger, uint32_t CommutationSource);
  354. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger, uint32_t CommutationSource);
  355. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger, uint32_t CommutationSource);
  356. HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim, TIM_MasterConfigTypeDef * sMasterConfig);
  357. HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim, TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig);
  358. HAL_StatusTypeDef HAL_TIMEx_ConfigBreakInput(TIM_HandleTypeDef *htim, uint32_t BreakInput, TIMEx_BreakInputConfigTypeDef *sBreakInputConfig);
  359. HAL_StatusTypeDef HAL_TIMEx_GroupChannel5(TIM_HandleTypeDef *htim, uint32_t Channels);
  360. HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap);
  361. /**
  362. * @}
  363. */
  364. /** @addtogroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions
  365. * @brief Extended Callbacks functions
  366. * @{
  367. */
  368. /* Extended Callback **********************************************************/
  369. void HAL_TIMEx_CommutationCallback(TIM_HandleTypeDef *htim);
  370. void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim);
  371. /**
  372. * @}
  373. */
  374. /** @addtogroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions
  375. * @brief Extended Peripheral State functions
  376. * @{
  377. */
  378. /* Extended Peripheral State functions ***************************************/
  379. HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef *htim);
  380. /**
  381. * @}
  382. */
  383. /**
  384. * @}
  385. */
  386. /* End of exported functions -------------------------------------------------*/
  387. /* Private functions----------------------------------------------------------*/
  388. /** @defgroup TIMEx_Private_Functions TIMEx Private Functions
  389. * @{
  390. */
  391. void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma);
  392. /**
  393. * @}
  394. */
  395. /* End of private functions --------------------------------------------------*/
  396. /**
  397. * @}
  398. */
  399. /**
  400. * @}
  401. */
  402. #ifdef __cplusplus
  403. }
  404. #endif
  405. #endif /* __STM32L4xx_HAL_TIM_EX_H */
  406. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/