1 /** 2 ****************************************************************************** 3 * @file stm32wb0x_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) 2024 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 STM32WB0x_HAL_TIM_EX_H 21 #define STM32WB0x_HAL_TIM_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32wb0x_hal_def.h" 29 30 /** @addtogroup STM32WB0x_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 /** 45 * @brief TIM Break/Break2 input configuration 46 */ 47 typedef struct 48 { 49 uint32_t Source; /*!< Specifies the source of the timer break input. 50 This parameter can be a value of @ref TIMEx_Break_Input_Source */ 51 uint32_t Enable; /*!< Specifies whether or not the break input source is enabled. 52 This parameter can be a value of @ref TIMEx_Break_Input_Source_Enable */ 53 uint32_t Polarity; /*!< Specifies the break input source polarity. 54 This parameter can be a value of @ref TIMEx_Break_Input_Source_Polarity */ 55 } TIMEx_BreakInputConfigTypeDef; 56 57 /** 58 * @} 59 */ 60 /* End of exported types -----------------------------------------------------*/ 61 62 /* Exported constants --------------------------------------------------------*/ 63 /** @defgroup TIMEx_Exported_Constants TIM Extended Exported Constants 64 * @{ 65 */ 66 67 /** @defgroup TIMEx_Remap TIM Extended Remapping 68 * @{ 69 */ 70 #if defined(TIM17) 71 #define TIM_TIM17_TI1_GPIO 0x00000000U /*!< TIM17 TI1 is connected to GPIO */ 72 #define TIM_TIM17_TI1_LC0 TIM_OR1_TI1_RMP_0 /*!< TIM17 TI1 is connected to LCO */ 73 #define TIM_TIM17_TI1_MCO TIM_OR1_TI1_RMP_1 /*!< TIM17 TI1 is connected to MCO */ 74 #endif /* TIM17 */ 75 /** 76 * @} 77 */ 78 79 /** @defgroup TIMEx_Break_Input TIM Extended Break input 80 * @{ 81 */ 82 #define TIM_BREAKINPUT_BRK 0x00000001U /*!< Timer break input */ 83 #define TIM_BREAKINPUT_BRK2 0x00000002U /*!< Timer break2 input */ 84 /** 85 * @} 86 */ 87 88 /** @defgroup TIMEx_Break_Input_Source TIM Extended Break input source 89 * @{ 90 */ 91 #define TIM_BREAKINPUTSOURCE_BKIN 0x00000001U /*!< An external source (GPIO) is connected to the BKIN pin */ 92 /** 93 * @} 94 */ 95 96 /** @defgroup TIMEx_Break_Input_Source_Enable TIM Extended Break input source enabling 97 * @{ 98 */ 99 #define TIM_BREAKINPUTSOURCE_DISABLE 0x00000000U /*!< Break input source is disabled */ 100 #define TIM_BREAKINPUTSOURCE_ENABLE 0x00000001U /*!< Break input source is enabled */ 101 /** 102 * @} 103 */ 104 105 /** @defgroup TIMEx_Break_Input_Source_Polarity TIM Extended Break input polarity 106 * @{ 107 */ 108 #define TIM_BREAKINPUTSOURCE_POLARITY_LOW 0x00000001U /*!< Break input source is active low */ 109 #define TIM_BREAKINPUTSOURCE_POLARITY_HIGH 0x00000000U /*!< Break input source is active_high */ 110 /** 111 * @} 112 */ 113 114 /** 115 * @} 116 */ 117 /* End of exported constants -------------------------------------------------*/ 118 119 /* Exported macro ------------------------------------------------------------*/ 120 /** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros 121 * @{ 122 */ 123 124 /** 125 * @} 126 */ 127 /* End of exported macro -----------------------------------------------------*/ 128 129 /* Private macro -------------------------------------------------------------*/ 130 /** @defgroup TIMEx_Private_Macros TIM Extended Private Macros 131 * @{ 132 */ 133 #if defined(TIM17) 134 #define IS_TIM_REMAP(__INSTANCE__, __REMAP__) \ 135 ((((__INSTANCE__) == TIM17) && ((((__REMAP__) & 0xFFFFFFFCU) == 0x00000000U)))) 136 #endif /* TIM17 */ 137 138 #if defined(TIM1) 139 #define IS_TIM_BREAKINPUT(__BREAKINPUT__) \ 140 (((__BREAKINPUT__) == TIM_BREAKINPUT_BRK) || \ 141 ((__BREAKINPUT__) == TIM_BREAKINPUT_BRK2)) 142 #else 143 #define IS_TIM_BREAKINPUT(__BREAKINPUT__) \ 144 (((__BREAKINPUT__) == TIM_BREAKINPUT_BRK)) 145 #endif /* TIM1 */ 146 147 #define IS_TIM_BREAKINPUTSOURCE(__SOURCE__) \ 148 (((__SOURCE__) == TIM_BREAKINPUTSOURCE_BKIN)) 149 150 #define IS_TIM_BREAKINPUTSOURCE_STATE(__STATE__) \ 151 (((__STATE__) == TIM_BREAKINPUTSOURCE_DISABLE) || \ 152 ((__STATE__) == TIM_BREAKINPUTSOURCE_ENABLE)) 153 154 #define IS_TIM_BREAKINPUTSOURCE_POLARITY(__POLARITY__) \ 155 (((__POLARITY__) == TIM_BREAKINPUTSOURCE_POLARITY_LOW) || \ 156 ((__POLARITY__) == TIM_BREAKINPUTSOURCE_POLARITY_HIGH)) 157 158 #if defined(TIM1) 159 #define IS_TIM_CLOCKSOURCE_INSTANCE(INSTANCE, __CLOCK__) \ 160 ((((INSTANCE) == TIM1) && \ 161 (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL) || \ 162 ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE1) || \ 163 ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE2) || \ 164 ((__CLOCK__) == TIM_CLOCKSOURCE_TI1ED) || \ 165 ((__CLOCK__) == TIM_CLOCKSOURCE_TI1) || \ 166 ((__CLOCK__) == TIM_CLOCKSOURCE_TI2)))) 167 #else 168 #define IS_TIM_CLOCKSOURCE_INSTANCE(INSTANCE, __CLOCK__) \ 169 ((((INSTANCE) == TIM2) && \ 170 (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL) || \ 171 ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE1) || \ 172 ((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE2) || \ 173 ((__CLOCK__) == TIM_CLOCKSOURCE_TI1ED) || \ 174 ((__CLOCK__) == TIM_CLOCKSOURCE_TI1) || \ 175 ((__CLOCK__) == TIM_CLOCKSOURCE_TI2))) \ 176 || \ 177 (((INSTANCE) == TIM16) && \ 178 (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL))) \ 179 || \ 180 (((INSTANCE) == TIM17) && \ 181 (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL)))) 182 #endif /* TIM1 */ 183 184 #if defined(TIM1) 185 #define IS_TIM_TRIGGER_INSTANCE(INSTANCE, __SELECTION__) \ 186 ((((INSTANCE) == TIM1) && \ 187 (((__SELECTION__) == TIM_TS_TI1F_ED) || \ 188 ((__SELECTION__) == TIM_TS_TI1FP1) || \ 189 ((__SELECTION__) == TIM_TS_TI2FP2) || \ 190 ((__SELECTION__) == TIM_TS_ETRF)))) 191 #else 192 #define IS_TIM_TRIGGER_INSTANCE(INSTANCE, __SELECTION__) \ 193 ((((INSTANCE) == TIM2) && \ 194 (((__SELECTION__) == TIM_TS_TI1F_ED) || \ 195 ((__SELECTION__) == TIM_TS_TI1FP1) || \ 196 ((__SELECTION__) == TIM_TS_TI2FP2) || \ 197 ((__SELECTION__) == TIM_TS_ETRF)))) 198 #endif /* TIM1 */ 199 200 /** 201 * @} 202 */ 203 /* End of private macro ------------------------------------------------------*/ 204 205 /* Exported functions --------------------------------------------------------*/ 206 /** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions 207 * @{ 208 */ 209 210 /** @addtogroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions 211 * @brief Timer Complementary Output Compare functions 212 * @{ 213 */ 214 /* Timer Complementary Output Compare functions *****************************/ 215 /* Blocking mode: Polling */ 216 HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel); 217 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel); 218 219 /* Non-Blocking mode: Interrupt */ 220 HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel); 221 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel); 222 223 #if defined(TIM_DMA_SUPPORT) 224 /* Non-Blocking mode: DMA */ 225 HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData, 226 uint16_t Length); 227 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel); 228 #endif /* TIM_DMA_SUPPORT */ 229 /** 230 * @} 231 */ 232 233 /** @addtogroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions 234 * @brief Timer Complementary PWM functions 235 * @{ 236 */ 237 /* Timer Complementary PWM functions ****************************************/ 238 /* Blocking mode: Polling */ 239 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel); 240 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel); 241 242 /* Non-Blocking mode: Interrupt */ 243 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel); 244 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel); 245 #if defined(TIM_DMA_SUPPORT) 246 /* Non-Blocking mode: DMA */ 247 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData, 248 uint16_t Length); 249 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel); 250 #endif /* TIM_DMA_SUPPORT */ 251 /** 252 * @} 253 */ 254 255 /** @addtogroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions 256 * @brief Timer Complementary One Pulse functions 257 * @{ 258 */ 259 /* Timer Complementary One Pulse functions **********************************/ 260 /* Blocking mode: Polling */ 261 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel); 262 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel); 263 264 /* Non-Blocking mode: Interrupt */ 265 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel); 266 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel); 267 /** 268 * @} 269 */ 270 271 /** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions 272 * @brief Peripheral Control functions 273 * @{ 274 */ 275 /* Extended Control functions ************************************************/ 276 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger, 277 uint32_t CommutationSource); 278 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger, 279 uint32_t CommutationSource); 280 HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim, 281 const TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig); 282 HAL_StatusTypeDef HAL_TIMEx_ConfigBreakInput(TIM_HandleTypeDef *htim, uint32_t BreakInput, 283 const TIMEx_BreakInputConfigTypeDef *sBreakInputConfig); 284 #if defined(TIM_CCR5_CCR5) 285 HAL_StatusTypeDef HAL_TIMEx_GroupChannel5(TIM_HandleTypeDef *htim, uint32_t Channels); 286 #endif /* TIM_CCR5_CCR5 */ 287 #if defined(TIM17) 288 HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap); 289 #endif /* TIM17 */ 290 #if defined(TIM_BDTR_BKBID) 291 292 HAL_StatusTypeDef HAL_TIMEx_DisarmBreakInput(TIM_HandleTypeDef *htim, uint32_t BreakInput); 293 HAL_StatusTypeDef HAL_TIMEx_ReArmBreakInput(const TIM_HandleTypeDef *htim, uint32_t BreakInput); 294 #endif /* TIM_BDTR_BKBID */ 295 /** 296 * @} 297 */ 298 299 /** @addtogroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions 300 * @brief Extended Callbacks functions 301 * @{ 302 */ 303 /* Extended Callback **********************************************************/ 304 void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim); 305 void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim); 306 #if defined(TIM_BDTR_BK2E) 307 void HAL_TIMEx_Break2Callback(TIM_HandleTypeDef *htim); 308 #endif /* TIM_BDTR_BK2E */ 309 /** 310 * @} 311 */ 312 313 /** @addtogroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions 314 * @brief Extended Peripheral State functions 315 * @{ 316 */ 317 /* Extended Peripheral State functions ***************************************/ 318 HAL_TIM_ChannelStateTypeDef HAL_TIMEx_GetChannelNState(const TIM_HandleTypeDef *htim, uint32_t ChannelN); 319 /** 320 * @} 321 */ 322 323 /** 324 * @} 325 */ 326 /* End of exported functions -------------------------------------------------*/ 327 328 /** 329 * @} 330 */ 331 332 /** 333 * @} 334 */ 335 336 #ifdef __cplusplus 337 } 338 #endif 339 340 341 #endif /* STM32WB0x_HAL_TIM_EX_H */ 342