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