py32f002b_hal_tim_ex.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. /**
  2. ******************************************************************************
  3. * @file py32f002b_hal_tim_ex.h
  4. * @author MCU Application Team
  5. * @brief Header file of TIM HAL Extended module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2023 Puya Semiconductor Co.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by Puya under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. * @attention
  19. *
  20. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  21. * All rights reserved.</center></h2>
  22. *
  23. * This software component is licensed by ST under BSD 3-Clause license,
  24. * the "License"; You may not use this file except in compliance with the
  25. * License. You may obtain a copy of the License at:
  26. * opensource.org/licenses/BSD-3-Clause
  27. *
  28. ******************************************************************************
  29. */
  30. /* Define to prevent recursive inclusion -------------------------------------*/
  31. #ifndef __PY32F002B_HAL_TIM_EX_H
  32. #define __PY32F002B_HAL_TIM_EX_H
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /* Includes ------------------------------------------------------------------*/
  37. #include "py32f002b_hal_def.h"
  38. /** @addtogroup PY32F002B_HAL_Driver
  39. * @{
  40. */
  41. /** @addtogroup TIMEx
  42. * @{
  43. */
  44. /* Exported types ------------------------------------------------------------*/
  45. /** @defgroup TIMEx_Exported_Types TIM Extended Exported Types
  46. * @{
  47. */
  48. /**
  49. * @brief TIM Hall sensor Configuration Structure definition
  50. */
  51. typedef struct
  52. {
  53. uint32_t IC1Polarity; /*!< Specifies the active edge of the input signal.
  54. This parameter can be a value of @ref TIM_Input_Capture_Polarity */
  55. uint32_t IC1Prescaler; /*!< Specifies the Input Capture Prescaler.
  56. This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
  57. uint32_t IC1Filter; /*!< Specifies the input capture filter.
  58. This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
  59. uint32_t Commutation_Delay; /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
  60. This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
  61. } TIM_HallSensor_InitTypeDef;
  62. /**
  63. * @}
  64. */
  65. /* End of exported types -----------------------------------------------------*/
  66. /* Exported constants --------------------------------------------------------*/
  67. /** @defgroup TIMEx_Exported_Constants TIM Extended Exported Constants
  68. * @{
  69. */
  70. /** @defgroup TIMEx_Remap TIM Extended Remapping
  71. * @{
  72. */
  73. #define TIM_TIM14_GPIO (0x00000000U) /*!< TIM14 TI1 is connected to GPIO */
  74. #define TIM_TIM14_RTC (0x00000001U) /*!< TIM14 TI1 is connected to RTC_clock */
  75. #define TIM_TIM14_HSE (0x00000002U) /*!< TIM14 TI1 is connected to HSE/32U */
  76. #define TIM_TIM14_MCO (0x00000003U) /*!< TIM14 TI1 is connected to MCO */
  77. /**
  78. * @}
  79. */
  80. /**
  81. * @}
  82. */
  83. /* End of exported constants -------------------------------------------------*/
  84. /* Exported macro ------------------------------------------------------------*/
  85. /** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros
  86. * @{
  87. */
  88. /**
  89. * @}
  90. */
  91. /* End of exported macro -----------------------------------------------------*/
  92. /* Private macro -------------------------------------------------------------*/
  93. /** @defgroup TIMEx_Private_Macros TIM Extended Private Macros
  94. * @{
  95. */
  96. #define IS_TIM_REMAP(__INSTANCE__, __REMAP__) \
  97. (((__INSTANCE__) == TIM14) && (((__REMAP__) & 0xFFFFFFFCU) == 0x00000000U))
  98. /**
  99. * @}
  100. */
  101. /* End of private macro ------------------------------------------------------*/
  102. /* Exported functions --------------------------------------------------------*/
  103. /** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions
  104. * @{
  105. */
  106. /** @addtogroup TIMEx_Exported_Functions_Group1 Extended Timer Hall Sensor functions
  107. * @brief Timer Hall Sensor functions
  108. * @{
  109. */
  110. /* Timer Hall Sensor functions **********************************************/
  111. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, TIM_HallSensor_InitTypeDef *sConfig);
  112. HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim);
  113. void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim);
  114. void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim);
  115. /* Blocking mode: Polling */
  116. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim);
  117. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim);
  118. /* Non-Blocking mode: Interrupt */
  119. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim);
  120. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim);
  121. #if (defined(DMA) || defined(DMA1))
  122. /* Non-Blocking mode: DMA */
  123. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
  124. HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim);
  125. #endif
  126. /**
  127. * @}
  128. */
  129. /** @addtogroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions
  130. * @brief Timer Complementary Output Compare functions
  131. * @{
  132. */
  133. /* Timer Complementary Output Compare functions *****************************/
  134. /* Blocking mode: Polling */
  135. HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  136. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  137. /* Non-Blocking mode: Interrupt */
  138. HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  139. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  140. #if (defined(DMA) || defined(DMA1))
  141. /* Non-Blocking mode: DMA */
  142. HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  143. HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  144. #endif
  145. /**
  146. * @}
  147. */
  148. /** @addtogroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions
  149. * @brief Timer Complementary PWM functions
  150. * @{
  151. */
  152. /* Timer Complementary PWM functions ****************************************/
  153. /* Blocking mode: Polling */
  154. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
  155. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
  156. /* Non-Blocking mode: Interrupt */
  157. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  158. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
  159. #if (defined(DMA) || defined(DMA1))
  160. /* Non-Blocking mode: DMA */
  161. HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
  162. HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
  163. #endif
  164. /**
  165. * @}
  166. */
  167. /** @addtogroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions
  168. * @brief Timer Complementary One Pulse functions
  169. * @{
  170. */
  171. /* Timer Complementary One Pulse functions **********************************/
  172. /* Blocking mode: Polling */
  173. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  174. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  175. /* Non-Blocking mode: Interrupt */
  176. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  177. HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
  178. /**
  179. * @}
  180. */
  181. /** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions
  182. * @brief Peripheral Control functions
  183. * @{
  184. */
  185. /* Extended Control functions ************************************************/
  186. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
  187. uint32_t CommutationSource);
  188. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
  189. uint32_t CommutationSource);
  190. #if (defined(DMA) || defined(DMA1))
  191. HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
  192. uint32_t CommutationSource);
  193. #endif
  194. HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim,
  195. TIM_MasterConfigTypeDef *sMasterConfig);
  196. HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim,
  197. TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig);
  198. HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap);
  199. /**
  200. * @}
  201. */
  202. /** @addtogroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions
  203. * @brief Extended Callbacks functions
  204. * @{
  205. */
  206. /* Extended Callback **********************************************************/
  207. void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim);
  208. void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim);
  209. void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim);
  210. /**
  211. * @}
  212. */
  213. /** @addtogroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions
  214. * @brief Extended Peripheral State functions
  215. * @{
  216. */
  217. /* Extended Peripheral State functions ***************************************/
  218. HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef *htim);
  219. /**
  220. * @}
  221. */
  222. /**
  223. * @}
  224. */
  225. /* End of exported functions -------------------------------------------------*/
  226. /* Private functions----------------------------------------------------------*/
  227. /** @addtogroup TIMEx_Private_Functions TIM Extended Private Functions
  228. * @{
  229. */
  230. #if (defined(DMA) || defined(DMA1))
  231. void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma);
  232. void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma);
  233. #endif
  234. /**
  235. * @}
  236. */
  237. /* End of private functions --------------------------------------------------*/
  238. /**
  239. * @}
  240. */
  241. /**
  242. * @}
  243. */
  244. #ifdef __cplusplus
  245. }
  246. #endif
  247. #endif /* __PY32F002B_HAL_TIM_EX_H */
  248. /************************ (C) COPYRIGHT Puya *****END OF FILE****/