stm32f2xx_hal_tim_ex.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /**
  2. ******************************************************************************
  3. * @file stm32f2xx_hal_tim_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of TIM HAL Extended module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32F2xx_HAL_TIM_EX_H
  21. #define STM32F2xx_HAL_TIM_EX_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32f2xx_hal_def.h"
  27. /** @addtogroup STM32F2xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup TIMEx
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /** @defgroup TIMEx_Exported_Types TIM Extended Exported Types
  35. * @{
  36. */
  37. /**
  38. * @brief TIM Hall sensor Configuration Structure definition
  39. */
  40. typedef struct
  41. {
  42. uint32_t IC1Polarity; /*!< Specifies the active edge of the input signal.
  43. This parameter can be a value of @ref TIM_Input_Capture_Polarity */
  44. uint32_t IC1Prescaler; /*!< Specifies the Input Capture Prescaler.
  45. This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
  46. uint32_t IC1Filter; /*!< Specifies the input capture filter.
  47. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  48. uint32_t Commutation_Delay; /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
  49. This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
  50. } TIM_HallSensor_InitTypeDef;
  51. /**
  52. * @}
  53. */
  54. /* End of exported types -----------------------------------------------------*/
  55. /* Exported constants --------------------------------------------------------*/
  56. /** @defgroup TIMEx_Exported_Constants TIM Extended Exported Constants
  57. * @{
  58. */
  59. /** @defgroup TIMEx_Remap TIM Extended Remapping
  60. * @{
  61. */
  62. #define TIM_TIM2_TIM8_TRGO 0x00000000U /*!< TIM2 ITR1 is connected to TIM8 TRGO */
  63. #define TIM_TIM2_ETH_PTP TIM_OR_ITR1_RMP_0 /*!< TIM2 ITR1 is connected to PTP trigger output */
  64. #define TIM_TIM2_USBFS_SOF TIM_OR_ITR1_RMP_1 /*!< TIM2 ITR1 is connected to OTG FS SOF */
  65. #define TIM_TIM2_USBHS_SOF (TIM_OR_ITR1_RMP_1 | TIM_OR_ITR1_RMP_0) /*!< TIM2 ITR1 is connected to OTG HS SOF */
  66. #define TIM_TIM5_GPIO 0x00000000U /*!< TIM5 TI4 is connected to GPIO */
  67. #define TIM_TIM5_LSI TIM_OR_TI4_RMP_0 /*!< TIM5 TI4 is connected to LSI */
  68. #define TIM_TIM5_LSE TIM_OR_TI4_RMP_1 /*!< TIM5 TI4 is connected to LSE */
  69. #define TIM_TIM5_RTC (TIM_OR_TI4_RMP_1 | TIM_OR_TI4_RMP_0) /*!< TIM5 TI4 is connected to the RTC wakeup interrupt */
  70. #define TIM_TIM11_GPIO 0x00000000U /*!< TIM11 TI1 is connected to GPIO */
  71. #define TIM_TIM11_HSE TIM_OR_TI1_RMP_1 /*!< TIM11 TI1 is connected to HSE_RTC clock */
  72. /**
  73. * @}
  74. */
  75. /**
  76. * @}
  77. */
  78. /* End of exported constants -------------------------------------------------*/
  79. /* Exported macro ------------------------------------------------------------*/
  80. /** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros
  81. * @{
  82. */
  83. /**
  84. * @}
  85. */
  86. /* End of exported macro -----------------------------------------------------*/
  87. /* Private macro -------------------------------------------------------------*/
  88. /** @defgroup TIMEx_Private_Macros TIM Extended Private Macros
  89. * @{
  90. */
  91. #define IS_TIM_REMAP(INSTANCE, TIM_REMAP) \
  92. ((((INSTANCE) == TIM2) && (((TIM_REMAP) == TIM_TIM2_TIM8_TRGO) || \
  93. ((TIM_REMAP) == TIM_TIM2_USBFS_SOF) || \
  94. ((TIM_REMAP) == TIM_TIM2_USBHS_SOF))) || \
  95. (((INSTANCE) == TIM5) && (((TIM_REMAP) == TIM_TIM5_GPIO) || \
  96. ((TIM_REMAP) == TIM_TIM5_LSI) || \
  97. ((TIM_REMAP) == TIM_TIM5_LSE) || \
  98. ((TIM_REMAP) == TIM_TIM5_RTC))) || \
  99. (((INSTANCE) == TIM11) && (((TIM_REMAP) == TIM_TIM11_GPIO) || \
  100. ((TIM_REMAP) == TIM_TIM11_HSE))))
  101. /**
  102. * @}
  103. */
  104. /* End of private macro ------------------------------------------------------*/
  105. /* Exported functions --------------------------------------------------------*/
  106. /** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions
  107. * @{
  108. */
  109. /** @addtogroup TIMEx_Exported_Functions_Group1 Extended Timer Hall Sensor functions
  110. * @brief Timer Hall Sensor functions
  111. * @{
  112. */
  113. /* Timer Hall Sensor functions **********************************************/
  114. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, TIM_HallSensor_InitTypeDef *sConfig);
  115. HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim);
  116. void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim);
  117. void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim);
  118. /* Blocking mode: Polling */
  119. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim);
  120. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim);
  121. /* Non-Blocking mode: Interrupt */
  122. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim);
  123. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim);
  124. /* Non-Blocking mode: DMA */
  125. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
  126. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim);
  127. /**
  128. * @}
  129. */
  130. /** @addtogroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions
  131. * @brief Timer Complementary Output Compare functions
  132. * @{
  133. */
  134. /* Timer Complementary Output Compare functions *****************************/
  135. /* Blocking mode: Polling */
  136. HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  137. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  138. /* Non-Blocking mode: Interrupt */
  139. HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  140. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  141. /* Non-Blocking mode: DMA */
  142. HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  143. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  144. /**
  145. * @}
  146. */
  147. /** @addtogroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions
  148. * @brief Timer Complementary PWM functions
  149. * @{
  150. */
  151. /* Timer Complementary PWM functions ****************************************/
  152. /* Blocking mode: Polling */
  153. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  154. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  155. /* Non-Blocking mode: Interrupt */
  156. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  157. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  158. /* Non-Blocking mode: DMA */
  159. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  160. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  161. /**
  162. * @}
  163. */
  164. /** @addtogroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions
  165. * @brief Timer Complementary One Pulse functions
  166. * @{
  167. */
  168. /* Timer Complementary One Pulse functions **********************************/
  169. /* Blocking mode: Polling */
  170. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  171. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  172. /* Non-Blocking mode: Interrupt */
  173. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  174. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  175. /**
  176. * @}
  177. */
  178. /** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions
  179. * @brief Peripheral Control functions
  180. * @{
  181. */
  182. /* Extended Control functions ************************************************/
  183. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
  184. uint32_t CommutationSource);
  185. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
  186. uint32_t CommutationSource);
  187. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
  188. uint32_t CommutationSource);
  189. HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim,
  190. TIM_MasterConfigTypeDef *sMasterConfig);
  191. HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim,
  192. TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig);
  193. HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap);
  194. /**
  195. * @}
  196. */
  197. /** @addtogroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions
  198. * @brief Extended Callbacks functions
  199. * @{
  200. */
  201. /* Extended Callback **********************************************************/
  202. void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim);
  203. void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim);
  204. void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim);
  205. /**
  206. * @}
  207. */
  208. /** @addtogroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions
  209. * @brief Extended Peripheral State functions
  210. * @{
  211. */
  212. /* Extended Peripheral State functions ***************************************/
  213. HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef *htim);
  214. /**
  215. * @}
  216. */
  217. /**
  218. * @}
  219. */
  220. /* End of exported functions -------------------------------------------------*/
  221. /* Private functions----------------------------------------------------------*/
  222. /** @addtogroup TIMEx_Private_Functions TIMEx Private Functions
  223. * @{
  224. */
  225. void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma);
  226. void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma);
  227. /**
  228. * @}
  229. */
  230. /* End of private functions --------------------------------------------------*/
  231. /**
  232. * @}
  233. */
  234. /**
  235. * @}
  236. */
  237. #ifdef __cplusplus
  238. }
  239. #endif
  240. #endif /* STM32F2xx_HAL_TIM_EX_H */
  241. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/