HAL_TIMER_EX.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /***********************************************************************
  2. * Filename : hal_timer_ex.h
  3. * Description : timer driver header file
  4. * Author(s) : xwl
  5. * version : V1.0
  6. * Modify date : 2021-03-24
  7. ***********************************************************************/
  8. #ifndef __HAL_TIMER_EX_H__
  9. #define __HAL_TIMER_EX_H__
  10. #include "ACM32Fxx_HAL.h"
  11. #define TIM_BDTR_DTG_Pos (0U)
  12. #define TIM_BDTR_DTG_Msk (0xFFUL << TIM_BDTR_DTG_Pos) /*!< 0x000000FF */
  13. #define TIM_BDTR_DTG TIM_BDTR_DTG_Msk /*!<DTG[0:7] bits (Dead-Time Generator set-up) */
  14. #define TIM_BDTR_DTG_0 (0x01UL << TIM_BDTR_DTG_Pos) /*!< 0x00000001 */
  15. #define TIM_BDTR_DTG_1 (0x02UL << TIM_BDTR_DTG_Pos) /*!< 0x00000002 */
  16. #define TIM_BDTR_DTG_2 (0x04UL << TIM_BDTR_DTG_Pos) /*!< 0x00000004 */
  17. #define TIM_BDTR_DTG_3 (0x08UL << TIM_BDTR_DTG_Pos) /*!< 0x00000008 */
  18. #define TIM_BDTR_DTG_4 (0x10UL << TIM_BDTR_DTG_Pos) /*!< 0x00000010 */
  19. #define TIM_BDTR_DTG_5 (0x20UL << TIM_BDTR_DTG_Pos) /*!< 0x00000020 */
  20. #define TIM_BDTR_DTG_6 (0x40UL << TIM_BDTR_DTG_Pos) /*!< 0x00000040 */
  21. #define TIM_BDTR_DTG_7 (0x80UL << TIM_BDTR_DTG_Pos)
  22. #define TIM_BDTR_LOCK_Pos (8U)
  23. #define TIM_BDTR_LOCK_Msk (0x3UL << TIM_BDTR_LOCK_Pos) /*!< 0x00000300 */
  24. #define TIM_BDTR_LOCK TIM_BDTR_LOCK_Msk /*!<LOCK[1:0] bits (Lock Configuration) */
  25. #define TIM_BDTR_LOCK_0 (0x1UL << TIM_BDTR_LOCK_Pos) /*!< 0x00000100 */
  26. #define TIM_BDTR_LOCK_1 (0x2UL << TIM_BDTR_LOCK_Pos)
  27. #define TIM_BDTR_OSSI_Pos (10U)
  28. #define TIM_BDTR_OSSI_Msk (0x1UL << TIM_BDTR_OSSI_Pos) /*!< 0x00000400 */
  29. #define TIM_BDTR_OSSI TIM_BDTR_OSSI_Msk /*!<Off-State Selection for Idle mode */
  30. #define TIM_BDTR_OSSR_Pos (11U)
  31. #define TIM_BDTR_OSSR_Msk (0x1UL << TIM_BDTR_OSSR_Pos) /*!< 0x00000800 */
  32. #define TIM_BDTR_OSSR TIM_BDTR_OSSR_Msk /*!<Off-State Selection for Run mode */
  33. #define TIM_BDTR_BKE_Pos (12U)
  34. #define TIM_BDTR_BKE_Msk (0x1UL << TIM_BDTR_BKE_Pos) /*!< 0x00001000 */
  35. #define TIM_BDTR_BKE TIM_BDTR_BKE_Msk /*!<Break enable for Break 1 */
  36. #define TIM_BDTR_BKP_Pos (13U)
  37. #define TIM_BDTR_BKP_Msk (0x1UL << TIM_BDTR_BKP_Pos) /*!< 0x00002000 */
  38. #define TIM_BDTR_BKP TIM_BDTR_BKP_Msk /*!<Break Polarity for Break 1 */
  39. #define TIM_BDTR_AOE_Pos (14U)
  40. #define TIM_BDTR_AOE_Msk (0x1UL << TIM_BDTR_AOE_Pos) /*!< 0x00004000 */
  41. #define TIM_BDTR_AOE TIM_BDTR_AOE_Msk /*!<Automatic Output enable */
  42. #define TIM_BDTR_MOE_Pos (15U)
  43. #define TIM_BDTR_MOE_Msk (0x1UL << TIM_BDTR_MOE_Pos) /*!< 0x00008000 */
  44. #define TIM_BDTR_MOE TIM_BDTR_MOE_Msk /*!<Main Output enable */
  45. #define TIM_BDTR_BKF_Pos (16U)
  46. #define TIM_BDTR_BKF_Msk (0xFUL << TIM_BDTR_BKF_Pos) /*!< 0x000F0000 */
  47. #define TIM_BDTR_BKF TIM_BDTR_BKF_Msk
  48. #define TIM_BREAKINPUTSOURCE_BKIN 0x00000001U /* !< An external source (GPIO) is connected to the BKIN pin */
  49. #ifdef HAL_COMP_MODULE_ENABLED
  50. #define TIM_BREAKINPUTSOURCE_COMP1 0x00000002U /* !< The COMP1 output is connected to the break input */
  51. #define TIM_BREAKINPUTSOURCE_COMP2 0x00000004U /* !< The COMP2 output is connected to the break input */
  52. #endif /* COMP1 && COMP2 */
  53. #define TIM_BREAKINPUT_BRK 0x00000001U
  54. #define TIM1_AF1_BKINE_Pos (0U)
  55. #define TIM1_AF1_BKINE_Msk (0x1UL << TIM1_AF1_BKINE_Pos) /*!< 0x00000001 */
  56. #define TIM1_AF1_BKINE TIM1_AF1_BKINE_Msk /*!<BRK BKIN input enable */
  57. #define TIM1_AF1_BKCMP1E_Pos (1U)
  58. #define TIM1_AF1_BKCMP1E_Msk (0x1UL << TIM1_AF1_BKCMP1E_Pos) /*!< 0x00000002 */
  59. #define TIM1_AF1_BKCMP1E TIM1_AF1_BKCMP1E_Msk /*!<BRK COMP1 enable */
  60. #define TIM1_AF1_BKCMP2E_Pos (2U)
  61. #define TIM1_AF1_BKCMP2E_Msk (0x1UL << TIM1_AF1_BKCMP2E_Pos) /*!< 0x00000004 */
  62. #define TIM1_AF1_BKCMP2E TIM1_AF1_BKCMP2E_Msk /*!<BRK COMP2 enable */
  63. #define TIM1_AF1_BKINP_Pos (9U)
  64. #define TIM1_AF1_BKINP_Msk (0x1UL << TIM1_AF1_BKINP_Pos) /*!< 0x00000200 */
  65. #define TIM1_AF1_BKINP TIM1_AF1_BKINP_Msk /*!<BRK BKIN input polarity */
  66. #define TIM1_AF1_BKCMP1P_Pos (10U)
  67. #define TIM1_AF1_BKCMP1P_Msk (0x1UL << TIM1_AF1_BKCMP1P_Pos) /*!< 0x00000400 */
  68. #define TIM1_AF1_BKCMP1P TIM1_AF1_BKCMP1P_Msk /*!<BRK COMP1 input polarity */
  69. #define TIM1_AF1_BKCMP2P_Pos (11U)
  70. #define TIM1_AF1_BKCMP2P_Msk (0x1UL << TIM1_AF1_BKCMP2P_Pos) /*!< 0x00000800 */
  71. #define TIM1_AF1_BKCMP2P TIM1_AF1_BKCMP2P_Msk
  72. typedef struct
  73. {
  74. uint32_t OffStateRunMode; // TIM off state in run mode
  75. uint32_t OffStateIDLEMode; // TIM off state in IDLE mode
  76. uint32_t LockLevel; // TIM Lock level
  77. uint32_t DeadTime; // TIM dead Time
  78. uint32_t BreakState; // TIM Break State
  79. uint32_t BreakPolarity; // TIM Break input polarity
  80. uint32_t BreakFilter; // Specifies the break input filter.
  81. uint32_t AutomaticOutput; // TIM Automatic Output Enable state
  82. } TIM_BreakDeadTimeConfigTypeDef;
  83. typedef struct
  84. {
  85. uint32_t Source; /*!< Specifies the source of the timer break input.
  86. This parameter can be a value of @ref TIMEx_Break_Input_Source */
  87. uint32_t Enable; /*!< Specifies whether or not the break input source is enabled.
  88. This parameter can be a value of @ref TIMEx_Break_Input_Source_Enable */
  89. uint32_t Polarity; /*!< Specifies the break input source polarity.
  90. This parameter can be a value of @ref TIMEx_Break_Input_Source_Polarity */
  91. }
  92. TIMEx_BreakInputConfigTypeDef;
  93. /******************* Bit definition for TIM_TISEL register *********************/
  94. #define TIM_TISEL_TI1SEL_Pos (0U)
  95. #define TIM_TISEL_TI1SEL_Msk (0xFUL << TIM_TISEL_TI1SEL_Pos) /*!< 0x0000000F */
  96. #define TIM_TISEL_TI1SEL TIM_TISEL_TI1SEL_Msk /*!<TI1SEL[3:0] bits (TIM1 TI1 SEL)*/
  97. #define TIM_TISEL_TI1SEL_0 (0x1UL << TIM_TISEL_TI1SEL_Pos) /*!< 0x00000001 */
  98. #define TIM_TISEL_TI1SEL_1 (0x2UL << TIM_TISEL_TI1SEL_Pos) /*!< 0x00000002 */
  99. #define TIM_TISEL_TI1SEL_2 (0x4UL << TIM_TISEL_TI1SEL_Pos) /*!< 0x00000004 */
  100. #define TIM_TISEL_TI1SEL_3 (0x8UL << TIM_TISEL_TI1SEL_Pos) /*!< 0x00000008 */
  101. #define TIM_TISEL_TI2SEL_Pos (8U)
  102. #define TIM_TISEL_TI2SEL_Msk (0xFUL << TIM_TISEL_TI2SEL_Pos) /*!< 0x00000F00 */
  103. #define TIM_TISEL_TI2SEL TIM_TISEL_TI2SEL_Msk /*!<TI2SEL[3:0] bits (TIM1 TI2 SEL)*/
  104. #define TIM_TISEL_TI2SEL_0 (0x1UL << TIM_TISEL_TI2SEL_Pos) /*!< 0x00000100 */
  105. #define TIM_TISEL_TI2SEL_1 (0x2UL << TIM_TISEL_TI2SEL_Pos) /*!< 0x00000200 */
  106. #define TIM_TISEL_TI2SEL_2 (0x4UL << TIM_TISEL_TI2SEL_Pos) /*!< 0x00000400 */
  107. #define TIM_TISEL_TI2SEL_3 (0x8UL << TIM_TISEL_TI2SEL_Pos) /*!< 0x00000800 */
  108. #endif