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.
 
 
 

326 lines
13 KiB

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