stm32l0xx_hal_tim_ex.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /**
  2. ******************************************************************************
  3. * @file stm32l0xx_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. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32L0xx_HAL_TIM_EX_H
  20. #define STM32L0xx_HAL_TIM_EX_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32l0xx_hal_def.h"
  26. /** @addtogroup STM32L0xx_HAL_Driver
  27. * @{
  28. */
  29. /** @addtogroup TIMEx
  30. * @{
  31. */
  32. /* Exported types ------------------------------------------------------------*/
  33. /** @defgroup TIMEx_Exported_Types TIM Extended Exported Types
  34. * @{
  35. */
  36. /**
  37. * @}
  38. */
  39. /* End of exported types -----------------------------------------------------*/
  40. /* Exported constants --------------------------------------------------------*/
  41. /** @defgroup TIMEx_Exported_Constants TIM Extended Exported Constants
  42. * @{
  43. */
  44. /** @defgroup TIMEx_Remap TIM Extended Remapping
  45. * @{
  46. */
  47. #define TIM2_ETR_GPIO 0x00000000U /*!< TIM2 ETR input is connected to ORed GPIOs */
  48. #if defined(RCC_HSI48_SUPPORT)
  49. #define TIM2_ETR_HSI48 TIM2_OR_ETR_RMP_2 /*!< TIM2 ETR input is connected to HSI48 clock */
  50. #endif /* RCC_HSI48_SUPPORT */
  51. #define TIM2_ETR_HSI16 (TIM2_OR_ETR_RMP_1 | TIM2_OR_ETR_RMP_0) /*!< TIM2 ETR input is connected to HSI16 clock */
  52. #define TIM2_ETR_LSE (TIM2_OR_ETR_RMP_2 | TIM2_OR_ETR_RMP_0) /*!< TIM2 ETR input is connected to LSE clock */
  53. #if defined(COMP1) && defined(COMP2)
  54. #define TIM2_ETR_COMP2_OUT (TIM2_OR_ETR_RMP_2 | TIM2_OR_ETR_RMP_1) /*!< TIM2 ETR input is connected to COMP2_OUT */
  55. #define TIM2_ETR_COMP1_OUT TIM2_OR_ETR_RMP /*!< TIM2 ETR input is connected to COMP1_OUT */
  56. #endif /* COMP1 && COMP2 */
  57. #define TIM2_TI4_GPIO 0x00000000U /*!< TIM2 TI4 input connected to ORed GPIOs */
  58. #if defined(COMP1) && defined(COMP2)
  59. #define TIM2_TI4_COMP2 TIM2_OR_TI4_RMP_0 /*!< TIM2 TI4 input connected to COMP2_OUT */
  60. #define TIM2_TI4_COMP1 TIM2_OR_TI4_RMP_1 /*!< TIM2 TI4 input connected to COMP1_OUT */
  61. #endif /* COMP1 && COMP2 */
  62. #if defined(TIM3)
  63. #if defined(USB)
  64. #define TIM3_TI4_USB_NOE 0x00000000U /*!< USB_NOE selected selected for PC9 (AF2) remapping */
  65. #endif /* USB */
  66. #define TIM3_TI4_GPIOC9_AF2 TIM3_OR_TI4_RMP /*!< TIM3_CH4 selected for PC9 (AF2) remapping */
  67. #define TIM3_TI2_GPIO_DEF 0x00000000U /*!< TIM3_CH2 selected for PB5 (AF4) remapping */
  68. #define TIM3_TI2_GPIOB5_AF4 TIM3_OR_TI2_RMP /*!< TIM22_CH2 selected for PB5 (AF4) remapping */
  69. #if defined(USB)
  70. #define TIM3_TI1_USB_SOF 0x00000000U /*!< TIM3 TI1 input connected to USB_SOF */
  71. #endif /* USB */
  72. #define TIM3_TI1_GPIO TIM3_OR_TI1_RMP /*!< TIM3 TI1 input connected to ORed GPIOs */
  73. #define TIM3_ETR_GPIO 0x00000000U /*!< TIM3 ETR input connected to ORed GPIOs */
  74. #define TIM3_ETR_HSI TIM3_OR_ETR_RMP_1 /*!< TIM3_ETR input is connected to HSI48 clock */
  75. #endif /* TIM3 */
  76. #define TIM21_ETR_GPIO 0x00000000U /*!< TIM21 ETR input connected to ORed GPIOs */
  77. #if defined(COMP1) && defined(COMP2)
  78. #define TIM21_ETR_COMP2_OUT TIM21_OR_ETR_RMP_0 /*!< TIM21 ETR input connected to COMP2_OUT */
  79. #define TIM21_ETR_COMP1_OUT TIM21_OR_ETR_RMP_1 /*!< TIM21 ETR input connected to COMP1_OUT */
  80. #endif /* COMP1 && COMP2 */
  81. #define TIM21_ETR_LSE TIM21_OR_ETR_RMP /*!< TIM21 ETR input connected to LSE clock */
  82. #define TIM21_TI1_GPIO 0x00000000U /*!< TIM21 TI1 input connected to ORed GPIOs */
  83. #define TIM21_TI1_MCO TIM21_OR_TI1_RMP /*!< TIM21 TI1 input connected to MCO clock */
  84. #define TIM21_TI1_RTC_WKUT_IT TIM21_OR_TI1_RMP_0 /*!< TIM21 TI1 input connected to RTC WAKEUP interrupt */
  85. #define TIM21_TI1_HSE_RTC TIM21_OR_TI1_RMP_1 /*!< TIM21 TI1 input connected to HSE_RTC clock */
  86. #define TIM21_TI1_MSI (TIM21_OR_TI1_RMP_0 | TIM21_OR_TI1_RMP_1) /*!< TIM21 TI1 input connected to MSI clock */
  87. #define TIM21_TI1_LSE TIM21_OR_TI1_RMP_2 /*!< TIM21 TI1 input connected to LSE clock */
  88. #define TIM21_TI1_LSI (TIM21_OR_TI1_RMP_2 | TIM21_OR_TI1_RMP_0) /*!< TIM21 TI1 input connected to LSI clock */
  89. #if defined(COMP1)
  90. #define TIM21_TI1_COMP1_OUT (TIM21_OR_TI1_RMP_2 | TIM21_OR_TI1_RMP_1) /*!< TIM21 TI1 input connected to COMP1_OUT */
  91. #endif /* COMP1 */
  92. #define TIM21_TI2_GPIO 0x00000000U /*!< TIM21 TI2 input connected to ORed GPIOs */
  93. #if defined(COMP2)
  94. #define TIM21_TI2_COMP2_OUT TIM21_OR_TI2_RMP /*!< TIM21 TI2 input connected to COMP2_OUT */
  95. #endif /* COMP2 */
  96. #if defined(TIM22)
  97. #define TIM22_ETR_GPIO 0x00000000U /*!< TIM22 ETR input is connected to ORed GPIOs */
  98. #if defined(COMP1) && defined(COMP2)
  99. #define TIM22_ETR_COMP2_OUT TIM22_OR_ETR_RMP_0 /*!< TIM22 ETR input is connected to COMP2_OUT */
  100. #define TIM22_ETR_COMP1_OUT TIM22_OR_ETR_RMP_1 /*!< TIM22 ETR input is connected to COMP1_OUT */
  101. #endif /* COMP1 && COMP2 */
  102. #define TIM22_ETR_LSE TIM22_OR_ETR_RMP /*!< TIM22 ETR input is connected to LSE clock */
  103. #define TIM22_TI1_GPIO 0x00000000U /*!< TIM22 TI1 input is connected to ORed GPIOs */
  104. #if defined(COMP1) && defined(COMP2)
  105. #define TIM22_TI1_COMP2_OUT TIM22_OR_TI1_RMP_0 /*!< TIM22 TI1 input is connected to COMP2_OUT */
  106. #define TIM22_TI1_COMP1_OUT TIM22_OR_TI1_RMP_1 /*!< TIM22 TI1 input is connected to COMP1_OUT */
  107. #endif /* COMP1 && COMP2 */
  108. #endif /* TIM22 */
  109. /**
  110. * @}
  111. */
  112. /**
  113. * @}
  114. */
  115. /* End of exported constants -------------------------------------------------*/
  116. /* Exported macro ------------------------------------------------------------*/
  117. /** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros
  118. * @{
  119. */
  120. /**
  121. * @}
  122. */
  123. /* End of exported macro -----------------------------------------------------*/
  124. /* Private macro -------------------------------------------------------------*/
  125. /** @defgroup TIMEx_Private_Macros TIM Extended Private Macros
  126. * @{
  127. */
  128. #if defined(TIM3) && defined(TIM22)
  129. #define IS_TIM_REMAP(__INSTANCE__, __TIM_REMAP__) \
  130. ((((__INSTANCE__) == TIM2) && ((__TIM_REMAP__) <= (TIM2_OR_TI4_RMP | TIM2_OR_ETR_RMP))) || \
  131. (((__INSTANCE__) == TIM22) && ((__TIM_REMAP__) <= (TIM22_OR_TI1_RMP | TIM22_OR_ETR_RMP))) || \
  132. (((__INSTANCE__) == TIM21) && ((__TIM_REMAP__) <= (TIM21_OR_ETR_RMP | TIM21_OR_TI1_RMP | TIM21_OR_TI2_RMP))) || \
  133. (((__INSTANCE__) == TIM3) && ((__TIM_REMAP__) <= (TIM3_OR_ETR_RMP | TIM3_OR_TI1_RMP | TIM3_OR_TI2_RMP | TIM3_OR_TI4_RMP))))
  134. #define IS_CHANNEL_AVAILABLE(__INSTANCE__, __CHANNEL__) \
  135. ((((__INSTANCE__) == TIM2) && (((__CHANNEL__) == TIM_CHANNEL_1) || \
  136. ((__CHANNEL__) == TIM_CHANNEL_2) || \
  137. ((__CHANNEL__) == TIM_CHANNEL_3) || \
  138. ((__CHANNEL__) == TIM_CHANNEL_4))) || \
  139. (((__INSTANCE__) == TIM3) && (((__CHANNEL__) == TIM_CHANNEL_1) || \
  140. ((__CHANNEL__) == TIM_CHANNEL_2) || \
  141. ((__CHANNEL__) == TIM_CHANNEL_3) || \
  142. ((__CHANNEL__) == TIM_CHANNEL_4))) || \
  143. (((__INSTANCE__) == TIM21) && (((__CHANNEL__) == TIM_CHANNEL_1) || \
  144. ((__CHANNEL__) == TIM_CHANNEL_2))) || \
  145. (((__INSTANCE__) == TIM22) && (((__CHANNEL__) == TIM_CHANNEL_1) || \
  146. ((__CHANNEL__) == TIM_CHANNEL_2))))
  147. #elif defined(TIM22)
  148. #define IS_TIM_REMAP(__INSTANCE__, __TIM_REMAP__) \
  149. ((((__INSTANCE__) == TIM2) && ((__TIM_REMAP__) <= (TIM2_OR_TI4_RMP | TIM2_OR_ETR_RMP))) || \
  150. (((__INSTANCE__) == TIM22) && ((__TIM_REMAP__) <= (TIM22_OR_TI1_RMP | TIM22_OR_ETR_RMP))) || \
  151. (((__INSTANCE__) == TIM21) && ((__TIM_REMAP__) <= (TIM21_OR_ETR_RMP | TIM21_OR_TI1_RMP | TIM21_OR_TI2_RMP))))
  152. #define IS_CHANNEL_AVAILABLE(__INSTANCE__, __CHANNEL__) \
  153. ((((__INSTANCE__) == TIM2) && (((__CHANNEL__) == TIM_CHANNEL_1) || \
  154. ((__CHANNEL__) == TIM_CHANNEL_2) || \
  155. ((__CHANNEL__) == TIM_CHANNEL_3) || \
  156. ((__CHANNEL__) == TIM_CHANNEL_4))) || \
  157. (((__INSTANCE__) == TIM21) && (((__CHANNEL__) == TIM_CHANNEL_1) || \
  158. ((__CHANNEL__) == TIM_CHANNEL_2))) || \
  159. (((__INSTANCE__) == TIM22) && (((__CHANNEL__) == TIM_CHANNEL_1) || \
  160. ((__CHANNEL__) == TIM_CHANNEL_2))))
  161. #else
  162. #define IS_TIM_REMAP(__INSTANCE__, __TIM_REMAP__) \
  163. ((((__INSTANCE__) == TIM2) && ((__TIM_REMAP__) <= (TIM2_OR_TI4_RMP | TIM2_OR_ETR_RMP))) || \
  164. (((__INSTANCE__) == TIM21) && ((__TIM_REMAP__) <= (TIM21_OR_ETR_RMP | TIM21_OR_TI1_RMP | TIM21_OR_TI2_RMP))))
  165. #define IS_CHANNEL_AVAILABLE(__INSTANCE__, __CHANNEL__) \
  166. ((((__INSTANCE__) == TIM2) && (((__CHANNEL__) == TIM_CHANNEL_1) || \
  167. ((__CHANNEL__) == TIM_CHANNEL_2) || \
  168. ((__CHANNEL__) == TIM_CHANNEL_3) || \
  169. ((__CHANNEL__) == TIM_CHANNEL_4))) || \
  170. (((__INSTANCE__) == TIM21) && (((__CHANNEL__) == TIM_CHANNEL_1) || \
  171. ((__CHANNEL__) == TIM_CHANNEL_2))))
  172. #endif /* TIM3 && TIM22 */
  173. /**
  174. * @}
  175. */
  176. /* End of private macro ------------------------------------------------------*/
  177. /* Exported functions --------------------------------------------------------*/
  178. /** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions
  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_MasterConfigSynchronization(TIM_HandleTypeDef *htim,
  187. const TIM_MasterConfigTypeDef *sMasterConfig);
  188. HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap);
  189. /**
  190. * @}
  191. */
  192. /**
  193. * @}
  194. */
  195. /* End of exported functions -------------------------------------------------*/
  196. /**
  197. * @}
  198. */
  199. /**
  200. * @}
  201. */
  202. #ifdef __cplusplus
  203. }
  204. #endif
  205. #endif /* STM32L0xx_HAL_TIM_EX_H */