STM32F439xx 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 Extension module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
00010   *
00011   * Redistribution and use in source and binary forms, with or without modification,
00012   * are permitted provided that the following conditions are met:
00013   *   1. Redistributions of source code must retain the above copyright notice,
00014   *      this list of conditions and the following disclaimer.
00015   *   2. Redistributions in binary form must reproduce the above copyright notice,
00016   *      this list of conditions and the following disclaimer in the documentation
00017   *      and/or other materials provided with the distribution.
00018   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00019   *      may be used to endorse or promote products derived from this software
00020   *      without specific prior written permission.
00021   *
00022   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00023   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00025   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00026   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00027   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00028   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00030   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00031   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032   *
00033   ******************************************************************************
00034   */ 
00035 
00036 /* Define to prevent recursive inclusion -------------------------------------*/
00037 #ifndef __STM32F4xx_HAL_TIM_EX_H
00038 #define __STM32F4xx_HAL_TIM_EX_H
00039 
00040 #ifdef __cplusplus
00041  extern "C" {
00042 #endif
00043 
00044 /* Includes ------------------------------------------------------------------*/
00045 #include "stm32f4xx_hal_def.h"
00046 
00047 /** @addtogroup STM32F4xx_HAL_Driver
00048   * @{
00049   */
00050 
00051 /** @addtogroup TIMEx
00052   * @{
00053   */ 
00054 
00055 /* Exported types ------------------------------------------------------------*/ 
00056 /** @defgroup TIMEx_Exported_Types TIM Exported Types
00057   * @{
00058   */
00059   
00060 /** 
00061   * @brief  TIM Hall sensor Configuration Structure definition  
00062   */
00063 
00064 typedef struct
00065 {
00066 
00067   uint32_t IC1Polarity;            /*!< Specifies the active edge of the input signal.
00068                                         This parameter can be a value of @ref TIM_Input_Capture_Polarity */
00069 
00070   uint32_t IC1Prescaler;        /*!< Specifies the Input Capture Prescaler.
00071                                      This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
00072 
00073   uint32_t IC1Filter;           /*!< Specifies the input capture filter.
00074                                      This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
00075 
00076   uint32_t Commutation_Delay;  /*!< Specifies the pulse value to be loaded into the Capture Compare Register. 
00077                                     This parameter can be a number between Min_Data = 0x0000U and Max_Data = 0xFFFFU */
00078 } TIM_HallSensor_InitTypeDef;
00079 
00080 /** 
00081   * @brief  TIM Master configuration Structure definition  
00082   */ 
00083 typedef struct {
00084   uint32_t  MasterOutputTrigger;   /*!< Trigger output (TRGO) selection. 
00085                                       This parameter can be a value of @ref TIM_Master_Mode_Selection */
00086 
00087   uint32_t  MasterSlaveMode;       /*!< Master/slave mode selection. 
00088                                       This parameter can be a value of @ref TIM_Master_Slave_Mode */
00089 }TIM_MasterConfigTypeDef;
00090 
00091 /** 
00092   * @brief  TIM Break and Dead time configuration Structure definition  
00093   */ 
00094 typedef struct
00095 {
00096   uint32_t OffStateRunMode;            /*!< TIM off state in run mode.
00097                                          This parameter can be a value of @ref TIM_OSSR_Off_State_Selection_for_Run_mode_state */
00098   uint32_t OffStateIDLEMode;          /*!< TIM off state in IDLE mode.
00099                                          This parameter can be a value of @ref TIM_OSSI_Off_State_Selection_for_Idle_mode_state */
00100   uint32_t LockLevel;                     /*!< TIM Lock level.
00101                                          This parameter can be a value of @ref TIM_Lock_level */                             
00102   uint32_t DeadTime;                     /*!< TIM dead Time. 
00103                                          This parameter can be a number between Min_Data = 0x00 and Max_Data = 0xFF */
00104   uint32_t BreakState;                   /*!< TIM Break State. 
00105                                          This parameter can be a value of @ref TIM_Break_Input_enable_disable */
00106   uint32_t BreakPolarity;                 /*!< TIM Break input polarity. 
00107                                          This parameter can be a value of @ref TIM_Break_Polarity */
00108   uint32_t AutomaticOutput;               /*!< TIM Automatic Output Enable state. 
00109                                          This parameter can be a value of @ref TIM_AOE_Bit_Set_Reset */           
00110 }TIM_BreakDeadTimeConfigTypeDef;
00111 /**
00112   * @}
00113   */
00114   
00115 /* Exported constants --------------------------------------------------------*/
00116 /** @defgroup TIMEx_Exported_Constants  TIM Exported Constants
00117   * @{
00118   */
00119   
00120 /** @defgroup TIMEx_Remap  TIM Remap
00121   * @{
00122   */
00123 #define TIM_TIM2_TIM8_TRGO                     0x00000000U
00124 #define TIM_TIM2_ETH_PTP                       0x00000400U
00125 #define TIM_TIM2_USBFS_SOF                     0x00000800U
00126 #define TIM_TIM2_USBHS_SOF                     0x00000C00U
00127 #define TIM_TIM5_GPIO                          0x00000000U
00128 #define TIM_TIM5_LSI                           0x00000040U
00129 #define TIM_TIM5_LSE                           0x00000080U
00130 #define TIM_TIM5_RTC                           0x000000C0U
00131 #define TIM_TIM11_GPIO                         0x00000000U
00132 #define TIM_TIM11_HSE                          0x00000002U
00133 
00134 #if defined(STM32F413xx) || defined(STM32F423xx)
00135 #define TIM_TIM9_TIM3_TRGO                     0x10000000U
00136 #define TIM_TIM9_LPTIM                         0x10000010U
00137 #define TIM_TIM5_TIM3_TRGO                     0x10000000U
00138 #define TIM_TIM5_LPTIM                         0x10000008U
00139 #define TIM_TIM1_TIM3_TRGO                     0x10000000U
00140 #define TIM_TIM1_LPTIM                         0x10000004U
00141 #endif /* STM32F413xx | STM32F423xx */
00142 
00143 #if defined (STM32F446xx) 
00144 #define TIM_TIM11_SPDIFRX                      0x00000001U
00145 #endif /* STM32F446xx */
00146 /**
00147   * @}
00148   */
00149 
00150 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F413xx) || defined(STM32F423xx)
00151 /** @defgroup TIMEx_SystemBreakInput  TIM System Break Input
00152   * @{
00153   */
00154 #define TIM_SYSTEMBREAKINPUT_HARDFAULT     0x00000001U /* Core Lockup lock output(Hardfault) is connected to Break Input of TIM1 and TIM8 */
00155 #define TIM_SYSTEMBREAKINPUT_PVD           0x00000004U /* PVD Interrupt is connected to Break Input of TIM1 and TIM8 */
00156 #define TIM_SYSTEMBREAKINPUT_HARDFAULT_PVD 0x00000005U /* Core Lockup lock output(Hardfault) and PVD Interrupt are connected to Break Input of TIM1 and TIM8 */   
00157 /**
00158   * @}
00159   */
00160 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx || STM32F413xx || STM32F423xx */
00161 
00162 /**
00163   * @}
00164   */ 
00165 /* Exported macro ------------------------------------------------------------*/
00166 /* Exported functions --------------------------------------------------------*/
00167 /** @addtogroup TIMEx_Exported_Functions
00168   * @{
00169   */
00170 
00171 /** @addtogroup TIMEx_Exported_Functions_Group1
00172   * @{
00173   */
00174 /*  Timer Hall Sensor functions  **********************************************/
00175 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef* htim, TIM_HallSensor_InitTypeDef* sConfig);
00176 HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef* htim);
00177 
00178 void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef* htim);
00179 void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef* htim);
00180 
00181  /* Blocking mode: Polling */
00182 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef* htim);
00183 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef* htim);
00184 /* Non-Blocking mode: Interrupt */
00185 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef* htim);
00186 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef* htim);
00187 /* Non-Blocking mode: DMA */
00188 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef* htim, uint32_t *pData, uint16_t Length);
00189 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef* htim);
00190 /**
00191   * @}
00192   */
00193 
00194 /** @addtogroup TIMEx_Exported_Functions_Group2
00195   * @{
00196   */
00197 /*  Timer Complementary Output Compare functions  *****************************/
00198 /* Blocking mode: Polling */
00199 HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef* htim, uint32_t Channel);
00200 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef* htim, uint32_t Channel);
00201 
00202 /* Non-Blocking mode: Interrupt */
00203 HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef* htim, uint32_t Channel);
00204 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef* htim, uint32_t Channel);
00205 
00206 /* Non-Blocking mode: DMA */
00207 HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef* htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
00208 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef* htim, uint32_t Channel);
00209 /**
00210   * @}
00211   */
00212 
00213 /** @addtogroup TIMEx_Exported_Functions_Group3
00214   * @{
00215   */
00216 /*  Timer Complementary PWM functions  ****************************************/
00217 /* Blocking mode: Polling */
00218 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef* htim, uint32_t Channel);
00219 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef* htim, uint32_t Channel);
00220 
00221 /* Non-Blocking mode: Interrupt */
00222 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef* htim, uint32_t Channel);
00223 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef* htim, uint32_t Channel);
00224 /* Non-Blocking mode: DMA */
00225 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef* htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
00226 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef* htim, uint32_t Channel);
00227 /**
00228   * @}
00229   */
00230 
00231 /** @addtogroup TIMEx_Exported_Functions_Group4
00232   * @{
00233   */
00234 /*  Timer Complementary One Pulse functions  **********************************/
00235 /* Blocking mode: Polling */
00236 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef* htim, uint32_t OutputChannel);
00237 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef* htim, uint32_t OutputChannel);
00238 
00239 /* Non-Blocking mode: Interrupt */
00240 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef* htim, uint32_t OutputChannel);
00241 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef* htim, uint32_t OutputChannel);
00242 /**
00243   * @}
00244   */
00245 
00246 /** @addtogroup TIMEx_Exported_Functions_Group5
00247   * @{
00248   */
00249 /* Extension Control functions  ************************************************/
00250 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent(TIM_HandleTypeDef* htim, uint32_t  InputTrigger, uint32_t  CommutationSource);
00251 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent_IT(TIM_HandleTypeDef* htim, uint32_t  InputTrigger, uint32_t  CommutationSource);
00252 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent_DMA(TIM_HandleTypeDef* htim, uint32_t  InputTrigger, uint32_t  CommutationSource);
00253 HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef* htim, TIM_MasterConfigTypeDef * sMasterConfig);
00254 HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef* htim, TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig);
00255 HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef* htim, uint32_t Remap);
00256 /**
00257   * @}
00258   */
00259 
00260 /** @addtogroup TIMEx_Exported_Functions_Group6
00261   * @{
00262   */ 
00263 /* Extension Callback *********************************************************/
00264 void HAL_TIMEx_CommutationCallback(TIM_HandleTypeDef* htim);
00265 void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef* htim);
00266 void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma);
00267 /**
00268   * @}
00269   */
00270 
00271 /** @addtogroup TIMEx_Exported_Functions_Group7
00272   * @{
00273   */
00274 /* Extension Peripheral State functions  **************************************/
00275 HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef* htim);
00276 /**
00277   * @}
00278   */ 
00279 
00280 /**
00281   * @}
00282   */ 
00283 
00284 /* Private types -------------------------------------------------------------*/
00285 /* Private variables ---------------------------------------------------------*/
00286 /* Private constants ---------------------------------------------------------*/
00287 /* Private macros ------------------------------------------------------------*/
00288 /** @defgroup TIMEx_Private_Macros TIM Private Macros
00289   * @{
00290   */
00291 #if defined (STM32F446xx) 
00292 #define IS_TIM_REMAP(TIM_REMAP)   (((TIM_REMAP) == TIM_TIM2_TIM8_TRGO)||\
00293                                   ((TIM_REMAP) == TIM_TIM2_ETH_PTP)||\
00294                                   ((TIM_REMAP) == TIM_TIM2_USBFS_SOF)||\
00295                                   ((TIM_REMAP) == TIM_TIM2_USBHS_SOF)||\
00296                                   ((TIM_REMAP) == TIM_TIM5_GPIO)||\
00297                                   ((TIM_REMAP) == TIM_TIM5_LSI)||\
00298                                   ((TIM_REMAP) == TIM_TIM5_LSE)||\
00299                                   ((TIM_REMAP) == TIM_TIM5_RTC)||\
00300                                   ((TIM_REMAP) == TIM_TIM11_GPIO)||\
00301                                   ((TIM_REMAP) == TIM_TIM11_SPDIFRX)||\
00302                                   ((TIM_REMAP) == TIM_TIM11_HSE))
00303 #elif defined(STM32F413xx) || defined(STM32F423xx)
00304 #define IS_TIM_REMAP(TIM_REMAP)   (((TIM_REMAP) == TIM_TIM2_TIM8_TRGO)||\
00305                                   ((TIM_REMAP) == TIM_TIM2_ETH_PTP)||\
00306                                   ((TIM_REMAP) == TIM_TIM2_USBFS_SOF)||\
00307                                   ((TIM_REMAP) == TIM_TIM2_USBHS_SOF)||\
00308                                   ((TIM_REMAP) == TIM_TIM5_GPIO)||\
00309                                   ((TIM_REMAP) == TIM_TIM5_LSI)||\
00310                                   ((TIM_REMAP) == TIM_TIM5_LSE)||\
00311                                   ((TIM_REMAP) == TIM_TIM5_RTC)||\
00312                                   ((TIM_REMAP) == TIM_TIM11_GPIO)||\
00313                                   ((TIM_REMAP) == TIM_TIM11_HSE)||\
00314                                   ((TIM_REMAP) == TIM_TIM9_TIM3_TRGO)||\
00315                                   ((TIM_REMAP) == TIM_TIM9_LPTIM)||\
00316                                   ((TIM_REMAP) == TIM_TIM5_TIM3_TRGO)||\
00317                                   ((TIM_REMAP) == TIM_TIM5_LPTIM)||\
00318                                   ((TIM_REMAP) == TIM_TIM1_TIM3_TRGO)||\
00319                                   ((TIM_REMAP) == TIM_TIM1_LPTIM))
00320 #else
00321 #define IS_TIM_REMAP(TIM_REMAP)   (((TIM_REMAP) == TIM_TIM2_TIM8_TRGO)||\
00322                                   ((TIM_REMAP) == TIM_TIM2_ETH_PTP)||\
00323                                   ((TIM_REMAP) == TIM_TIM2_USBFS_SOF)||\
00324                                   ((TIM_REMAP) == TIM_TIM2_USBHS_SOF)||\
00325                                   ((TIM_REMAP) == TIM_TIM5_GPIO)||\
00326                                   ((TIM_REMAP) == TIM_TIM5_LSI)||\
00327                                   ((TIM_REMAP) == TIM_TIM5_LSE)||\
00328                                   ((TIM_REMAP) == TIM_TIM5_RTC)||\
00329                                   ((TIM_REMAP) == TIM_TIM11_GPIO)||\
00330                                   ((TIM_REMAP) == TIM_TIM11_HSE))
00331 #endif /* STM32F446xx */
00332 
00333 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F413xx) || defined(STM32F423xx)
00334 #define IS_TIM_SYSTEMBREAKINPUT(BREAKINPUT)   (((BREAKINPUT) == TIM_SYSTEMBREAKINPUT_HARDFAULT)||\
00335                                                ((BREAKINPUT) == TIM_SYSTEMBREAKINPUT_PVD)||\
00336                                                ((BREAKINPUT) == TIM_SYSTEMBREAKINPUT_HARDFAULT_PVD))
00337 
00338 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx || STM32F413xx || STM32F423xx */ 
00339 
00340 #define IS_TIM_DEADTIME(DEADTIME)      ((DEADTIME) <= 0xFFU) 
00341 /**
00342   * @}
00343   */  
00344   
00345 /* Private functions ---------------------------------------------------------*/
00346 /** @defgroup TIMEx_Private_Functions TIM Private Functions
00347   * @{
00348   */
00349   
00350 /**
00351   * @}
00352   */
00353 
00354 /**
00355   * @}
00356   */ 
00357 
00358 /**
00359   * @}
00360   */
00361     
00362 #ifdef __cplusplus
00363 }
00364 #endif
00365 
00366 #endif /* __STM32F4xx_HAL_TIM_EX_H */
00367 
00368 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/