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.
 
 
 

397 lines
17 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32wbxx_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) 2019 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 STM32WBxx_HAL_TIM_EX_H
  21. #define STM32WBxx_HAL_TIM_EX_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32wbxx_hal_def.h"
  27. /** @addtogroup STM32WBxx_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. * @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. }
  63. TIMEx_BreakInputConfigTypeDef;
  64. /**
  65. * @}
  66. */
  67. /* End of exported types -----------------------------------------------------*/
  68. /* Exported constants --------------------------------------------------------*/
  69. /** @defgroup TIMEx_Exported_Constants TIM Extended Exported Constants
  70. * @{
  71. */
  72. /** @defgroup TIMEx_Remap TIM Extended Remapping
  73. * @{
  74. */
  75. #define TIM_TIM1_ETR_GPIO 0x00000000U /* !< TIM1_ETR is not connected to I/O */
  76. #define TIM_TIM1_ETR_ADC1_AWD1 TIM1_OR_ETR_ADC1_RMP_0 /* !< TIM1_ETR is connected to ADC1 AWD1 */
  77. #define TIM_TIM1_ETR_ADC1_AWD2 TIM1_OR_ETR_ADC1_RMP_1 /* !< TIM1_ETR is connected to ADC1 AWD2 */
  78. #define TIM_TIM1_ETR_ADC1_AWD3 (TIM1_OR_ETR_ADC1_RMP_0 | TIM1_OR_ETR_ADC1_RMP_1) /* !< TIM1_ETR is connected to ADC1 AWD3 */
  79. #if defined(COMP1)
  80. #define TIM_TIM1_ETR_COMP1 TIM1_AF1_ETRSEL_0 /* !< TIM1_ETR is connected to COMP1 output */
  81. #endif /* COMP1 */
  82. #if defined(COMP2)
  83. #define TIM_TIM1_ETR_COMP2 TIM1_AF1_ETRSEL_1 /* !< TIM1_ETR is connected to COMP2 output */
  84. #endif /* COMP2 */
  85. #define TIM_TIM1_TI1_GPIO 0x00000000U /* !< TIM1 Input capture 1 is connected to I/0 */
  86. #define TIM_TIM1_TI1_COMP1 TIM1_OR_TI1_RMP /* !< TIM1 Input capture 1is connected to COMP1 OUT */
  87. #define TIM_TIM2_ITR_NC 0x00000000U /* !< TIM2 Internal trigger ITR is not connected */
  88. #if defined(USB)
  89. #define TIM_TIM2_ITR_USB TIM2_OR_ITR1_RMP /* !< TIM2 Internal trigger ITR is connected to USBFS SOF */
  90. #endif /* USB */
  91. #define TIM_TIM2_ETR_GPIO 0x00000000U /* !< TIM2 External trigger ETR is connected to I/O */
  92. #define TIM_TIM2_ETR_LSE TIM2_OR_ETR_RMP /* !< TIM2 External trigger ETR is connected to LSE */
  93. #if defined(COMP1)
  94. #define TIM_TIM2_ETR_COMP1 TIM2_AF1_ETRSEL_0 /* !< TIM2_ETR is connected to COMP1 output */
  95. #endif /* COMP1 */
  96. #if defined(COMP2)
  97. #define TIM_TIM2_ETR_COMP2 TIM2_AF1_ETRSEL_1 /* !< TIM2_ETR is connected to COMP2 output */
  98. #endif /* COMP2 */
  99. #define TIM_TIM2_TI4_GPIO 0x00000000U /* !< TIM2_TI4 is connected to I/O */
  100. #if defined(COMP1)
  101. #define TIM_TIM2_TI4_COMP1 TIM2_OR_TI4_RMP_0 /* !< TIM2_TI4 is connected to COMP1 OUT */
  102. #endif /* COMP1 */
  103. #if defined(COMP2)
  104. #define TIM_TIM2_TI4_COMP2 TIM2_OR_TI4_RMP_1 /* !< TIM2_TI4 is connected to COMP1 OUT */
  105. #endif /* COMP2 */
  106. #if defined(COMP1) && defined(COMP2)
  107. #define TIM_TIM2_TI4_COMP1_COMP2 (TIM2_OR_TI4_RMP_0 | TIM2_OR_TI4_RMP_1) /* !< TIM2_TI4 is connected to COMP1 and COMP2 OUT */
  108. #endif /* COMP1 && COMP2 */
  109. #define TIM_TIM16_TI1_GPIO 0x00000000U /* !< TIM16_TI1 is connected to I/O */
  110. #define TIM_TIM16_TI1_LSI TIM16_OR_TI1_RMP_0 /* !< TIM16_TI1 is connected to LSI Clock */
  111. #define TIM_TIM16_TI1_LSE TIM16_OR_TI1_RMP_1 /* !< TIM16_TI1 is connected to LSE Clock */
  112. #define TIM_TIM16_TI1_RTC (TIM16_OR_TI1_RMP_0 | TIM16_OR_TI1_RMP_1) /* !< TIM16_TI1 is connected to RTC */
  113. #define TIM_TIM17_TI1_GPIO 0x00000000U /* !< TIM17_TI1 is connected to I/O */
  114. #define TIM_TIM17_TI1_MSI TIM17_OR_TI1_RMP_0 /* !< TIM17_TI1 is connected to MSI */
  115. #define TIM_TIM17_TI1_HSE TIM17_OR_TI1_RMP_1 /* !< TIM17_TI1 is connected to HSE/32 */
  116. #define TIM_TIM17_TI1_MCO (TIM17_OR_TI1_RMP_0 | TIM17_OR_TI1_RMP_1) /* !< TIM17_TI1 is connected to MCO */
  117. /**
  118. * @}
  119. */
  120. /** @defgroup TIMEx_Break_Input TIM Extended Break input
  121. * @{
  122. */
  123. #define TIM_BREAKINPUT_BRK 0x00000001U /* !< Timer break input */
  124. #define TIM_BREAKINPUT_BRK2 0x00000002U /* !< Timer break2 input */
  125. /**
  126. * @}
  127. */
  128. /** @defgroup TIMEx_Break_Input_Source TIM Extended Break input source
  129. * @{
  130. */
  131. #define TIM_BREAKINPUTSOURCE_BKIN 0x00000001U /* !< An external source (GPIO) is connected to the BKIN pin */
  132. #if defined(COMP1)
  133. #define TIM_BREAKINPUTSOURCE_COMP1 0x00000002U /* !< The COMP1 output is connected to the break input */
  134. #endif /* COMP1 */
  135. #if defined(COMP2)
  136. #define TIM_BREAKINPUTSOURCE_COMP2 0x00000004U /* !< The COMP2 output is connected to the break input */
  137. #endif /* COMP2 */
  138. /**
  139. * @}
  140. */
  141. /** @defgroup TIMEx_Break_Input_Source_Enable TIM Extended Break input source enabling
  142. * @{
  143. */
  144. #define TIM_BREAKINPUTSOURCE_DISABLE 0x00000000U /* !< Break input source is disabled */
  145. #define TIM_BREAKINPUTSOURCE_ENABLE 0x00000001U /* !< Break input source is enabled */
  146. /**
  147. * @}
  148. */
  149. /** @defgroup TIMEx_Break_Input_Source_Polarity TIM Extended Break input polarity
  150. * @{
  151. */
  152. #define TIM_BREAKINPUTSOURCE_POLARITY_LOW 0x00000001U /* !< Break input source is active low */
  153. #define TIM_BREAKINPUTSOURCE_POLARITY_HIGH 0x00000000U /* !< Break input source is active_high */
  154. /**
  155. * @}
  156. */
  157. /**
  158. * @}
  159. */
  160. /* End of exported constants -------------------------------------------------*/
  161. /* Exported macro ------------------------------------------------------------*/
  162. /** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros
  163. * @{
  164. */
  165. /**
  166. * @}
  167. */
  168. /* End of exported macro -----------------------------------------------------*/
  169. /* Private macro -------------------------------------------------------------*/
  170. /** @defgroup TIMEx_Private_Macros TIM Extended Private Macros
  171. * @{
  172. */
  173. #define IS_TIM_REMAP(__INSTANCE__, __REMAP__) \
  174. ((((__INSTANCE__) == TIM1) && ((((__REMAP__) & 0xFFFE3FECU) == 0x00000000U))) \
  175. || (((__INSTANCE__) == TIM2) && ((((__REMAP__) & 0xFFFE3FF0U) == 0x00000000U))) \
  176. || (((__INSTANCE__) == TIM16) && ((((__REMAP__) & 0xFFFFFFFCU) == 0x00000000U))) \
  177. || (((__INSTANCE__) == TIM17) && ((((__REMAP__) & 0xFFFFFFFCU) == 0x00000000U))))
  178. #define IS_TIM_BREAKINPUT(__BREAKINPUT__) \
  179. (((__BREAKINPUT__) == TIM_BREAKINPUT_BRK) || \
  180. ((__BREAKINPUT__) == TIM_BREAKINPUT_BRK2))
  181. #if defined(COMP1) && defined(COMP2)
  182. #define IS_TIM_BREAKINPUTSOURCE(__SOURCE__) \
  183. (((__SOURCE__) == TIM_BREAKINPUTSOURCE_BKIN) || \
  184. ((__SOURCE__) == TIM_BREAKINPUTSOURCE_COMP1) || \
  185. ((__SOURCE__) == TIM_BREAKINPUTSOURCE_COMP2))
  186. #else
  187. #define IS_TIM_BREAKINPUTSOURCE(__SOURCE__) \
  188. (((__SOURCE__) == TIM_BREAKINPUTSOURCE_BKIN))
  189. #endif
  190. #define IS_TIM_BREAKINPUTSOURCE_STATE(__STATE__) \
  191. (((__STATE__) == TIM_BREAKINPUTSOURCE_DISABLE) || \
  192. ((__STATE__) == TIM_BREAKINPUTSOURCE_ENABLE))
  193. #define IS_TIM_BREAKINPUTSOURCE_POLARITY(__POLARITY__) \
  194. (((__POLARITY__) == TIM_BREAKINPUTSOURCE_POLARITY_LOW) || \
  195. ((__POLARITY__) == TIM_BREAKINPUTSOURCE_POLARITY_HIGH))
  196. /**
  197. * @}
  198. */
  199. /* End of private macro ------------------------------------------------------*/
  200. /* Exported functions --------------------------------------------------------*/
  201. /** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions
  202. * @{
  203. */
  204. /** @addtogroup TIMEx_Exported_Functions_Group1 Extended Timer Hall Sensor functions
  205. * @brief Timer Hall Sensor functions
  206. * @{
  207. */
  208. /* Timer Hall Sensor functions **********************************************/
  209. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, TIM_HallSensor_InitTypeDef *sConfig);
  210. HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim);
  211. void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim);
  212. void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim);
  213. /* Blocking mode: Polling */
  214. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim);
  215. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim);
  216. /* Non-Blocking mode: Interrupt */
  217. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim);
  218. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim);
  219. /* Non-Blocking mode: DMA */
  220. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
  221. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim);
  222. /**
  223. * @}
  224. */
  225. /** @addtogroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions
  226. * @brief Timer Complementary Output Compare functions
  227. * @{
  228. */
  229. /* Timer Complementary Output Compare functions *****************************/
  230. /* Blocking mode: Polling */
  231. HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  232. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  233. /* Non-Blocking mode: Interrupt */
  234. HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  235. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  236. /* Non-Blocking mode: DMA */
  237. HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  238. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  239. /**
  240. * @}
  241. */
  242. /** @addtogroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions
  243. * @brief Timer Complementary PWM functions
  244. * @{
  245. */
  246. /* Timer Complementary PWM functions ****************************************/
  247. /* Blocking mode: Polling */
  248. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  249. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  250. /* Non-Blocking mode: Interrupt */
  251. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  252. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  253. /* Non-Blocking mode: DMA */
  254. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  255. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  256. /**
  257. * @}
  258. */
  259. /** @addtogroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions
  260. * @brief Timer Complementary One Pulse functions
  261. * @{
  262. */
  263. /* Timer Complementary One Pulse functions **********************************/
  264. /* Blocking mode: Polling */
  265. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  266. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  267. /* Non-Blocking mode: Interrupt */
  268. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  269. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  270. /**
  271. * @}
  272. */
  273. /** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions
  274. * @brief Peripheral Control functions
  275. * @{
  276. */
  277. /* Extended Control functions ************************************************/
  278. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
  279. uint32_t CommutationSource);
  280. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
  281. uint32_t CommutationSource);
  282. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
  283. uint32_t CommutationSource);
  284. HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim,
  285. TIM_MasterConfigTypeDef *sMasterConfig);
  286. HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim,
  287. TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig);
  288. HAL_StatusTypeDef HAL_TIMEx_ConfigBreakInput(TIM_HandleTypeDef *htim, uint32_t BreakInput,
  289. TIMEx_BreakInputConfigTypeDef *sBreakInputConfig);
  290. HAL_StatusTypeDef HAL_TIMEx_GroupChannel5(TIM_HandleTypeDef *htim, uint32_t Channels);
  291. HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap);
  292. /**
  293. * @}
  294. */
  295. /** @addtogroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions
  296. * @brief Extended Callbacks functions
  297. * @{
  298. */
  299. /* Extended Callback **********************************************************/
  300. void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim);
  301. void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim);
  302. void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim);
  303. void HAL_TIMEx_Break2Callback(TIM_HandleTypeDef *htim);
  304. /**
  305. * @}
  306. */
  307. /** @addtogroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions
  308. * @brief Extended Peripheral State functions
  309. * @{
  310. */
  311. /* Extended Peripheral State functions ***************************************/
  312. HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef *htim);
  313. /**
  314. * @}
  315. */
  316. /**
  317. * @}
  318. */
  319. /* End of exported functions -------------------------------------------------*/
  320. /* Private functions----------------------------------------------------------*/
  321. /** @addtogroup TIMEx_Private_Functions TIMEx Private Functions
  322. * @{
  323. */
  324. void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma);
  325. void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma);
  326. /**
  327. * @}
  328. */
  329. /* End of private functions --------------------------------------------------*/
  330. /**
  331. * @}
  332. */
  333. /**
  334. * @}
  335. */
  336. #ifdef __cplusplus
  337. }
  338. #endif
  339. #endif /* STM32WBxx_HAL_TIM_EX_H */
  340. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/