lptim.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /******************************************************************************
  2. * Copyright (C) 2021, Xiaohua Semiconductor Co., Ltd. All rights reserved.
  3. *
  4. * This software component is licensed by XHSC 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. /******************************************************************************
  11. * @file lptim.h
  12. *
  13. * @brief Header file for LPTIM functions
  14. *
  15. * @author MADS Team
  16. *
  17. ******************************************************************************/
  18. #ifndef __LPTIM_H__
  19. #define __LPTIM_H__
  20. /*****************************************************************************
  21. * Include files
  22. *****************************************************************************/
  23. #include "ddl.h"
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. /**
  29. *******************************************************************************
  30. ** \brief LPTIMx 预除频
  31. ** \note LPTIMx_CR PRS 在定时器运行时不可以更改该值
  32. ******************************************************************************/
  33. typedef enum
  34. {
  35. LptimPrsDiv1 = 0, // 1分频
  36. LptimPrsDiv2 = 1, // 2分频
  37. LptimPrsDiv4 = 2, // 4分频
  38. LptimPrsDiv8 = 3, // 8分频
  39. LptimPrsDiv16 = 4, // 16分频
  40. LptimPrsDiv32 = 5, // 32分频
  41. LptimPrsDiv64 = 6, // 64分频
  42. LptimPrsDiv256 = 7 // 256分频
  43. }en_lptim_prs_t;
  44. /**
  45. *******************************************************************************
  46. ** \brief LPTIMx 时钟选择
  47. ** \note LPTIMx_CR TCK_SEL
  48. ******************************************************************************/
  49. typedef enum
  50. {
  51. LptimPclk = 0,
  52. LptimXtl = 2,
  53. LptimRcl = 3
  54. }en_lptim_tcksel_t;
  55. /**
  56. *******************************************************************************
  57. ** \brief LPTIMx GATE极性控制位
  58. ** \note LPTIMx_CR GATE_P
  59. ******************************************************************************/
  60. typedef enum
  61. {
  62. LptimGatePLow = 0,
  63. LptimGatePHigh = 1
  64. }en_lptim_gatep_t;
  65. /**
  66. *******************************************************************************
  67. ** \brief LPTIMx 时钟选择
  68. ** \note LPTIMx_CR GATE
  69. ******************************************************************************/
  70. typedef enum
  71. {
  72. LptimGateLow = 0,
  73. LptimGateHigh = 1
  74. }en_lptim_gate_t;
  75. /**
  76. *******************************************************************************
  77. ** \brief LPTIMx TOG输出使能位
  78. ** \note LPTIMx_CR TOG
  79. ******************************************************************************/
  80. typedef enum
  81. {
  82. LptimTogEnLow = 0,
  83. LptimTogEnHigh = 1
  84. }en_lptim_togen_t;
  85. /**
  86. *******************************************************************************
  87. ** \brief LPTIMx CT计数器/定时器功能选择
  88. ** \note LPTIMx_CR CT
  89. ******************************************************************************/
  90. typedef enum
  91. {
  92. LptimTimerFun = 0, //警示器功能,定时器使用TCK_SEL选择的时钟进行计数
  93. LptimCntFun = 1 //计数器功能,计数器使用外部输入的下降沿进行计数,采样时钟使用TCK_SEL选择的时钟
  94. }en_lptim_ct_t;
  95. /**
  96. *******************************************************************************
  97. ** \brief LPTIMx 定时器工作模式
  98. ** \note LPTIMx_CR MD
  99. ******************************************************************************/
  100. typedef enum
  101. {
  102. LptimMode1 = 0, //模式1无重载16位计数器/定时器
  103. LptimMode2 = 1 //模式2自动重载16位计数器/定时器
  104. }en_lptim_md_t;
  105. /**
  106. *******************************************************************************
  107. ** \brief LPTIMx 初始化配置的结构体
  108. ** \note
  109. ******************************************************************************/
  110. typedef struct
  111. {
  112. en_lptim_prs_t enPrs;
  113. en_lptim_tcksel_t enTcksel;
  114. en_lptim_gatep_t enGatep;
  115. en_lptim_gate_t enGate;
  116. en_lptim_togen_t enTogen;
  117. en_lptim_ct_t enCt;
  118. en_lptim_md_t enMd;
  119. uint16_t u16Arr;
  120. }stc_lptim_cfg_t;
  121. /******************************************************************************
  122. * Global variable declarations ('extern', definition in C source)
  123. *****************************************************************************/
  124. /******************************************************************************
  125. * Global function prototypes (definition in C source)
  126. *****************************************************************************/
  127. extern void Lptim_ConfIt(M0P_LPTIMER_TypeDef* Lptimx, boolean_t NewStatus);
  128. extern void Lptim_Cmd(M0P_LPTIMER_TypeDef* Lptimx, boolean_t NewStatus);
  129. extern boolean_t Lptim_GetItStatus(M0P_LPTIMER_TypeDef* Lptimx);
  130. extern void Lptim_ClrItStatus(M0P_LPTIMER_TypeDef* Lptimx);
  131. extern en_result_t Lptim_Init(M0P_LPTIMER_TypeDef* Lptimx, stc_lptim_cfg_t* InitStruct);
  132. #ifdef __cplusplus
  133. #endif
  134. #endif //__LPTIM_H__
  135. /******************************************************************************
  136. * EOF (not truncated)
  137. *****************************************************************************/