stm32f3xx_hal_tim_ex.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. /**
  2. ******************************************************************************
  3. * @file stm32f3xx_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) 2016 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 STM32F3xx_HAL_TIM_EX_H
  20. #define STM32F3xx_HAL_TIM_EX_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f3xx_hal_def.h"
  26. /** @addtogroup STM32F3xx_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. /**
  51. * @}
  52. */
  53. /* End of exported types -----------------------------------------------------*/
  54. /* Exported constants --------------------------------------------------------*/
  55. /** @defgroup TIMEx_Exported_Constants TIM Extended Exported Constants
  56. * @{
  57. */
  58. /** @defgroup TIMEx_Remap TIM Extended Remapping
  59. * @{
  60. */
  61. #if defined(TIM1)
  62. #define TIM_TIM1_ADC1_NONE (0x00000000U) /*!< TIM1_ETR is not connected to any AWD (analog watchdog)*/
  63. #define TIM_TIM1_ADC1_AWD1 (0x00000001U) /*!< TIM1_ETR is connected to ADC1 AWD1 */
  64. #define TIM_TIM1_ADC1_AWD2 (0x00000002U) /*!< TIM1_ETR is connected to ADC1 AWD2 */
  65. #define TIM_TIM1_ADC1_AWD3 (0x00000003U) /*!< TIM1_ETR is connected to ADC1 AWD3 */
  66. #if defined(ADC4)
  67. #define TIM_TIM1_ADC4_NONE (0x00000000U) /*!< TIM1_ETR is not connected to any AWD (analog watchdog)*/
  68. #define TIM_TIM1_ADC4_AWD1 (0x00000004U) /*!< TIM1_ETR is connected to ADC4 AWD1 */
  69. #define TIM_TIM1_ADC4_AWD2 (0x00000008U) /*!< TIM1_ETR is connected to ADC4 AWD2 */
  70. #define TIM_TIM1_ADC4_AWD3 (0x0000000CU) /*!< TIM1_ETR is connected to ADC4 AWD3 */
  71. #elif defined(ADC2)
  72. #define TIM_TIM1_ADC2_NONE (0x00000000U) /*!< TIM1_ETR is not connected to any AWD (analog watchdog)*/
  73. #define TIM_TIM1_ADC2_AWD1 (0x00000004U) /*!< TIM1_ETR is connected to ADC2 AWD1 */
  74. #define TIM_TIM1_ADC2_AWD2 (0x00000008U) /*!< TIM1_ETR is connected to ADC2 AWD2 */
  75. #define TIM_TIM1_ADC2_AWD3 (0x0000000CU) /*!< TIM1_ETR is connected to ADC2 AWD3 */
  76. #endif /* ADC4 */
  77. #endif /* TIM1 */
  78. #if defined(TIM8)
  79. #define TIM_TIM8_ADC2_NONE (0x00000000U) /*!< TIM8_ETR is not connected to any AWD (analog watchdog) */
  80. #define TIM_TIM8_ADC2_AWD1 (0x00000001U) /*!< TIM8_ETR is connected to ADC2 AWD1 */
  81. #define TIM_TIM8_ADC2_AWD2 (0x00000002U) /*!< TIM8_ETR is connected to ADC2 AWD2 */
  82. #define TIM_TIM8_ADC2_AWD3 (0x00000003U) /*!< TIM8_ETR is connected to ADC2 AWD3 */
  83. #define TIM_TIM8_ADC3_NONE (0x00000000U) /*!< TIM8_ETR is not connected to any AWD (analog watchdog) */
  84. #define TIM_TIM8_ADC3_AWD1 (0x00000004U) /*!< TIM8_ETR is connected to ADC3 AWD1 */
  85. #define TIM_TIM8_ADC3_AWD2 (0x00000008U) /*!< TIM8_ETR is connected to ADC3 AWD2 */
  86. #define TIM_TIM8_ADC3_AWD3 (0x0000000CU) /*!< TIM8_ETR is connected to ADC3 AWD3 */
  87. #endif /* TIM8 */
  88. #if defined(TIM14)
  89. #define TIM_TIM14_GPIO (0x00000000U) /*!< TIM14 TI1 is connected to GPIO */
  90. #define TIM_TIM14_RTC (0x00000001U) /*!< TIM14 TI1 is connected to RTC_clock */
  91. #define TIM_TIM14_HSE (0x00000002U) /*!< TIM14 TI1 is connected to HSE/32U */
  92. #define TIM_TIM14_MCO (0x00000003U) /*!< TIM14 TI1 is connected to MCO */
  93. #endif /* TIM14 */
  94. #if defined(TIM16)
  95. #define TIM_TIM16_GPIO (0x00000000U) /*!< TIM16 TI1 is connected to GPIO */
  96. #define TIM_TIM16_RTC (0x00000001U) /*!< TIM16 TI1 is connected to RTC_clock */
  97. #define TIM_TIM16_HSE (0x00000002U) /*!< TIM16 TI1 is connected to HSE/32 */
  98. #define TIM_TIM16_MCO (0x00000003U) /*!< TIM16 TI1 is connected to MCO */
  99. #endif /* TIM16 */
  100. #if defined(TIM20)
  101. #define TIM_TIM20_ADC3_NONE (0x00000000U) /*!< TIM20_ETR is not connected to any AWD (analog watchdog) */
  102. #define TIM_TIM20_ADC3_AWD1 (0x00000001U) /*!< TIM20_ETR is connected to ADC3 AWD1 */
  103. #define TIM_TIM20_ADC3_AWD2 (0x00000002U) /*!< TIM20_ETR is connected to ADC3 AWD2 */
  104. #define TIM_TIM20_ADC3_AWD3 (0x00000003U) /*!< TIM20_ETR is connected to ADC3 AWD3 */
  105. #define TIM_TIM20_ADC4_NONE (0x00000000U) /*!< TIM20_ETR is not connected to any AWD (analog watchdog) */
  106. #define TIM_TIM20_ADC4_AWD1 (0x00000004U) /*!< TIM20_ETR is connected to ADC4 AWD1 */
  107. #define TIM_TIM20_ADC4_AWD2 (0x00000008U) /*!< TIM20_ETR is connected to ADC4 AWD2 */
  108. #define TIM_TIM20_ADC4_AWD3 (0x0000000CU) /*!< TIM20_ETR is connected to ADC4 AWD3 */
  109. #endif /* TIM20 */
  110. /**
  111. * @}
  112. */
  113. /**
  114. * @}
  115. */
  116. /* End of exported constants -------------------------------------------------*/
  117. /* Exported macro ------------------------------------------------------------*/
  118. /** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros
  119. * @{
  120. */
  121. /**
  122. * @}
  123. */
  124. /* End of exported macro -----------------------------------------------------*/
  125. /* Private macro -------------------------------------------------------------*/
  126. /** @defgroup TIMEx_Private_Macros TIM Extended Private Macros
  127. * @{
  128. */
  129. #if defined(TIM1) && defined(TIM8) && defined(TIM20) && defined(TIM16)
  130. #define IS_TIM_REMAP(__INSTANCE__, __REMAP__) \
  131. ((((__INSTANCE__) == TIM1) && ((((__REMAP__) & 0xFFFFFFF0U) == 0x00000000U))) \
  132. || (((__INSTANCE__) == TIM8) && ((((__REMAP__) & 0xFFFFFFF0U) == 0x00000000U))) \
  133. || (((__INSTANCE__) == TIM20) && ((((__REMAP__) & 0xFFFFFFF0U) == 0x00000000U))) \
  134. || (((__INSTANCE__) == TIM16) && ((((__REMAP__) & 0xFFFFFFFCU) == 0x00000000U))))
  135. #elif defined(TIM1) && defined(TIM8) && defined(TIM16)
  136. #define IS_TIM_REMAP(__INSTANCE__, __REMAP__) \
  137. ((((__INSTANCE__) == TIM1) && ((((__REMAP__) & 0xFFFFFFF0U) == 0x00000000U))) \
  138. || (((__INSTANCE__) == TIM8) && ((((__REMAP__) & 0xFFFFFFF0U) == 0x00000000U))) \
  139. || (((__INSTANCE__) == TIM16) && ((((__REMAP__) & 0xFFFFFFFCU) == 0x00000000U))))
  140. #elif defined(TIM1) && defined(TIM16)
  141. #define IS_TIM_REMAP(__INSTANCE__, __REMAP__) \
  142. ((((__INSTANCE__) == TIM1) && ((((__REMAP__) & 0xFFFFFFF0U) == 0x00000000U))) \
  143. || (((__INSTANCE__) == TIM16) && ((((__REMAP__) & 0xFFFFFFFCU) == 0x00000000U))))
  144. #elif defined(TIM14)
  145. #define IS_TIM_REMAP(__INSTANCE__, __REMAP__) \
  146. (((__INSTANCE__) == TIM14) && (((__REMAP__) & 0xFFFFFFFCU) == 0x00000000U))
  147. #endif /* TIM1 && TIM8 && TIM20 && TIM16 */
  148. /**
  149. * @}
  150. */
  151. /* End of private macro ------------------------------------------------------*/
  152. /* Exported functions --------------------------------------------------------*/
  153. /** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions
  154. * @{
  155. */
  156. /** @addtogroup TIMEx_Exported_Functions_Group1 Extended Timer Hall Sensor functions
  157. * @brief Timer Hall Sensor functions
  158. * @{
  159. */
  160. /* Timer Hall Sensor functions **********************************************/
  161. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, const TIM_HallSensor_InitTypeDef *sConfig);
  162. HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim);
  163. void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim);
  164. void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim);
  165. /* Blocking mode: Polling */
  166. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim);
  167. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim);
  168. /* Non-Blocking mode: Interrupt */
  169. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim);
  170. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim);
  171. /* Non-Blocking mode: DMA */
  172. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
  173. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim);
  174. /**
  175. * @}
  176. */
  177. /** @addtogroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions
  178. * @brief Timer Complementary Output Compare functions
  179. * @{
  180. */
  181. /* Timer Complementary Output Compare functions *****************************/
  182. /* Blocking mode: Polling */
  183. HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  184. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  185. /* Non-Blocking mode: Interrupt */
  186. HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  187. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  188. /* Non-Blocking mode: DMA */
  189. HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData,
  190. uint16_t Length);
  191. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  192. /**
  193. * @}
  194. */
  195. /** @addtogroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions
  196. * @brief Timer Complementary PWM functions
  197. * @{
  198. */
  199. /* Timer Complementary PWM functions ****************************************/
  200. /* Blocking mode: Polling */
  201. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  202. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  203. /* Non-Blocking mode: Interrupt */
  204. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  205. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  206. /* Non-Blocking mode: DMA */
  207. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData,
  208. uint16_t Length);
  209. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  210. /**
  211. * @}
  212. */
  213. /** @addtogroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions
  214. * @brief Timer Complementary One Pulse functions
  215. * @{
  216. */
  217. /* Timer Complementary One Pulse functions **********************************/
  218. /* Blocking mode: Polling */
  219. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  220. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  221. /* Non-Blocking mode: Interrupt */
  222. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  223. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  224. /**
  225. * @}
  226. */
  227. /** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions
  228. * @brief Peripheral Control functions
  229. * @{
  230. */
  231. /* Extended Control functions ************************************************/
  232. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
  233. uint32_t CommutationSource);
  234. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
  235. uint32_t CommutationSource);
  236. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
  237. uint32_t CommutationSource);
  238. HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim,
  239. const TIM_MasterConfigTypeDef *sMasterConfig);
  240. HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim,
  241. const TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig);
  242. #if defined(TIM_CCR5_CCR5)
  243. HAL_StatusTypeDef HAL_TIMEx_GroupChannel5(TIM_HandleTypeDef *htim, uint32_t Channels);
  244. #endif /* TIM_CCR5_CCR5 */
  245. HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap);
  246. /**
  247. * @}
  248. */
  249. /** @addtogroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions
  250. * @brief Extended Callbacks functions
  251. * @{
  252. */
  253. /* Extended Callback **********************************************************/
  254. void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim);
  255. void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim);
  256. void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim);
  257. #if defined(TIM_BDTR_BK2E)
  258. void HAL_TIMEx_Break2Callback(TIM_HandleTypeDef *htim);
  259. #endif /* TIM_BDTR_BK2E */
  260. /**
  261. * @}
  262. */
  263. /** @addtogroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions
  264. * @brief Extended Peripheral State functions
  265. * @{
  266. */
  267. /* Extended Peripheral State functions ***************************************/
  268. HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(const TIM_HandleTypeDef *htim);
  269. HAL_TIM_ChannelStateTypeDef HAL_TIMEx_GetChannelNState(const TIM_HandleTypeDef *htim, uint32_t ChannelN);
  270. /**
  271. * @}
  272. */
  273. /**
  274. * @}
  275. */
  276. /* End of exported functions -------------------------------------------------*/
  277. /* Private functions----------------------------------------------------------*/
  278. /** @addtogroup TIMEx_Private_Functions TIM Extended Private Functions
  279. * @{
  280. */
  281. void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma);
  282. void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma);
  283. /**
  284. * @}
  285. */
  286. /* End of private functions --------------------------------------------------*/
  287. /**
  288. * @}
  289. */
  290. /**
  291. * @}
  292. */
  293. #ifdef __cplusplus
  294. }
  295. #endif
  296. #endif /* STM32F3xx_HAL_TIM_EX_H */