hc32l196_lptim.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /******************************************************************************
  2. * Copyright (C) 2019, Huada Semiconductor Co.,Ltd All rights reserved.
  3. *
  4. * This software is owned and published by:
  5. * Huada Semiconductor Co.,Ltd ("HDSC").
  6. *
  7. * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
  8. * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
  9. *
  10. * This software contains source code for use with HDSC
  11. * components. This software is licensed by HDSC to be adapted only
  12. * for use in systems utilizing HDSC components. HDSC shall not be
  13. * responsible for misuse or illegal use of this software for devices not
  14. * supported herein. HDSC is providing this software "AS IS" and will
  15. * not be responsible for issues arising from incorrect user implementation
  16. * of the software.
  17. *
  18. * Disclaimer:
  19. * HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
  20. * REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
  21. * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
  22. * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
  23. * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
  24. * WARRANTY OF NONINFRINGEMENT.
  25. * HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
  26. * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
  27. * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
  28. * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
  29. * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
  30. * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
  31. * SAVINGS OR PROFITS,
  32. * EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  33. * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
  34. * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
  35. * FROM, THE SOFTWARE.
  36. *
  37. * This software may be replicated in part or whole for the licensed use,
  38. * with the restriction that this Disclaimer and Copyright notice must be
  39. * included with each copy of this software, whether used in part or whole,
  40. * at all times.
  41. */
  42. /*****************************************************************************/
  43. /** \file lptim.h
  44. **
  45. **
  46. **
  47. **
  48. ** History:
  49. ** - 2019-04-09 First version
  50. **
  51. *****************************************************************************/
  52. #ifndef __LPTIM_H__
  53. #define __LPTIM_H__
  54. /*****************************************************************************
  55. * Include files
  56. *****************************************************************************/
  57. #include "ddl.h"
  58. #ifdef __cplusplus
  59. extern "C"
  60. {
  61. #endif
  62. /**
  63. *******************************************************************************
  64. ** \brief LPTIMx 预除频
  65. ** \note LPTIMx_CR PRS 在定时器运行时不可以更改该值
  66. ******************************************************************************/
  67. typedef enum
  68. {
  69. LptimPrsDiv1 = 0, // 1分频
  70. LptimPrsDiv2 = 1, // 2分频
  71. LptimPrsDiv4 = 2, // 4分频
  72. LptimPrsDiv8 = 3, // 8分频
  73. LptimPrsDiv16 = 4, // 16分频
  74. LptimPrsDiv32 = 5, // 32分频
  75. LptimPrsDiv64 = 6, // 64分频
  76. LptimPrsDiv256 = 7 // 256分频
  77. }en_lptim_prs_t;
  78. /**
  79. *******************************************************************************
  80. ** \brief LPTIMx 时钟选择
  81. ** \note LPTIMx_CR TCK_SEL
  82. ******************************************************************************/
  83. typedef enum
  84. {
  85. LptimPclk = 0,
  86. LptimXtl = 2,
  87. LptimRcl = 3
  88. }en_lptim_tcksel_t;
  89. /**
  90. *******************************************************************************
  91. ** \brief LPTIMx GATE极性控制位
  92. ** \note LPTIMx_CR GATE_P
  93. ******************************************************************************/
  94. typedef enum
  95. {
  96. LptimGatePLow = 0,
  97. LptimGatePHigh = 1
  98. }en_lptim_gatep_t;
  99. /**
  100. *******************************************************************************
  101. ** \brief LPTIMx 时钟选择
  102. ** \note LPTIMx_CR GATE
  103. ******************************************************************************/
  104. typedef enum
  105. {
  106. LptimGateLow = 0,
  107. LptimGateHigh = 1
  108. }en_lptim_gate_t;
  109. /**
  110. *******************************************************************************
  111. ** \brief LPTIMx TOG输出使能位
  112. ** \note LPTIMx_CR TOG
  113. ******************************************************************************/
  114. typedef enum
  115. {
  116. LptimTogEnLow = 0,
  117. LptimTogEnHigh = 1
  118. }en_lptim_togen_t;
  119. /**
  120. *******************************************************************************
  121. ** \brief LPTIMx CT计数器/定时器功能选择
  122. ** \note LPTIMx_CR CT
  123. ******************************************************************************/
  124. typedef enum
  125. {
  126. LptimTimerFun = 0, //警示器功能,定时器使用TCK_SEL选择的时钟进行计数
  127. LptimCntFun = 1 //计数器功能,计数器使用外部输入的下降沿进行计数,采样时钟使用TCK_SEL选择的时钟
  128. }en_lptim_ct_t;
  129. /**
  130. *******************************************************************************
  131. ** \brief LPTIMx 定时器工作模式
  132. ** \note LPTIMx_CR MD
  133. ******************************************************************************/
  134. typedef enum
  135. {
  136. LptimMode1 = 0, //模式1无重载16位计数器/定时器
  137. LptimMode2 = 1 //模式2自动重载16位计数器/定时器
  138. }en_lptim_md_t;
  139. /**
  140. *******************************************************************************
  141. ** \brief LPTIMx 初始化配置的结构体
  142. ** \note
  143. ******************************************************************************/
  144. typedef struct
  145. {
  146. en_lptim_prs_t enPrs;
  147. en_lptim_tcksel_t enTcksel;
  148. en_lptim_gatep_t enGatep;
  149. en_lptim_gate_t enGate;
  150. en_lptim_togen_t enTogen;
  151. en_lptim_ct_t enCt;
  152. en_lptim_md_t enMd;
  153. uint16_t u16Arr;
  154. }stc_lptim_cfg_t;
  155. /******************************************************************************
  156. * Global variable declarations ('extern', definition in C source)
  157. *****************************************************************************/
  158. /******************************************************************************
  159. * Global function prototypes (definition in C source)
  160. *****************************************************************************/
  161. extern void Lptim_ConfIt(M0P_LPTIMER_TypeDef* Lptimx, boolean_t NewStatus);
  162. extern void Lptim_Cmd(M0P_LPTIMER_TypeDef* Lptimx, boolean_t NewStatus);
  163. extern boolean_t Lptim_GetItStatus(M0P_LPTIMER_TypeDef* Lptimx);
  164. extern void Lptim_ClrItStatus(M0P_LPTIMER_TypeDef* Lptimx);
  165. extern en_result_t Lptim_Init(M0P_LPTIMER_TypeDef* Lptimx, stc_lptim_cfg_t* InitStruct);
  166. #ifdef __cplusplus
  167. #endif
  168. #endif //__LPTIM_H__
  169. /******************************************************************************
  170. * EOF (not truncated)
  171. *****************************************************************************/