stm32f7xx_hal_tim_ex.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. /**
  2. ******************************************************************************
  3. * @file stm32f7xx_hal_tim_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of TIM HAL Extended module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32F7xx_HAL_TIM_EX_H
  20. #define STM32F7xx_HAL_TIM_EX_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f7xx_hal_def.h"
  26. /** @addtogroup STM32F7xx_HAL_Driver
  27. * @{
  28. */
  29. /** @addtogroup TIMEx
  30. * @{
  31. */
  32. /* Exported types ------------------------------------------------------------*/
  33. /** @defgroup TIMEx_Exported_Types TIM Extended Exported Types
  34. * @{
  35. */
  36. /**
  37. * @brief TIM Hall sensor Configuration Structure definition
  38. */
  39. typedef struct
  40. {
  41. uint32_t IC1Polarity; /*!< Specifies the active edge of the input signal.
  42. This parameter can be a value of @ref TIM_Input_Capture_Polarity */
  43. uint32_t IC1Prescaler; /*!< Specifies the Input Capture Prescaler.
  44. This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
  45. uint32_t IC1Filter; /*!< Specifies the input capture filter.
  46. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  47. uint32_t Commutation_Delay; /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
  48. This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
  49. } TIM_HallSensor_InitTypeDef;
  50. #if defined(TIM_BREAK_INPUT_SUPPORT)
  51. /**
  52. * @brief TIM Break/Break2 input configuration
  53. */
  54. typedef struct
  55. {
  56. uint32_t Source; /*!< Specifies the source of the timer break input.
  57. This parameter can be a value of @ref TIMEx_Break_Input_Source */
  58. uint32_t Enable; /*!< Specifies whether or not the break input source is enabled.
  59. This parameter can be a value of @ref TIMEx_Break_Input_Source_Enable */
  60. uint32_t Polarity; /*!< Specifies the break input source polarity.
  61. This parameter can be a value of @ref TIMEx_Break_Input_Source_Polarity
  62. Not relevant when analog watchdog output of the DFSDM1 used as break input source */
  63. } TIMEx_BreakInputConfigTypeDef;
  64. #endif /* TIM_BREAK_INPUT_SUPPORT */
  65. /**
  66. * @}
  67. */
  68. /* End of exported types -----------------------------------------------------*/
  69. /* Exported constants --------------------------------------------------------*/
  70. /** @defgroup TIMEx_Exported_Constants TIM Extended Exported Constants
  71. * @{
  72. */
  73. /** @defgroup TIMEx_Remap TIM Extended Remapping
  74. * @{
  75. */
  76. #define TIM_TIM2_TIM8_TRGO (0x00000000U)
  77. #define TIM_TIM2_ETH_PTP (0x00000400U)
  78. #define TIM_TIM2_USBFS_SOF (0x00000800U)
  79. #define TIM_TIM2_USBHS_SOF (0x00000C00U)
  80. #define TIM_TIM5_GPIO (0x00000000U)
  81. #define TIM_TIM5_LSI (0x00000040U)
  82. #define TIM_TIM5_LSE (0x00000080U)
  83. #define TIM_TIM5_RTC (0x000000C0U)
  84. #define TIM_TIM11_GPIO (0x00000000U)
  85. #define TIM_TIM11_SPDIFRX (0x00000001U)
  86. #define TIM_TIM11_HSE (0x00000002U)
  87. #define TIM_TIM11_MCO1 (0x00000003U)
  88. /**
  89. * @}
  90. */
  91. #if defined(TIM_BREAK_INPUT_SUPPORT)
  92. /** @defgroup TIMEx_Break_Input TIM Extended Break input
  93. * @{
  94. */
  95. #define TIM_BREAKINPUT_BRK 0x00000001U /*!< Timer break input */
  96. #define TIM_BREAKINPUT_BRK2 0x00000002U /*!< Timer break2 input */
  97. /**
  98. * @}
  99. */
  100. /** @defgroup TIMEx_Break_Input_Source TIM Extended Break input source
  101. * @{
  102. */
  103. #define TIM_BREAKINPUTSOURCE_BKIN (0x00000001U) /* !< An external source (GPIO) is connected to the BKIN pin */
  104. #define TIM_BREAKINPUTSOURCE_DFSDM1 (0x00000008U) /* !< The analog watchdog output of the DFSDM1 peripheral is connected to the break input */
  105. /**
  106. * @}
  107. */
  108. /** @defgroup TIMEx_Break_Input_Source_Enable TIM Extended Break input source enabling
  109. * @{
  110. */
  111. #define TIM_BREAKINPUTSOURCE_DISABLE 0x00000000U /*!< Break input source is disabled */
  112. #define TIM_BREAKINPUTSOURCE_ENABLE 0x00000001U /*!< Break input source is enabled */
  113. /**
  114. * @}
  115. */
  116. /** @defgroup TIMEx_Break_Input_Source_Polarity TIM Extended Break input polarity
  117. * @{
  118. */
  119. #define TIM_BREAKINPUTSOURCE_POLARITY_LOW 0x00000001U /*!< Break input source is active low */
  120. #define TIM_BREAKINPUTSOURCE_POLARITY_HIGH 0x00000000U /*!< Break input source is active_high */
  121. /**
  122. * @}
  123. */
  124. #endif /* TIM_BREAK_INPUT_SUPPORT */
  125. /**
  126. * @}
  127. */
  128. /* End of exported constants -------------------------------------------------*/
  129. /* Exported macro ------------------------------------------------------------*/
  130. /** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros
  131. * @{
  132. */
  133. /**
  134. * @}
  135. */
  136. /* End of exported macro -----------------------------------------------------*/
  137. /* Private macro -------------------------------------------------------------*/
  138. /** @defgroup TIMEx_Private_Macros TIM Extended Private Macros
  139. * @{
  140. */
  141. #define IS_TIM_REMAP(__TIM_REMAP__) (((__TIM_REMAP__) == TIM_TIM2_TIM8_TRGO)||\
  142. ((__TIM_REMAP__) == TIM_TIM2_ETH_PTP) ||\
  143. ((__TIM_REMAP__) == TIM_TIM2_USBFS_SOF)||\
  144. ((__TIM_REMAP__) == TIM_TIM2_USBHS_SOF)||\
  145. ((__TIM_REMAP__) == TIM_TIM5_GPIO) ||\
  146. ((__TIM_REMAP__) == TIM_TIM5_LSI) ||\
  147. ((__TIM_REMAP__) == TIM_TIM5_LSE) ||\
  148. ((__TIM_REMAP__) == TIM_TIM5_RTC) ||\
  149. ((__TIM_REMAP__) == TIM_TIM11_GPIO) ||\
  150. ((__TIM_REMAP__) == TIM_TIM11_SPDIFRX) ||\
  151. ((__TIM_REMAP__) == TIM_TIM11_HSE) ||\
  152. ((__TIM_REMAP__) == TIM_TIM11_MCO1))
  153. #if defined(TIM_BREAK_INPUT_SUPPORT)
  154. #define IS_TIM_BREAKINPUT(__BREAKINPUT__) (((__BREAKINPUT__) == TIM_BREAKINPUT_BRK) || \
  155. ((__BREAKINPUT__) == TIM_BREAKINPUT_BRK2))
  156. #define IS_TIM_BREAKINPUTSOURCE(__SOURCE__) (((__SOURCE__) == TIM_BREAKINPUTSOURCE_BKIN) || \
  157. ((__SOURCE__) == TIM_BREAKINPUTSOURCE_DFSDM))
  158. #define IS_TIM_BREAKINPUTSOURCE_STATE(__STATE__) (((__STATE__) == TIM_BREAKINPUTSOURCE_DISABLE) || \
  159. ((__STATE__) == TIM_BREAKINPUTSOURCE_ENABLE))
  160. #define IS_TIM_BREAKINPUTSOURCE_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_BREAKINPUTSOURCE_POLARITY_LOW) || \
  161. ((__POLARITY__) == TIM_BREAKINPUTSOURCE_POLARITY_HIGH))
  162. #endif /* TIM_BREAK_INPUT_SUPPORT */
  163. /**
  164. * @}
  165. */
  166. /* End of private macro ------------------------------------------------------*/
  167. /* Exported functions --------------------------------------------------------*/
  168. /** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions
  169. * @{
  170. */
  171. /** @addtogroup TIMEx_Exported_Functions_Group1 Extended Timer Hall Sensor functions
  172. * @brief Timer Hall Sensor functions
  173. * @{
  174. */
  175. /* Timer Hall Sensor functions **********************************************/
  176. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, const TIM_HallSensor_InitTypeDef *sConfig);
  177. HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim);
  178. void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim);
  179. void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim);
  180. /* Blocking mode: Polling */
  181. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim);
  182. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim);
  183. /* Non-Blocking mode: Interrupt */
  184. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim);
  185. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim);
  186. /* Non-Blocking mode: DMA */
  187. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
  188. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim);
  189. /**
  190. * @}
  191. */
  192. /** @addtogroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions
  193. * @brief Timer Complementary Output Compare functions
  194. * @{
  195. */
  196. /* Timer Complementary Output Compare functions *****************************/
  197. /* Blocking mode: Polling */
  198. HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  199. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  200. /* Non-Blocking mode: Interrupt */
  201. HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  202. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  203. /* Non-Blocking mode: DMA */
  204. HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData,
  205. uint16_t Length);
  206. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  207. /**
  208. * @}
  209. */
  210. /** @addtogroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions
  211. * @brief Timer Complementary PWM functions
  212. * @{
  213. */
  214. /* Timer Complementary PWM functions ****************************************/
  215. /* Blocking mode: Polling */
  216. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  217. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  218. /* Non-Blocking mode: Interrupt */
  219. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  220. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  221. /* Non-Blocking mode: DMA */
  222. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData,
  223. uint16_t Length);
  224. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  225. /**
  226. * @}
  227. */
  228. /** @addtogroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions
  229. * @brief Timer Complementary One Pulse functions
  230. * @{
  231. */
  232. /* Timer Complementary One Pulse functions **********************************/
  233. /* Blocking mode: Polling */
  234. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  235. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  236. /* Non-Blocking mode: Interrupt */
  237. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  238. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  239. /**
  240. * @}
  241. */
  242. /** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions
  243. * @brief Peripheral Control functions
  244. * @{
  245. */
  246. /* Extended Control functions ************************************************/
  247. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
  248. uint32_t CommutationSource);
  249. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
  250. uint32_t CommutationSource);
  251. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
  252. uint32_t CommutationSource);
  253. HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim,
  254. const TIM_MasterConfigTypeDef *sMasterConfig);
  255. HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim,
  256. const TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig);
  257. #if defined(TIM_BREAK_INPUT_SUPPORT)
  258. HAL_StatusTypeDef HAL_TIMEx_ConfigBreakInput(TIM_HandleTypeDef *htim, uint32_t BreakInput,
  259. const TIMEx_BreakInputConfigTypeDef *sBreakInputConfig);
  260. #endif /* TIM_BREAK_INPUT_SUPPORT */
  261. HAL_StatusTypeDef HAL_TIMEx_GroupChannel5(TIM_HandleTypeDef *htim, uint32_t Channels);
  262. HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap);
  263. /**
  264. * @}
  265. */
  266. /** @addtogroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions
  267. * @brief Extended Callbacks functions
  268. * @{
  269. */
  270. /* Extended Callback **********************************************************/
  271. void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim);
  272. void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim);
  273. void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim);
  274. void HAL_TIMEx_Break2Callback(TIM_HandleTypeDef *htim);
  275. /**
  276. * @}
  277. */
  278. /** @addtogroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions
  279. * @brief Extended Peripheral State functions
  280. * @{
  281. */
  282. /* Extended Peripheral State functions ***************************************/
  283. HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(const TIM_HandleTypeDef *htim);
  284. HAL_TIM_ChannelStateTypeDef HAL_TIMEx_GetChannelNState(const TIM_HandleTypeDef *htim, uint32_t ChannelN);
  285. /**
  286. * @}
  287. */
  288. /**
  289. * @}
  290. */
  291. /* End of exported functions -------------------------------------------------*/
  292. /* Private functions----------------------------------------------------------*/
  293. /** @addtogroup TIMEx_Private_Functions TIM Extended Private Functions
  294. * @{
  295. */
  296. void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma);
  297. void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma);
  298. /**
  299. * @}
  300. */
  301. /* End of private functions --------------------------------------------------*/
  302. /**
  303. * @}
  304. */
  305. /**
  306. * @}
  307. */
  308. #ifdef __cplusplus
  309. }
  310. #endif
  311. #endif /* STM32F7xx_HAL_TIM_EX_H */