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.
 
 

352 line
16 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_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 STM32F4xx_HAL_TIM_EX_H
  21. #define STM32F4xx_HAL_TIM_EX_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32f4xx_hal_def.h"
  27. /** @addtogroup STM32F4xx_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. #if defined (TIM2)
  63. #if defined(TIM8)
  64. #define TIM_TIM2_TIM8_TRGO 0x00000000U /*!< TIM2 ITR1 is connected to TIM8 TRGO */
  65. #else
  66. #define TIM_TIM2_ETH_PTP TIM_OR_ITR1_RMP_0 /*!< TIM2 ITR1 is connected to PTP trigger output */
  67. #endif /* TIM8 */
  68. #define TIM_TIM2_USBFS_SOF TIM_OR_ITR1_RMP_1 /*!< TIM2 ITR1 is connected to OTG FS SOF */
  69. #define TIM_TIM2_USBHS_SOF (TIM_OR_ITR1_RMP_1 | TIM_OR_ITR1_RMP_0) /*!< TIM2 ITR1 is connected to OTG HS SOF */
  70. #endif /* TIM2 */
  71. #define TIM_TIM5_GPIO 0x00000000U /*!< TIM5 TI4 is connected to GPIO */
  72. #define TIM_TIM5_LSI TIM_OR_TI4_RMP_0 /*!< TIM5 TI4 is connected to LSI */
  73. #define TIM_TIM5_LSE TIM_OR_TI4_RMP_1 /*!< TIM5 TI4 is connected to LSE */
  74. #define TIM_TIM5_RTC (TIM_OR_TI4_RMP_1 | TIM_OR_TI4_RMP_0) /*!< TIM5 TI4 is connected to the RTC wakeup interrupt */
  75. #define TIM_TIM11_GPIO 0x00000000U /*!< TIM11 TI1 is connected to GPIO */
  76. #define TIM_TIM11_HSE TIM_OR_TI1_RMP_1 /*!< TIM11 TI1 is connected to HSE_RTC clock */
  77. #if defined(SPDIFRX)
  78. #define TIM_TIM11_SPDIFRX TIM_OR_TI1_RMP_0 /*!< TIM11 TI1 is connected to SPDIFRX_FRAME_SYNC */
  79. #endif /* SPDIFRX*/
  80. #if defined(LPTIM_OR_TIM1_ITR2_RMP) && defined(LPTIM_OR_TIM5_ITR1_RMP) && defined(LPTIM_OR_TIM5_ITR1_RMP)
  81. #define LPTIM_REMAP_MASK 0x10000000U
  82. #define TIM_TIM9_TIM3_TRGO LPTIM_REMAP_MASK /*!< TIM9 ITR1 is connected to TIM3 TRGO */
  83. #define TIM_TIM9_LPTIM (LPTIM_REMAP_MASK | LPTIM_OR_TIM9_ITR1_RMP) /*!< TIM9 ITR1 is connected to LPTIM1 output */
  84. #define TIM_TIM5_TIM3_TRGO LPTIM_REMAP_MASK /*!< TIM5 ITR1 is connected to TIM3 TRGO */
  85. #define TIM_TIM5_LPTIM (LPTIM_REMAP_MASK | LPTIM_OR_TIM5_ITR1_RMP) /*!< TIM5 ITR1 is connected to LPTIM1 output */
  86. #define TIM_TIM1_TIM3_TRGO LPTIM_REMAP_MASK /*!< TIM1 ITR2 is connected to TIM3 TRGO */
  87. #define TIM_TIM1_LPTIM (LPTIM_REMAP_MASK | LPTIM_OR_TIM1_ITR2_RMP) /*!< TIM1 ITR2 is connected to LPTIM1 output */
  88. #endif /* LPTIM_OR_TIM1_ITR2_RMP && LPTIM_OR_TIM5_ITR1_RMP && LPTIM_OR_TIM5_ITR1_RMP */
  89. /**
  90. * @}
  91. */
  92. /**
  93. * @}
  94. */
  95. /* End of exported constants -------------------------------------------------*/
  96. /* Exported macro ------------------------------------------------------------*/
  97. /** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros
  98. * @{
  99. */
  100. /**
  101. * @}
  102. */
  103. /* End of exported macro -----------------------------------------------------*/
  104. /* Private macro -------------------------------------------------------------*/
  105. /** @defgroup TIMEx_Private_Macros TIM Extended Private Macros
  106. * @{
  107. */
  108. #if defined(SPDIFRX)
  109. #define IS_TIM_REMAP(INSTANCE, TIM_REMAP) \
  110. ((((INSTANCE) == TIM2) && (((TIM_REMAP) == TIM_TIM2_TIM8_TRGO) || \
  111. ((TIM_REMAP) == TIM_TIM2_USBFS_SOF) || \
  112. ((TIM_REMAP) == TIM_TIM2_USBHS_SOF))) || \
  113. (((INSTANCE) == TIM5) && (((TIM_REMAP) == TIM_TIM5_GPIO) || \
  114. ((TIM_REMAP) == TIM_TIM5_LSI) || \
  115. ((TIM_REMAP) == TIM_TIM5_LSE) || \
  116. ((TIM_REMAP) == TIM_TIM5_RTC))) || \
  117. (((INSTANCE) == TIM11) && (((TIM_REMAP) == TIM_TIM11_GPIO) || \
  118. ((TIM_REMAP) == TIM_TIM11_SPDIFRX) || \
  119. ((TIM_REMAP) == TIM_TIM11_HSE))))
  120. #elif defined(TIM2)
  121. #if defined(LPTIM_OR_TIM1_ITR2_RMP) && defined(LPTIM_OR_TIM5_ITR1_RMP) && defined(LPTIM_OR_TIM5_ITR1_RMP)
  122. #define IS_TIM_REMAP(INSTANCE, TIM_REMAP) \
  123. ((((INSTANCE) == TIM2) && (((TIM_REMAP) == TIM_TIM2_TIM8_TRGO) || \
  124. ((TIM_REMAP) == TIM_TIM2_USBFS_SOF) || \
  125. ((TIM_REMAP) == TIM_TIM2_USBHS_SOF))) || \
  126. (((INSTANCE) == TIM5) && (((TIM_REMAP) == TIM_TIM5_GPIO) || \
  127. ((TIM_REMAP) == TIM_TIM5_LSI) || \
  128. ((TIM_REMAP) == TIM_TIM5_LSE) || \
  129. ((TIM_REMAP) == TIM_TIM5_RTC))) || \
  130. (((INSTANCE) == TIM11) && (((TIM_REMAP) == TIM_TIM11_GPIO) || \
  131. ((TIM_REMAP) == TIM_TIM11_HSE))) || \
  132. (((INSTANCE) == TIM1) && (((TIM_REMAP) == TIM_TIM1_TIM3_TRGO) || \
  133. ((TIM_REMAP) == TIM_TIM1_LPTIM))) || \
  134. (((INSTANCE) == TIM5) && (((TIM_REMAP) == TIM_TIM5_TIM3_TRGO) || \
  135. ((TIM_REMAP) == TIM_TIM5_LPTIM))) || \
  136. (((INSTANCE) == TIM9) && (((TIM_REMAP) == TIM_TIM9_TIM3_TRGO) || \
  137. ((TIM_REMAP) == TIM_TIM9_LPTIM))))
  138. #elif defined(TIM8)
  139. #define IS_TIM_REMAP(INSTANCE, TIM_REMAP) \
  140. ((((INSTANCE) == TIM2) && (((TIM_REMAP) == TIM_TIM2_TIM8_TRGO) || \
  141. ((TIM_REMAP) == TIM_TIM2_USBFS_SOF) || \
  142. ((TIM_REMAP) == TIM_TIM2_USBHS_SOF))) || \
  143. (((INSTANCE) == TIM5) && (((TIM_REMAP) == TIM_TIM5_GPIO) || \
  144. ((TIM_REMAP) == TIM_TIM5_LSI) || \
  145. ((TIM_REMAP) == TIM_TIM5_LSE) || \
  146. ((TIM_REMAP) == TIM_TIM5_RTC))) || \
  147. (((INSTANCE) == TIM11) && (((TIM_REMAP) == TIM_TIM11_GPIO) || \
  148. ((TIM_REMAP) == TIM_TIM11_HSE))))
  149. #else
  150. #define IS_TIM_REMAP(INSTANCE, TIM_REMAP) \
  151. ((((INSTANCE) == TIM2) && (((TIM_REMAP) == TIM_TIM2_ETH_PTP) || \
  152. ((TIM_REMAP) == TIM_TIM2_USBFS_SOF) || \
  153. ((TIM_REMAP) == TIM_TIM2_USBHS_SOF))) || \
  154. (((INSTANCE) == TIM5) && (((TIM_REMAP) == TIM_TIM5_GPIO) || \
  155. ((TIM_REMAP) == TIM_TIM5_LSI) || \
  156. ((TIM_REMAP) == TIM_TIM5_LSE) || \
  157. ((TIM_REMAP) == TIM_TIM5_RTC))) || \
  158. (((INSTANCE) == TIM11) && (((TIM_REMAP) == TIM_TIM11_GPIO) || \
  159. ((TIM_REMAP) == TIM_TIM11_HSE))))
  160. #endif /* LPTIM_OR_TIM1_ITR2_RMP && LPTIM_OR_TIM5_ITR1_RMP && LPTIM_OR_TIM5_ITR1_RMP */
  161. #else
  162. #define IS_TIM_REMAP(INSTANCE, TIM_REMAP) \
  163. ((((INSTANCE) == TIM5) && (((TIM_REMAP) == TIM_TIM5_GPIO) || \
  164. ((TIM_REMAP) == TIM_TIM5_LSI) || \
  165. ((TIM_REMAP) == TIM_TIM5_LSE) || \
  166. ((TIM_REMAP) == TIM_TIM5_RTC))) || \
  167. (((INSTANCE) == TIM11) && (((TIM_REMAP) == TIM_TIM11_GPIO) || \
  168. ((TIM_REMAP) == TIM_TIM11_HSE))))
  169. #endif /* SPDIFRX */
  170. /**
  171. * @}
  172. */
  173. /* End of private macro ------------------------------------------------------*/
  174. /* Exported functions --------------------------------------------------------*/
  175. /** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions
  176. * @{
  177. */
  178. /** @addtogroup TIMEx_Exported_Functions_Group1 Extended Timer Hall Sensor functions
  179. * @brief Timer Hall Sensor functions
  180. * @{
  181. */
  182. /* Timer Hall Sensor functions **********************************************/
  183. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, TIM_HallSensor_InitTypeDef *sConfig);
  184. HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim);
  185. void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim);
  186. void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim);
  187. /* Blocking mode: Polling */
  188. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim);
  189. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim);
  190. /* Non-Blocking mode: Interrupt */
  191. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim);
  192. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim);
  193. /* Non-Blocking mode: DMA */
  194. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
  195. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim);
  196. /**
  197. * @}
  198. */
  199. /** @addtogroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions
  200. * @brief Timer Complementary Output Compare functions
  201. * @{
  202. */
  203. /* Timer Complementary Output Compare functions *****************************/
  204. /* Blocking mode: Polling */
  205. HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  206. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  207. /* Non-Blocking mode: Interrupt */
  208. HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  209. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  210. /* Non-Blocking mode: DMA */
  211. HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  212. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  213. /**
  214. * @}
  215. */
  216. /** @addtogroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions
  217. * @brief Timer Complementary PWM functions
  218. * @{
  219. */
  220. /* Timer Complementary PWM functions ****************************************/
  221. /* Blocking mode: Polling */
  222. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  223. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  224. /* Non-Blocking mode: Interrupt */
  225. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  226. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  227. /* Non-Blocking mode: DMA */
  228. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  229. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  230. /**
  231. * @}
  232. */
  233. /** @addtogroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions
  234. * @brief Timer Complementary One Pulse functions
  235. * @{
  236. */
  237. /* Timer Complementary One Pulse functions **********************************/
  238. /* Blocking mode: Polling */
  239. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  240. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  241. /* Non-Blocking mode: Interrupt */
  242. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  243. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  244. /**
  245. * @}
  246. */
  247. /** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions
  248. * @brief Peripheral Control functions
  249. * @{
  250. */
  251. /* Extended Control functions ************************************************/
  252. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger, uint32_t CommutationSource);
  253. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger, uint32_t CommutationSource);
  254. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger, uint32_t CommutationSource);
  255. HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim, TIM_MasterConfigTypeDef *sMasterConfig);
  256. HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim, TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig);
  257. HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap);
  258. /**
  259. * @}
  260. */
  261. /** @addtogroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions
  262. * @brief Extended Callbacks functions
  263. * @{
  264. */
  265. /* Extended Callback **********************************************************/
  266. void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim);
  267. void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim);
  268. void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim);
  269. /**
  270. * @}
  271. */
  272. /** @addtogroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions
  273. * @brief Extended Peripheral State functions
  274. * @{
  275. */
  276. /* Extended Peripheral State functions ***************************************/
  277. HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef *htim);
  278. /**
  279. * @}
  280. */
  281. /**
  282. * @}
  283. */
  284. /* End of exported functions -------------------------------------------------*/
  285. /* Private functions----------------------------------------------------------*/
  286. /** @defgroup TIMEx_Private_Functions TIM Extended Private Functions
  287. * @{
  288. */
  289. void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma);
  290. void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma);
  291. /**
  292. * @}
  293. */
  294. /* End of private functions --------------------------------------------------*/
  295. /**
  296. * @}
  297. */
  298. /**
  299. * @}
  300. */
  301. #ifdef __cplusplus
  302. }
  303. #endif
  304. #endif /* STM32F4xx_HAL_TIM_EX_H */
  305. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/