1 /**
2   ******************************************************************************
3   * @file    stm32f0xx_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 STM32F0xx_HAL_TIM_EX_H
21 #define STM32F0xx_HAL_TIM_EX_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32f0xx_hal_def.h"
29 
30 /** @addtogroup STM32F0xx_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_TIM14_GPIO                         (0x00000000U) /*!< TIM14 TI1 is connected to GPIO */
75 #define TIM_TIM14_RTC                          (0x00000001U) /*!< TIM14 TI1 is connected to RTC_clock */
76 #define TIM_TIM14_HSE                          (0x00000002U) /*!< TIM14 TI1 is connected to HSE/32U */
77 #define TIM_TIM14_MCO                          (0x00000003U) /*!< TIM14 TI1 is connected to MCO */
78 /**
79   * @}
80   */
81 
82 /**
83   * @}
84   */
85 /* End of exported constants -------------------------------------------------*/
86 
87 /* Exported macro ------------------------------------------------------------*/
88 /** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros
89   * @{
90   */
91 
92 /**
93   * @}
94   */
95 /* End of exported macro -----------------------------------------------------*/
96 
97 /* Private macro -------------------------------------------------------------*/
98 /** @defgroup TIMEx_Private_Macros TIM Extended Private Macros
99   * @{
100   */
101 #define IS_TIM_REMAP(__INSTANCE__, __REMAP__)                                        \
102   (((__INSTANCE__) == TIM14)  && (((__REMAP__) & 0xFFFFFFFCU) == 0x00000000U))
103 
104 /**
105   * @}
106   */
107 /* End of private macro ------------------------------------------------------*/
108 
109 /* Exported functions --------------------------------------------------------*/
110 /** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions
111   * @{
112   */
113 
114 /** @addtogroup TIMEx_Exported_Functions_Group1 Extended Timer Hall Sensor functions
115   *  @brief    Timer Hall Sensor functions
116   * @{
117   */
118 /*  Timer Hall Sensor functions  **********************************************/
119 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, const TIM_HallSensor_InitTypeDef *sConfig);
120 HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim);
121 
122 void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim);
123 void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim);
124 
125 /* Blocking mode: Polling */
126 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim);
127 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim);
128 /* Non-Blocking mode: Interrupt */
129 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim);
130 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim);
131 /* Non-Blocking mode: DMA */
132 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
133 HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim);
134 /**
135   * @}
136   */
137 
138 /** @addtogroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions
139   *  @brief   Timer Complementary Output Compare functions
140   * @{
141   */
142 /*  Timer Complementary Output Compare functions  *****************************/
143 /* Blocking mode: Polling */
144 HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
145 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
146 
147 /* Non-Blocking mode: Interrupt */
148 HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
149 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
150 
151 /* Non-Blocking mode: DMA */
152 HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData,
153                                           uint16_t Length);
154 HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
155 /**
156   * @}
157   */
158 
159 /** @addtogroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions
160   *  @brief    Timer Complementary PWM functions
161   * @{
162   */
163 /*  Timer Complementary PWM functions  ****************************************/
164 /* Blocking mode: Polling */
165 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
166 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
167 
168 /* Non-Blocking mode: Interrupt */
169 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
170 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
171 /* Non-Blocking mode: DMA */
172 HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData,
173                                            uint16_t Length);
174 HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
175 /**
176   * @}
177   */
178 
179 /** @addtogroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions
180   *  @brief    Timer Complementary One Pulse functions
181   * @{
182   */
183 /*  Timer Complementary One Pulse functions  **********************************/
184 /* Blocking mode: Polling */
185 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
186 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
187 
188 /* Non-Blocking mode: Interrupt */
189 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
190 HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
191 /**
192   * @}
193   */
194 
195 /** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions
196   *  @brief    Peripheral Control functions
197   * @{
198   */
199 /* Extended Control functions  ************************************************/
200 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent(TIM_HandleTypeDef *htim, uint32_t  InputTrigger,
201                                               uint32_t  CommutationSource);
202 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_IT(TIM_HandleTypeDef *htim, uint32_t  InputTrigger,
203                                                  uint32_t  CommutationSource);
204 HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_DMA(TIM_HandleTypeDef *htim, uint32_t  InputTrigger,
205                                                   uint32_t  CommutationSource);
206 HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim,
207                                                         const TIM_MasterConfigTypeDef *sMasterConfig);
208 HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim,
209                                                 const TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig);
210 HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap);
211 /**
212   * @}
213   */
214 
215 /** @addtogroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions
216   * @brief    Extended Callbacks functions
217   * @{
218   */
219 /* Extended Callback **********************************************************/
220 void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim);
221 void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim);
222 void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim);
223 /**
224   * @}
225   */
226 
227 /** @addtogroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions
228   * @brief    Extended Peripheral State functions
229   * @{
230   */
231 /* Extended Peripheral State functions  ***************************************/
232 HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(const TIM_HandleTypeDef *htim);
233 HAL_TIM_ChannelStateTypeDef HAL_TIMEx_GetChannelNState(const TIM_HandleTypeDef *htim,  uint32_t ChannelN);
234 /**
235   * @}
236   */
237 
238 /**
239   * @}
240   */
241 /* End of exported functions -------------------------------------------------*/
242 
243 /* Private functions----------------------------------------------------------*/
244 /** @addtogroup TIMEx_Private_Functions TIM Extended Private Functions
245   * @{
246   */
247 void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma);
248 void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma);
249 /**
250   * @}
251   */
252 /* End of private functions --------------------------------------------------*/
253 
254 /**
255   * @}
256   */
257 
258 /**
259   * @}
260   */
261 
262 #ifdef __cplusplus
263 }
264 #endif
265 
266 
267 #endif /* STM32F0xx_HAL_TIM_EX_H */
268