1 /** 2 ****************************************************************************** 3 * @file stm32f2xx_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 19 /* Define to prevent recursive inclusion -------------------------------------*/ 20 #ifndef STM32F2xx_HAL_TIM_EX_H 21 #define STM32F2xx_HAL_TIM_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32f2xx_hal_def.h" 29 30 /** @addtogroup STM32F2xx_HAL_Driver 31 * @{ 32 */ 33 34 /** @addtogroup TIMEx 35 * @{ 36 */ 37 38 /* Exported types ------------------------------------------------------------*/ 39 /** @defgroup TIMEx_Exported_Types TIM Extended Exported Types 40 * @{ 41 */ 42 43 /** 44 * @brief TIM Hall sensor Configuration Structure definition 45 */ 46 47 typedef struct 48 { 49 uint32_t IC1Polarity; /*!< Specifies the active edge of the input signal. 50 This parameter can be a value of @ref TIM_Input_Capture_Polarity */ 51 52 uint32_t IC1Prescaler; /*!< Specifies the Input Capture Prescaler. 53 This parameter can be a value of @ref TIM_Input_Capture_Prescaler */ 54 55 uint32_t IC1Filter; /*!< Specifies the input capture filter. 56 This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */ 57 58 uint32_t Commutation_Delay; /*!< Specifies the pulse value to be loaded into the Capture Compare Register. 59 This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */ 60 } TIM_HallSensor_InitTypeDef; 61 /** 62 * @} 63 */ 64 /* End of exported types -----------------------------------------------------*/ 65 66 /* Exported constants --------------------------------------------------------*/ 67 /** @defgroup TIMEx_Exported_Constants TIM Extended Exported Constants 68 * @{ 69 */ 70 71 /** @defgroup TIMEx_Remap TIM Extended Remapping 72 * @{ 73 */ 74 #define TIM_TIM2_TIM8_TRGO 0x00000000U /*!< TIM2 ITR1 is connected to TIM8 TRGO */ 75 #define TIM_TIM2_ETH_PTP TIM_OR_ITR1_RMP_0 /*!< TIM2 ITR1 is connected to PTP trigger output */ 76 #define TIM_TIM2_USBFS_SOF TIM_OR_ITR1_RMP_1 /*!< TIM2 ITR1 is connected to OTG FS SOF */ 77 #define TIM_TIM2_USBHS_SOF (TIM_OR_ITR1_RMP_1 | TIM_OR_ITR1_RMP_0) /*!< TIM2 ITR1 is connected to OTG HS SOF */ 78 79 #define TIM_TIM5_GPIO 0x00000000U /*!< TIM5 TI4 is connected to GPIO */ 80 #define TIM_TIM5_LSI TIM_OR_TI4_RMP_0 /*!< TIM5 TI4 is connected to LSI */ 81 #define TIM_TIM5_LSE TIM_OR_TI4_RMP_1 /*!< TIM5 TI4 is connected to LSE */ 82 #define TIM_TIM5_RTC (TIM_OR_TI4_RMP_1 | TIM_OR_TI4_RMP_0) /*!< TIM5 TI4 is connected to the RTC wakeup interrupt */ 83 84 #define TIM_TIM11_GPIO 0x00000000U /*!< TIM11 TI1 is connected to GPIO */ 85 #define TIM_TIM11_HSE TIM_OR_TI1_RMP_1 /*!< TIM11 TI1 is connected to HSE_RTC clock */ 86 /** 87 * @} 88 */ 89 90 /** 91 * @} 92 */ 93 /* End of exported constants -------------------------------------------------*/ 94 95 /* Exported macro ------------------------------------------------------------*/ 96 /** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros 97 * @{ 98 */ 99 100 /** 101 * @} 102 */ 103 /* End of exported macro -----------------------------------------------------*/ 104 105 /* Private macro -------------------------------------------------------------*/ 106 /** @defgroup TIMEx_Private_Macros TIM Extended Private Macros 107 * @{ 108 */ 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_HSE)))) 119 120 /** 121 * @} 122 */ 123 /* End of private macro ------------------------------------------------------*/ 124 125 /* Exported functions --------------------------------------------------------*/ 126 /** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions 127 * @{ 128 */ 129 130 /** @addtogroup TIMEx_Exported_Functions_Group1 Extended Timer Hall Sensor functions 131 * @brief Timer Hall Sensor functions 132 * @{ 133 */ 134 /* Timer Hall Sensor functions **********************************************/ 135 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, const TIM_HallSensor_InitTypeDef *sConfig); 136 HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim); 137 138 void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim); 139 void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim); 140 141 /* Blocking mode: Polling */ 142 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim); 143 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim); 144 /* Non-Blocking mode: Interrupt */ 145 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim); 146 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim); 147 /* Non-Blocking mode: DMA */ 148 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length); 149 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim); 150 /** 151 * @} 152 */ 153 154 /** @addtogroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions 155 * @brief Timer Complementary Output Compare functions 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 163 /* Non-Blocking mode: Interrupt */ 164 HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel); 165 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel); 166 167 /* Non-Blocking mode: DMA */ 168 HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData, 169 uint16_t Length); 170 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel); 171 /** 172 * @} 173 */ 174 175 /** @addtogroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions 176 * @brief Timer Complementary PWM functions 177 * @{ 178 */ 179 /* Timer Complementary PWM functions ****************************************/ 180 /* Blocking mode: Polling */ 181 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel); 182 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel); 183 184 /* Non-Blocking mode: Interrupt */ 185 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel); 186 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel); 187 /* Non-Blocking mode: DMA */ 188 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData, 189 uint16_t Length); 190 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel); 191 /** 192 * @} 193 */ 194 195 /** @addtogroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions 196 * @brief Timer Complementary One Pulse functions 197 * @{ 198 */ 199 /* Timer Complementary One Pulse functions **********************************/ 200 /* Blocking mode: Polling */ 201 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel); 202 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel); 203 204 /* Non-Blocking mode: Interrupt */ 205 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel); 206 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel); 207 /** 208 * @} 209 */ 210 211 /** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions 212 * @brief Peripheral Control functions 213 * @{ 214 */ 215 /* Extended Control functions ************************************************/ 216 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger, 217 uint32_t CommutationSource); 218 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger, 219 uint32_t CommutationSource); 220 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger, 221 uint32_t CommutationSource); 222 HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim, 223 const TIM_MasterConfigTypeDef *sMasterConfig); 224 HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim, 225 const TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig); 226 HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap); 227 /** 228 * @} 229 */ 230 231 /** @addtogroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions 232 * @brief Extended Callbacks functions 233 * @{ 234 */ 235 /* Extended Callback **********************************************************/ 236 void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim); 237 void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim); 238 void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim); 239 /** 240 * @} 241 */ 242 243 /** @addtogroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions 244 * @brief Extended Peripheral State functions 245 * @{ 246 */ 247 /* Extended Peripheral State functions ***************************************/ 248 HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(const TIM_HandleTypeDef *htim); 249 HAL_TIM_ChannelStateTypeDef HAL_TIMEx_GetChannelNState(const TIM_HandleTypeDef *htim, uint32_t ChannelN); 250 /** 251 * @} 252 */ 253 254 /** 255 * @} 256 */ 257 /* End of exported functions -------------------------------------------------*/ 258 259 /* Private functions----------------------------------------------------------*/ 260 /** @addtogroup TIMEx_Private_Functions TIM Extended Private Functions 261 * @{ 262 */ 263 void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma); 264 void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma); 265 /** 266 * @} 267 */ 268 /* End of private functions --------------------------------------------------*/ 269 270 /** 271 * @} 272 */ 273 274 /** 275 * @} 276 */ 277 278 #ifdef __cplusplus 279 } 280 #endif 281 282 283 #endif /* STM32F2xx_HAL_TIM_EX_H */ 284