ql_pwm.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*================================================================
  2. Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
  3. Quectel Wireless Solutions Proprietary and Confidential.
  4. =================================================================*/
  5. /*=================================================================
  6. EDIT HISTORY FOR MODULE
  7. This section contains comments describing changes made to the module.
  8. Notice that changes are listed in reverse chronological order.
  9. WHEN WHO WHAT, WHERE, WHY
  10. ------------ ------- -------------------------------------------------------------------------------
  11. =================================================================*/
  12. #ifndef QL_PWM_H
  13. #define QL_PWM_H
  14. #include "ql_api_common.h"
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. /*===========================================================================
  19. * Macro Definition
  20. ===========================================================================*/
  21. #define QL_PWM_ERRCODE_BASE (QL_COMPONENT_BSP_PWM<<16)
  22. /*===========================================================================
  23. * Enum
  24. ===========================================================================*/
  25. /**
  26. * PWM errcode
  27. */
  28. typedef enum
  29. {
  30. QL_PWM_SUCCESS = QL_SUCCESS,
  31. QL_PWM_EXECUTE_ERR = 1|QL_PWM_ERRCODE_BASE,
  32. QL_PWM_INVALID_PARAM_ERR,
  33. QL_PWM_FUNC_SET_ERR,
  34. QL_PWM_ACQUIRE_ERR,
  35. QL_PWM_START_ERR,
  36. QL_PWM_STOP_ERR,
  37. QL_PWM_REPEAT_OPEN_ERR,
  38. QL_PWM_REPEAT_CLOSE_ERR,
  39. }ql_errcode_pwm;
  40. /**
  41. * PWM function select
  42. */
  43. typedef enum
  44. {
  45. QL_PWM_0,
  46. QL_PWM_1,
  47. QL_PWM_2,
  48. QL_PWM_3,
  49. QL_PWM_4,
  50. QL_PWM_5,
  51. QL_PWM_6,
  52. QL_PWM_7,
  53. QL_PWM_8,
  54. QL_PWM_9,
  55. QL_PWM_10,
  56. QL_PWM_11,
  57. QL_PWM_12,
  58. QL_PWM_13,
  59. QL_PWM_14,
  60. QL_PWM_15,
  61. QL_PWM_MAX
  62. }ql_pwm_sel;
  63. typedef enum
  64. {
  65. QL_CLK_XTAL, //not support
  66. QL_CLK_XTAL_LP, //support(26M)
  67. QL_CLK_RC26M, //support(26M)
  68. QL_CLK_GNSS_PLL_133M, //not support
  69. QL_CLK_GNSS_PLL_198M, //not support
  70. QL_CLK_APLL_200M, //not support
  71. QL_CLK_APLL_250M, //not support
  72. QL_CLK_RTC_32K, //not support
  73. } ql_pwm_clk;
  74. typedef enum
  75. {
  76. IND_SIM_NOT_INSERT = 0,
  77. IND_SIM_INITIALIZING,
  78. IND_SIM_PIN_LOCK,
  79. IND_SIM_CPIN_READY,
  80. IND_SEARCHING,
  81. IND_CAMP_ON_CELL = 5,
  82. IND_REGISTERING,
  83. IND_STANDBY,
  84. IND_PDP_ACTIVING,
  85. IND_PDP_ACTIVED,
  86. IND_SOCKET_SET_UP = 10,
  87. IND_DATA_TRANSMIT,
  88. IND_PDP_DEACTIVING,
  89. IND_DIALING,
  90. IND_NET_LED_STATUS_MAX
  91. }ql_module_status;
  92. typedef enum
  93. {
  94. IND_NET_TYPE_NOT_REGISTERED,
  95. IND_NET_TYPE_2G,
  96. IND_NET_TYPE_3G,
  97. IND_NET_TYPE_4G,
  98. IND_NET_TYPE_USER_DEF,
  99. IND_NET_TYPE_MAX
  100. }ql_net_type;
  101. /*===========================================================================
  102. * Struct
  103. ===========================================================================*/
  104. /*
  105. * frequency output = Fclk/(prescaler+1)/(period+1)
  106. * duty cycle = duty/period
  107. **/
  108. typedef struct
  109. {
  110. ql_pwm_clk clk_sel;
  111. uint16_t prescaler;
  112. uint16_t period;
  113. uint16_t duty;
  114. } ql_pwm_cfg_s;
  115. /*===========================================================================
  116. * Functions declaration
  117. ===========================================================================*/
  118. /**
  119. * @brief PWM open function
  120. * @param pwm_sel :pwm type
  121. * @return
  122. * QL_PWM_FUNC_SET_ERR
  123. * QL_PWM_ACQUIRE_ERR
  124. * QL_PWM_REPEAT_OPEN_ERR
  125. * QL_PWM_SUCCESS
  126. */
  127. ql_errcode_pwm ql_pwm_open(ql_pwm_sel pwm_sel);
  128. /**
  129. * @brief PWM close function
  130. * @param pwm_sel :pwm type
  131. * @return
  132. * QL_PWM_INVALID_PARAM_ERR
  133. * QL_PWM_REPEAT_CLOSE_ERR
  134. * QL_PWM_SUCCESS
  135. */
  136. ql_errcode_pwm ql_pwm_close(ql_pwm_sel pwm_sel);
  137. /**
  138. * @brief PWM function enable
  139. * @param pwm_cfg : reference ql_pwm_cfg_s
  140. * @return
  141. * QL_PWM_INVALID_PARAM_ERR
  142. * QL_PWM_START_ERR
  143. * QL_PWM_SUCCESS
  144. */
  145. ql_errcode_pwm ql_pwm_enable(ql_pwm_sel pwm_sel, ql_pwm_cfg_s *pwm_cfg);
  146. /**
  147. * @brief PWM function disable
  148. * @param pwm_sel :pwm type
  149. * @return
  150. * QL_PWM_INVALID_PARAM_ERR
  151. * QL_PWM_STOP_ERR
  152. * QL_PWM_SUCCESS
  153. */
  154. ql_errcode_pwm ql_pwm_disable(ql_pwm_sel pwm_sel);
  155. #ifdef __cplusplus
  156. } /*"C" */
  157. #endif
  158. #endif /* QL_PWM_H */