hc32f460_timer4_emb.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*******************************************************************************
  2. * Copyright (C) 2020, Huada Semiconductor Co., Ltd. All rights reserved.
  3. *
  4. * This software component is licensed by HDSC under BSD 3-Clause license
  5. * (the "License"); You may not use this file except in compliance with the
  6. * License. You may obtain a copy of the License at:
  7. * opensource.org/licenses/BSD-3-Clause
  8. */
  9. /******************************************************************************/
  10. /** \file hc32f460_timer4_emb.h
  11. **
  12. ** A detailed description is available at
  13. ** @link Timer4EmbGroup Timer4EMB description @endlink
  14. **
  15. ** - 2018-11-02 CDT First version for Device Driver Library of Timer4EMB.
  16. **
  17. ******************************************************************************/
  18. #ifndef __HC32F460_TIMER4_EMB_H__
  19. #define __HC32F460_TIMER4_EMB_H__
  20. /*******************************************************************************
  21. * Include files
  22. ******************************************************************************/
  23. #include "hc32_common.h"
  24. #include "ddl_config.h"
  25. #if (DDL_TIMER4_EMB_ENABLE == DDL_ON)
  26. /* C binding of definitions if building with C++ compiler */
  27. #ifdef __cplusplus
  28. extern "C"
  29. {
  30. #endif
  31. /**
  32. *******************************************************************************
  33. ** \defgroup Timer4EmbGroup Timer4 Emergency Brake(Timer4EMB)
  34. **
  35. ******************************************************************************/
  36. //@{
  37. /*******************************************************************************
  38. * Global type definitions ('typedef')
  39. ******************************************************************************/
  40. /**
  41. *******************************************************************************
  42. ** \brief Timer4 EMB hold function selection enumeration
  43. **
  44. ******************************************************************************/
  45. typedef enum en_timer4_emb_hold_mode
  46. {
  47. EmbChangePwm = 0u, ///< Don't hold PWM output when EMB signal occurs
  48. EmbHoldPwm = 1u, ///< Hold PWM output when EMB signal occurs
  49. } en_timer4_emb_hold_mode_t;
  50. /**
  51. *******************************************************************************
  52. ** \brief Timer4 EMB state selection enumeration
  53. **
  54. ******************************************************************************/
  55. typedef enum en_timer4_emb_state
  56. {
  57. EmbTrigPwmOutputNormal = 0u, ///< PWM output signal normally.
  58. EmbTrigPwmOutputHiz = 1u, ///< PWM output Hiz signal.
  59. EmbTrigPwmOutputLowLevel = 2u, ///< PWM output low level signal.
  60. EmbTrigPwmOutputHighLevel = 3u, ///< PWM output high level signal.
  61. } en_timer4_emb_state_t;
  62. /**
  63. *******************************************************************************
  64. ** \brief Timer4 EMB configure
  65. **
  66. ******************************************************************************/
  67. typedef struct stc_timer4_emb_init
  68. {
  69. en_timer4_emb_state_t enEmbState; ///< Timer4 EMB state selection and this parameter can be a value of @ref en_timer4_emb_state_t
  70. en_timer4_emb_hold_mode_t enPwmHold; ///< Timer4 EMB hold function selection and this parameter can be a value of @ref en_timer4_emb_hold_mode_t
  71. } stc_timer4_emb_init_t;
  72. /*******************************************************************************
  73. * Global pre-processor symbols/macros ('#define')
  74. ******************************************************************************/
  75. /*******************************************************************************
  76. * Global variable definitions ('extern')
  77. ******************************************************************************/
  78. /*******************************************************************************
  79. * Global function prototypes (definition in C source)
  80. ******************************************************************************/
  81. en_result_t TIMER4_EMB_Init(M4_TMR4_TypeDef *TMR4x,
  82. const stc_timer4_emb_init_t *pstcInitCfg);
  83. en_result_t TIMER4_EMB_DeInit(M4_TMR4_TypeDef *TMR4x);
  84. en_result_t TIMER4_EMB_SetHoldMode(M4_TMR4_TypeDef *TMR4x,
  85. en_timer4_emb_hold_mode_t enHoldMode);
  86. en_timer4_emb_hold_mode_t TIMER4_EMB_GetHoldMode(M4_TMR4_TypeDef *TMR4x);
  87. en_result_t TIMER4_EMB_SetState(const M4_TMR4_TypeDef *TMR4x,
  88. en_timer4_emb_state_t enEmbState);
  89. en_timer4_emb_state_t TIMER4_EMB_GetState(const M4_TMR4_TypeDef *TMR4x);
  90. //@} // Timer4EmbGroup
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94. #endif /* DDL_TIMER4_EMB_ENABLE */
  95. #endif /* __HC32F460_TIMER4_EMB_H__ */
  96. /*******************************************************************************
  97. * EOF (not truncated)
  98. ******************************************************************************/