STM32F479xx HAL User Manual
stm32f4xx_hal_tim_ex.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4xx_hal_tim_ex.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of TIM HAL Extended module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
00010   * All rights reserved.</center></h2>
00011   *
00012   * This software component is licensed by ST under BSD 3-Clause license,
00013   * the "License"; You may not use this file except in compliance with the
00014   * License. You may obtain a copy of the License at:
00015   *                        opensource.org/licenses/BSD-3-Clause
00016   *
00017   ******************************************************************************
00018   */
00019 
00020 /* Define to prevent recursive inclusion -------------------------------------*/
00021 #ifndef STM32F4xx_HAL_TIM_EX_H
00022 #define STM32F4xx_HAL_TIM_EX_H
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 /* Includes ------------------------------------------------------------------*/
00029 #include "stm32f4xx_hal_def.h"
00030 
00031 /** @addtogroup STM32F4xx_HAL_Driver
00032   * @{
00033   */
00034 
00035 /** @addtogroup TIMEx
00036   * @{
00037   */
00038 
00039 /* Exported types ------------------------------------------------------------*/
00040 /** @defgroup TIMEx_Exported_Types TIM Extended Exported Types
00041   * @{
00042   */
00043 
00044 /**
00045   * @brief  TIM Hall sensor Configuration Structure definition
00046   */
00047 
00048 typedef struct
00049 {
00050   uint32_t IC1Polarity;         /*!< Specifies the active edge of the input signal.
00051                                      This parameter can be a value of @ref TIM_Input_Capture_Polarity */
00052 
00053   uint32_t IC1Prescaler;        /*!< Specifies the Input Capture Prescaler.
00054                                      This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
00055 
00056   uint32_t IC1Filter;           /*!< Specifies the input capture filter.
00057                                      This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
00058 
00059   uint32_t Commutation_Delay;   /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
00060                                      This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
00061 } TIM_HallSensor_InitTypeDef;
00062 /**
00063   * @}
00064   */
00065 /* End of exported types -----------------------------------------------------*/
00066 
00067 /* Exported constants --------------------------------------------------------*/
00068 /** @defgroup TIMEx_Exported_Constants TIM Extended Exported Constants
00069   * @{
00070   */
00071 
00072 /** @defgroup TIMEx_Remap TIM Extended Remapping
00073   * @{
00074   */
00075 #if defined (TIM2)
00076 #if defined(TIM8)
00077 #define TIM_TIM2_TIM8_TRGO                     0x00000000U                              /*!< TIM2 ITR1 is connected to TIM8 TRGO */
00078 #else
00079 #define TIM_TIM2_ETH_PTP                       TIM_OR_ITR1_RMP_0                        /*!< TIM2 ITR1 is connected to PTP trigger output */
00080 #endif /*  TIM8 */
00081 #define TIM_TIM2_USBFS_SOF                     TIM_OR_ITR1_RMP_1                        /*!< TIM2 ITR1 is connected to OTG FS SOF */
00082 #define TIM_TIM2_USBHS_SOF                     (TIM_OR_ITR1_RMP_1 | TIM_OR_ITR1_RMP_0)  /*!< TIM2 ITR1 is connected to OTG HS SOF */
00083 #endif /* TIM2 */
00084 
00085 #define TIM_TIM5_GPIO                          0x00000000U                              /*!< TIM5 TI4 is connected to GPIO */
00086 #define TIM_TIM5_LSI                           TIM_OR_TI4_RMP_0                         /*!< TIM5 TI4 is connected to LSI */
00087 #define TIM_TIM5_LSE                           TIM_OR_TI4_RMP_1                         /*!< TIM5 TI4 is connected to LSE */
00088 #define TIM_TIM5_RTC                           (TIM_OR_TI4_RMP_1 | TIM_OR_TI4_RMP_0)    /*!< TIM5 TI4 is connected to the RTC wakeup interrupt */
00089 
00090 #define TIM_TIM11_GPIO                         0x00000000U                              /*!< TIM11 TI1 is connected to GPIO */
00091 #define TIM_TIM11_HSE                          TIM_OR_TI1_RMP_1                         /*!< TIM11 TI1 is connected to HSE_RTC clock */
00092 #if defined(SPDIFRX)
00093 #define TIM_TIM11_SPDIFRX                      TIM_OR_TI1_RMP_0                         /*!< TIM11 TI1 is connected to SPDIFRX_FRAME_SYNC */
00094 #endif /* SPDIFRX*/
00095 
00096 #if defined(LPTIM_OR_TIM1_ITR2_RMP) && defined(LPTIM_OR_TIM5_ITR1_RMP) && defined(LPTIM_OR_TIM5_ITR1_RMP)
00097 #define LPTIM_REMAP_MASK                       0x10000000U
00098 
00099 #define TIM_TIM9_TIM3_TRGO                     LPTIM_REMAP_MASK                             /*!< TIM9 ITR1 is connected to TIM3 TRGO */
00100 #define TIM_TIM9_LPTIM                         (LPTIM_REMAP_MASK | LPTIM_OR_TIM9_ITR1_RMP)  /*!< TIM9 ITR1 is connected to LPTIM1 output */
00101 
00102 #define TIM_TIM5_TIM3_TRGO                     LPTIM_REMAP_MASK                             /*!< TIM5 ITR1 is connected to TIM3 TRGO */
00103 #define TIM_TIM5_LPTIM                         (LPTIM_REMAP_MASK | LPTIM_OR_TIM5_ITR1_RMP)  /*!< TIM5 ITR1 is connected to LPTIM1 output */
00104 
00105 #define TIM_TIM1_TIM3_TRGO                     LPTIM_REMAP_MASK                             /*!< TIM1 ITR2 is connected to TIM3 TRGO */
00106 #define TIM_TIM1_LPTIM                         (LPTIM_REMAP_MASK | LPTIM_OR_TIM1_ITR2_RMP)  /*!< TIM1 ITR2 is connected to LPTIM1 output */
00107 #endif /* LPTIM_OR_TIM1_ITR2_RMP &&  LPTIM_OR_TIM5_ITR1_RMP && LPTIM_OR_TIM5_ITR1_RMP */
00108 /**
00109   * @}
00110   */
00111 
00112 /**
00113   * @}
00114   */
00115 /* End of exported constants -------------------------------------------------*/
00116 
00117 /* Exported macro ------------------------------------------------------------*/
00118 /** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros
00119   * @{
00120   */
00121 
00122 /**
00123   * @}
00124   */
00125 /* End of exported macro -----------------------------------------------------*/
00126 
00127 /* Private macro -------------------------------------------------------------*/
00128 /** @defgroup TIMEx_Private_Macros TIM Extended Private Macros
00129   * @{
00130   */
00131 #if defined(SPDIFRX)
00132 #define IS_TIM_REMAP(INSTANCE, TIM_REMAP)                                 \
00133   ((((INSTANCE) == TIM2)  && (((TIM_REMAP) == TIM_TIM2_TIM8_TRGO)      || \
00134                               ((TIM_REMAP) == TIM_TIM2_USBFS_SOF)      || \
00135                               ((TIM_REMAP) == TIM_TIM2_USBHS_SOF)))    || \
00136    (((INSTANCE) == TIM5)  && (((TIM_REMAP) == TIM_TIM5_GPIO)           || \
00137                               ((TIM_REMAP) == TIM_TIM5_LSI)            || \
00138                               ((TIM_REMAP) == TIM_TIM5_LSE)            || \
00139                               ((TIM_REMAP) == TIM_TIM5_RTC)))          || \
00140    (((INSTANCE) == TIM11) && (((TIM_REMAP) == TIM_TIM11_GPIO)          || \
00141                               ((TIM_REMAP) == TIM_TIM11_SPDIFRX)       || \
00142                               ((TIM_REMAP) == TIM_TIM11_HSE))))
00143 #elif defined(TIM2)
00144 #if defined(LPTIM_OR_TIM1_ITR2_RMP) && defined(LPTIM_OR_TIM5_ITR1_RMP) && defined(LPTIM_OR_TIM5_ITR1_RMP)
00145 #define IS_TIM_REMAP(INSTANCE, TIM_REMAP)                                 \
00146   ((((INSTANCE) == TIM2)  && (((TIM_REMAP) == TIM_TIM2_TIM8_TRGO)      || \
00147                               ((TIM_REMAP) == TIM_TIM2_USBFS_SOF)      || \
00148                               ((TIM_REMAP) == TIM_TIM2_USBHS_SOF)))    || \
00149    (((INSTANCE) == TIM5)  && (((TIM_REMAP) == TIM_TIM5_GPIO)           || \
00150                               ((TIM_REMAP) == TIM_TIM5_LSI)            || \
00151                               ((TIM_REMAP) == TIM_TIM5_LSE)            || \
00152                               ((TIM_REMAP) == TIM_TIM5_RTC)))          || \
00153    (((INSTANCE) == TIM11) && (((TIM_REMAP) == TIM_TIM11_GPIO)          || \
00154                               ((TIM_REMAP) == TIM_TIM11_HSE)))         || \
00155    (((INSTANCE) == TIM1)  && (((TIM_REMAP) == TIM_TIM1_TIM3_TRGO)      || \
00156                               ((TIM_REMAP) == TIM_TIM1_LPTIM)))        || \
00157    (((INSTANCE) == TIM5)  && (((TIM_REMAP) == TIM_TIM5_TIM3_TRGO)      || \
00158                               ((TIM_REMAP) == TIM_TIM5_LPTIM)))        || \
00159    (((INSTANCE) == TIM9)  && (((TIM_REMAP) == TIM_TIM9_TIM3_TRGO)      || \
00160                               ((TIM_REMAP) == TIM_TIM9_LPTIM))))
00161 #elif defined(TIM8)
00162 #define IS_TIM_REMAP(INSTANCE, TIM_REMAP)                                 \
00163   ((((INSTANCE) == TIM2)  && (((TIM_REMAP) == TIM_TIM2_TIM8_TRGO)      || \
00164                               ((TIM_REMAP) == TIM_TIM2_USBFS_SOF)      || \
00165                               ((TIM_REMAP) == TIM_TIM2_USBHS_SOF)))    || \
00166    (((INSTANCE) == TIM5)  && (((TIM_REMAP) == TIM_TIM5_GPIO)           || \
00167                               ((TIM_REMAP) == TIM_TIM5_LSI)            || \
00168                               ((TIM_REMAP) == TIM_TIM5_LSE)            || \
00169                               ((TIM_REMAP) == TIM_TIM5_RTC)))          || \
00170    (((INSTANCE) == TIM11) && (((TIM_REMAP) == TIM_TIM11_GPIO)          || \
00171                               ((TIM_REMAP) == TIM_TIM11_HSE))))
00172 #else
00173 #define IS_TIM_REMAP(INSTANCE, TIM_REMAP)                                 \
00174   ((((INSTANCE) == TIM2)  && (((TIM_REMAP) == TIM_TIM2_ETH_PTP)        || \
00175                               ((TIM_REMAP) == TIM_TIM2_USBFS_SOF)      || \
00176                               ((TIM_REMAP) == TIM_TIM2_USBHS_SOF)))    || \
00177    (((INSTANCE) == TIM5)  && (((TIM_REMAP) == TIM_TIM5_GPIO)           || \
00178                               ((TIM_REMAP) == TIM_TIM5_LSI)            || \
00179                               ((TIM_REMAP) == TIM_TIM5_LSE)            || \
00180                               ((TIM_REMAP) == TIM_TIM5_RTC)))          || \
00181    (((INSTANCE) == TIM11) && (((TIM_REMAP) == TIM_TIM11_GPIO)          || \
00182                               ((TIM_REMAP) == TIM_TIM11_HSE))))
00183 #endif /* LPTIM_OR_TIM1_ITR2_RMP &&  LPTIM_OR_TIM5_ITR1_RMP && LPTIM_OR_TIM5_ITR1_RMP */
00184 #else
00185 #define IS_TIM_REMAP(INSTANCE, TIM_REMAP)                                 \
00186   ((((INSTANCE) == TIM5)  && (((TIM_REMAP) == TIM_TIM5_GPIO)           || \
00187                               ((TIM_REMAP) == TIM_TIM5_LSI)            || \
00188                               ((TIM_REMAP) == TIM_TIM5_LSE)            || \
00189                               ((TIM_REMAP) == TIM_TIM5_RTC)))          || \
00190    (((INSTANCE) == TIM11) && (((TIM_REMAP) == TIM_TIM11_GPIO)          || \
00191                               ((TIM_REMAP) == TIM_TIM11_HSE))))
00192 #endif /* SPDIFRX */
00193 
00194 /**
00195   * @}
00196   */
00197 /* End of private macro ------------------------------------------------------*/
00198 
00199 /* Exported functions --------------------------------------------------------*/
00200 /** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions
00201   * @{
00202   */
00203 
00204 /** @addtogroup TIMEx_Exported_Functions_Group1 Extended Timer Hall Sensor functions
00205   *  @brief    Timer Hall Sensor functions
00206   * @{
00207   */
00208 /*  Timer Hall Sensor functions  **********************************************/
00209 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, TIM_HallSensor_InitTypeDef *sConfig);
00210 HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim);
00211 
00212 void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim);
00213 void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim);
00214 
00215 /* Blocking mode: Polling */
00216 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim);
00217 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim);
00218 /* Non-Blocking mode: Interrupt */
00219 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim);
00220 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim);
00221 /* Non-Blocking mode: DMA */
00222 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
00223 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim);
00224 /**
00225   * @}
00226   */
00227 
00228 /** @addtogroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions
00229   *  @brief   Timer Complementary Output Compare functions
00230   * @{
00231   */
00232 /*  Timer Complementary Output Compare functions  *****************************/
00233 /* Blocking mode: Polling */
00234 HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
00235 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
00236 
00237 /* Non-Blocking mode: Interrupt */
00238 HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
00239 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
00240 
00241 /* Non-Blocking mode: DMA */
00242 HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
00243 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
00244 /**
00245   * @}
00246   */
00247 
00248 /** @addtogroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions
00249   *  @brief    Timer Complementary PWM functions
00250   * @{
00251   */
00252 /*  Timer Complementary PWM functions  ****************************************/
00253 /* Blocking mode: Polling */
00254 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
00255 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
00256 
00257 /* Non-Blocking mode: Interrupt */
00258 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
00259 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
00260 /* Non-Blocking mode: DMA */
00261 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
00262 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
00263 /**
00264   * @}
00265   */
00266 
00267 /** @addtogroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions
00268   *  @brief    Timer Complementary One Pulse functions
00269   * @{
00270   */
00271 /*  Timer Complementary One Pulse functions  **********************************/
00272 /* Blocking mode: Polling */
00273 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
00274 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
00275 
00276 /* Non-Blocking mode: Interrupt */
00277 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
00278 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
00279 /**
00280   * @}
00281   */
00282 
00283 /** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions
00284   *  @brief    Peripheral Control functions
00285   * @{
00286   */
00287 /* Extended Control functions  ************************************************/
00288 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent(TIM_HandleTypeDef *htim, uint32_t  InputTrigger,
00289                                               uint32_t  CommutationSource);
00290 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_IT(TIM_HandleTypeDef *htim, uint32_t  InputTrigger,
00291                                                  uint32_t  CommutationSource);
00292 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_DMA(TIM_HandleTypeDef *htim, uint32_t  InputTrigger,
00293                                                   uint32_t  CommutationSource);
00294 HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim,
00295                                                         TIM_MasterConfigTypeDef *sMasterConfig);
00296 HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim,
00297                                                 TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig);
00298 HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap);
00299 /**
00300   * @}
00301   */
00302 
00303 /** @addtogroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions
00304   * @brief    Extended Callbacks functions
00305   * @{
00306   */
00307 /* Extended Callback **********************************************************/
00308 void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim);
00309 void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim);
00310 void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim);
00311 /**
00312   * @}
00313   */
00314 
00315 /** @addtogroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions
00316   * @brief    Extended Peripheral State functions
00317   * @{
00318   */
00319 /* Extended Peripheral State functions  ***************************************/
00320 HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef *htim);
00321 HAL_TIM_ChannelStateTypeDef HAL_TIMEx_GetChannelNState(TIM_HandleTypeDef *htim,  uint32_t ChannelN);
00322 /**
00323   * @}
00324   */
00325 
00326 /**
00327   * @}
00328   */
00329 /* End of exported functions -------------------------------------------------*/
00330 
00331 /* Private functions----------------------------------------------------------*/
00332 /** @addtogroup TIMEx_Private_Functions TIMEx Private Functions
00333   * @{
00334   */
00335 void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma);
00336 void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma);
00337 /**
00338   * @}
00339   */
00340 /* End of private functions --------------------------------------------------*/
00341 
00342 /**
00343   * @}
00344   */
00345 
00346 /**
00347   * @}
00348   */
00349 
00350 #ifdef __cplusplus
00351 }
00352 #endif
00353 
00354 
00355 #endif /* STM32F4xx_HAL_TIM_EX_H */
00356 
00357 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/