stm32f1xx_hal_tim_ex.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_hal_tim_ex.h
  4. * @author MCD Application Team
  5. * @version V1.0.4
  6. * @date 29-April-2016
  7. * @brief Header file of TIM HAL Extension module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32F1xx_HAL_TIM_EX_H
  39. #define __STM32F1xx_HAL_TIM_EX_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32f1xx_hal_def.h"
  45. /** @addtogroup STM32F1xx_HAL_Driver
  46. * @{
  47. */
  48. /** @addtogroup TIMEx
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /** @defgroup TIMEx_Exported_Types TIMEx Exported Types
  53. * @{
  54. */
  55. /**
  56. * @brief TIM Hall sensor Configuration Structure definition
  57. */
  58. typedef struct
  59. {
  60. uint32_t IC1Polarity; /*!< Specifies the active edge of the input signal.
  61. This parameter can be a value of @ref TIM_Input_Capture_Polarity */
  62. uint32_t IC1Prescaler; /*!< Specifies the Input Capture Prescaler.
  63. This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
  64. uint32_t IC1Filter; /*!< Specifies the input capture filter.
  65. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  66. uint32_t Commutation_Delay; /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
  67. This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
  68. } TIM_HallSensor_InitTypeDef;
  69. #if defined (STM32F100xB) || defined (STM32F100xE) || \
  70. defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F103xE) || defined (STM32F103xG) || \
  71. defined (STM32F105xC) || defined (STM32F107xC)
  72. /**
  73. * @brief TIM Break and Dead time configuration Structure definition
  74. */
  75. typedef struct
  76. {
  77. uint32_t OffStateRunMode; /*!< TIM off state in run mode
  78. This parameter can be a value of @ref TIM_OSSR_Off_State_Selection_for_Run_mode_state */
  79. uint32_t OffStateIDLEMode; /*!< TIM off state in IDLE mode
  80. This parameter can be a value of @ref TIM_OSSI_Off_State_Selection_for_Idle_mode_state */
  81. uint32_t LockLevel; /*!< TIM Lock level
  82. This parameter can be a value of @ref TIM_Lock_level */
  83. uint32_t DeadTime; /*!< TIM dead Time
  84. This parameter can be a number between Min_Data = 0x00 and Max_Data = 0xFF */
  85. uint32_t BreakState; /*!< TIM Break State
  86. This parameter can be a value of @ref TIM_Break_Input_enable_disable */
  87. uint32_t BreakPolarity; /*!< TIM Break input polarity
  88. This parameter can be a value of @ref TIM_Break_Polarity */
  89. uint32_t AutomaticOutput; /*!< TIM Automatic Output Enable state
  90. This parameter can be a value of @ref TIM_AOE_Bit_Set_Reset */
  91. } TIM_BreakDeadTimeConfigTypeDef;
  92. #endif /* defined(STM32F100xB) || defined(STM32F100xE) || */
  93. /* defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG) || */
  94. /* defined(STM32F105xC) || defined(STM32F107xC) */
  95. /**
  96. * @brief TIM Master configuration Structure definition
  97. */
  98. typedef struct {
  99. uint32_t MasterOutputTrigger; /*!< Trigger output (TRGO) selection
  100. This parameter can be a value of @ref TIM_Master_Mode_Selection */
  101. uint32_t MasterSlaveMode; /*!< Master/slave mode selection
  102. This parameter can be a value of @ref TIM_Master_Slave_Mode */
  103. }TIM_MasterConfigTypeDef;
  104. /**
  105. * @}
  106. */
  107. /* Exported constants --------------------------------------------------------*/
  108. #if defined (STM32F100xB) || defined (STM32F100xE) || \
  109. defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F103xE) || defined (STM32F103xG) || \
  110. defined (STM32F105xC) || defined (STM32F107xC)
  111. /** @defgroup TIMEx_Exported_Constants TIMEx Exported Constants
  112. * @{
  113. */
  114. /** @defgroup TIMEx_Clock_Filter TIMEx Clock Filter
  115. * @{
  116. */
  117. #define IS_TIM_DEADTIME(DEADTIME) ((DEADTIME) <= 0xFF) /*!< BreakDead Time */
  118. /**
  119. * @}
  120. */
  121. /**
  122. * @}
  123. */
  124. #endif /* defined(STM32F100xB) || defined(STM32F100xE) || */
  125. /* defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG) || */
  126. /* defined(STM32F105xC) || defined(STM32F107xC) */
  127. /* Exported macro ------------------------------------------------------------*/
  128. /* Exported functions --------------------------------------------------------*/
  129. /** @addtogroup TIMEx_Exported_Functions
  130. * @{
  131. */
  132. /** @addtogroup TIMEx_Exported_Functions_Group1
  133. * @{
  134. */
  135. /* Timer Hall Sensor functions **********************************************/
  136. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, TIM_HallSensor_InitTypeDef* sConfig);
  137. HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim);
  138. void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim);
  139. void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim);
  140. /* Blocking mode: Polling */
  141. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim);
  142. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim);
  143. /* Non-Blocking mode: Interrupt */
  144. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim);
  145. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim);
  146. /* Non-Blocking mode: DMA */
  147. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
  148. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim);
  149. /**
  150. * @}
  151. */
  152. #if defined (STM32F100xB) || defined (STM32F100xE) || \
  153. defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F103xE) || defined (STM32F103xG) || \
  154. defined (STM32F105xC) || defined (STM32F107xC)
  155. /** @addtogroup TIMEx_Exported_Functions_Group2
  156. * @{
  157. */
  158. /* Timer Complementary Output Compare functions *****************************/
  159. /* Blocking mode: Polling */
  160. HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  161. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  162. /* Non-Blocking mode: Interrupt */
  163. HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  164. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  165. /* Non-Blocking mode: DMA */
  166. HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  167. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  168. /**
  169. * @}
  170. */
  171. /** @addtogroup TIMEx_Exported_Functions_Group3
  172. * @{
  173. */
  174. /* Timer Complementary PWM functions ****************************************/
  175. /* Blocking mode: Polling */
  176. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  177. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  178. /* Non-Blocking mode: Interrupt */
  179. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  180. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  181. /* Non-Blocking mode: DMA */
  182. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  183. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  184. /**
  185. * @}
  186. */
  187. /** @addtogroup TIMEx_Exported_Functions_Group4
  188. * @{
  189. */
  190. /* Timer Complementary One Pulse functions **********************************/
  191. /* Blocking mode: Polling */
  192. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  193. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  194. /* Non-Blocking mode: Interrupt */
  195. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  196. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  197. /**
  198. * @}
  199. */
  200. #endif /* defined(STM32F100xB) || defined(STM32F100xE) || */
  201. /* defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG) || */
  202. /* defined(STM32F105xC) || defined(STM32F107xC) */
  203. /** @addtogroup TIMEx_Exported_Functions_Group5
  204. * @{
  205. */
  206. /* Extended Control functions ************************************************/
  207. #if defined (STM32F100xB) || defined (STM32F100xE) || \
  208. defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F103xE) || defined (STM32F103xG) || \
  209. defined (STM32F105xC) || defined (STM32F107xC)
  210. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger, uint32_t CommutationSource);
  211. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger, uint32_t CommutationSource);
  212. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger, uint32_t CommutationSource);
  213. HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim, TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig);
  214. #endif /* defined(STM32F100xB) || defined(STM32F100xE) || */
  215. /* defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG) || */
  216. /* defined(STM32F105xC) || defined(STM32F107xC) */
  217. HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim, TIM_MasterConfigTypeDef * sMasterConfig);
  218. /**
  219. * @}
  220. */
  221. /** @addtogroup TIMEx_Exported_Functions_Group6
  222. * @{
  223. */
  224. /* Extension Callback *********************************************************/
  225. void HAL_TIMEx_CommutationCallback(TIM_HandleTypeDef *htim);
  226. void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim);
  227. /**
  228. * @}
  229. */
  230. #if defined (STM32F100xB) || defined (STM32F100xE) || \
  231. defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F103xE) || defined (STM32F103xG) || \
  232. defined (STM32F105xC) || defined (STM32F107xC)
  233. /** @addtogroup TIMEx_Exported_Functions_Group7
  234. * @{
  235. */
  236. /* Extension Peripheral State functions **************************************/
  237. HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef *htim);
  238. /**
  239. * @}
  240. */
  241. #endif /* defined(STM32F100xB) || defined(STM32F100xE) || */
  242. /* defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG) || */
  243. /* defined(STM32F105xC) || defined(STM32F107xC) */
  244. /**
  245. * @}
  246. */
  247. /* End of exported functions -------------------------------------------------*/
  248. /* Private functions----------------------------------------------------------*/
  249. /** @defgroup TIMEx_Private_Functions TIMEx Private Functions
  250. * @{
  251. */
  252. void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma);
  253. /**
  254. * @}
  255. */
  256. /* End of private functions --------------------------------------------------*/
  257. /**
  258. * @}
  259. */
  260. /**
  261. * @}
  262. */
  263. #ifdef __cplusplus
  264. }
  265. #endif
  266. #endif /* __STM32F1xx_HAL_TIM_EX_H */
  267. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/