at32f425_pwc.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /**
  2. **************************************************************************
  3. * @file at32f425_pwc.h
  4. * @brief at32f425 pwc header file
  5. **************************************************************************
  6. * Copyright notice & Disclaimer
  7. *
  8. * The software Board Support Package (BSP) that is made available to
  9. * download from Artery official website is the copyrighted work of Artery.
  10. * Artery authorizes customers to use, copy, and distribute the BSP
  11. * software and its related documentation for the purpose of design and
  12. * development in conjunction with Artery microcontrollers. Use of the
  13. * software is governed by this copyright notice and the following disclaimer.
  14. *
  15. * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  16. * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  17. * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  18. * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  19. * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  21. *
  22. **************************************************************************
  23. */
  24. /* Define to prevent recursive inclusion -------------------------------------*/
  25. #ifndef __AT32F425_PWC_H
  26. #define __AT32F425_PWC_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "at32f425.h"
  32. /** @addtogroup AT32F425_periph_driver
  33. * @{
  34. */
  35. /** @addtogroup PWC
  36. * @{
  37. */
  38. /** @defgroup PWC_flags_definition
  39. * @brief pwc flag
  40. * @{
  41. */
  42. #define PWC_WAKEUP_FLAG ((uint32_t)0x00000001) /*!< wakeup flag */
  43. #define PWC_STANDBY_FLAG ((uint32_t)0x00000002) /*!< standby flag */
  44. #define PWC_PVM_OUTPUT_FLAG ((uint32_t)0x00000004) /*!< pvm output flag */
  45. /**
  46. * @}
  47. */
  48. /**
  49. * @brief pwc wakeup pin num definition
  50. */
  51. #define PWC_WAKEUP_PIN_1 ((uint32_t)0x00000100) /*!< standby wake-up pin1 */
  52. #define PWC_WAKEUP_PIN_2 ((uint32_t)0x00000200) /*!< standby wake-up pin2 */
  53. #define PWC_WAKEUP_PIN_4 ((uint32_t)0x00000800) /*!< standby wake-up pin4 */
  54. #define PWC_WAKEUP_PIN_5 ((uint32_t)0x00001000) /*!< standby wake-up pin5 */
  55. #define PWC_WAKEUP_PIN_6 ((uint32_t)0x00002000) /*!< standby wake-up pin6 */
  56. #define PWC_WAKEUP_PIN_7 ((uint32_t)0x00004000) /*!< standby wake-up pin7 */
  57. /** @defgroup PWC_exported_types
  58. * @{
  59. */
  60. /**
  61. * @brief pwc pvm voltage type
  62. */
  63. typedef enum
  64. {
  65. PWC_PVM_VOLTAGE_2V3 = 0x01, /*!< power voltage monitoring boundary 2.3v */
  66. PWC_PVM_VOLTAGE_2V4 = 0x02, /*!< power voltage monitoring boundary 2.4v */
  67. PWC_PVM_VOLTAGE_2V5 = 0x03, /*!< power voltage monitoring boundary 2.5v */
  68. PWC_PVM_VOLTAGE_2V6 = 0x04, /*!< power voltage monitoring boundary 2.6v */
  69. PWC_PVM_VOLTAGE_2V7 = 0x05, /*!< power voltage monitoring boundary 2.7v */
  70. PWC_PVM_VOLTAGE_2V8 = 0x06, /*!< power voltage monitoring boundary 2.8v */
  71. PWC_PVM_VOLTAGE_2V9 = 0x07 /*!< power voltage monitoring boundary 2.9v */
  72. } pwc_pvm_voltage_type;
  73. /**
  74. * @brief pwc sleep enter type
  75. */
  76. typedef enum
  77. {
  78. PWC_SLEEP_ENTER_WFI = 0x00, /*!< use wfi enter sleep mode */
  79. PWC_SLEEP_ENTER_WFE = 0x01 /*!< use wfe enter sleep mode */
  80. } pwc_sleep_enter_type;
  81. /**
  82. * @brief pwc deep sleep enter type
  83. */
  84. typedef enum
  85. {
  86. PWC_DEEP_SLEEP_ENTER_WFI = 0x00, /*!< use wfi enter deepsleep mode */
  87. PWC_DEEP_SLEEP_ENTER_WFE = 0x01 /*!< use wfe enter deepsleep mode */
  88. } pwc_deep_sleep_enter_type;
  89. /**
  90. * @brief pwc regulator type
  91. */
  92. typedef enum
  93. {
  94. PWC_REGULATOR_ON = 0x00, /*!< voltage regulator state on when deepsleep mode */
  95. PWC_REGULATOR_LOW_POWER = 0x01, /*!< voltage regulator state low power when deepsleep mode */
  96. PWC_REGULATOR_EXTRA_LOW_POWER = 0x02 /*!< voltage regulator state extra low power when deepsleep mode */
  97. } pwc_regulator_type;
  98. /**
  99. * @brief type define pwc register all
  100. */
  101. typedef struct
  102. {
  103. /**
  104. * @brief pwc ctrl register, offset:0x00
  105. */
  106. union
  107. {
  108. __IO uint32_t ctrl;
  109. struct
  110. {
  111. __IO uint32_t vrsel : 1; /* [0] */
  112. __IO uint32_t lpsel : 1; /* [1] */
  113. __IO uint32_t clswef : 1; /* [2] */
  114. __IO uint32_t clsef : 1; /* [3] */
  115. __IO uint32_t pvmen : 1; /* [4] */
  116. __IO uint32_t pvmsel : 3; /* [7:5] */
  117. __IO uint32_t bpwen : 1; /* [8] */
  118. __IO uint32_t reserved1 : 23;/* [31:9] */
  119. } ctrl_bit;
  120. };
  121. /**
  122. * @brief pwc ctrlsts register, offset:0x04
  123. */
  124. union
  125. {
  126. __IO uint32_t ctrlsts;
  127. struct
  128. {
  129. __IO uint32_t swef : 1; /* [0] */
  130. __IO uint32_t sef : 1; /* [1] */
  131. __IO uint32_t pvmof : 1; /* [2] */
  132. __IO uint32_t reserved1 : 5; /* [7:3] */
  133. __IO uint32_t swpen1 : 1; /* [8] */
  134. __IO uint32_t swpen2 : 1; /* [9] */
  135. __IO uint32_t reserved2 : 3; /* [12:10] */
  136. __IO uint32_t swpen6 : 1; /* [13] */
  137. __IO uint32_t swpen7 : 1; /* [14] */
  138. __IO uint32_t reserved3 : 17;/* [31:15] */
  139. } ctrlsts_bit;
  140. };
  141. /**
  142. * @brief pwc reserved register, offset:0x08~0x1C
  143. */
  144. __IO uint32_t reserved1[6];
  145. /**
  146. * @brief pwc ctrl2 register, offset:0x20
  147. */
  148. union
  149. {
  150. __IO uint32_t ctrl2;
  151. struct
  152. {
  153. __IO uint32_t reserved1 : 5;/* [4:0] */
  154. __IO uint32_t vrexlpen : 1; /* [5] */
  155. __IO uint32_t reserved2 : 26;/* [31:6] */
  156. } ctrl2_bit;
  157. };
  158. } pwc_type;
  159. /**
  160. * @}
  161. */
  162. #define PWC ((pwc_type *) PWC_BASE)
  163. /** @defgroup PWC_exported_functions
  164. * @{
  165. */
  166. void pwc_reset(void);
  167. void pwc_battery_powered_domain_access(confirm_state new_state);
  168. void pwc_pvm_level_select(pwc_pvm_voltage_type pvm_voltage);
  169. void pwc_power_voltage_monitor_enable(confirm_state new_state);
  170. void pwc_wakeup_pin_enable(uint32_t pin_num, confirm_state new_state);
  171. void pwc_flag_clear(uint32_t pwc_flag);
  172. flag_status pwc_flag_get(uint32_t pwc_flag);
  173. void pwc_sleep_mode_enter(pwc_sleep_enter_type pwc_sleep_enter);
  174. void pwc_deep_sleep_mode_enter(pwc_deep_sleep_enter_type pwc_deep_sleep_enter);
  175. void pwc_voltage_regulate_set(pwc_regulator_type pwc_regulator);
  176. void pwc_standby_mode_enter(void);
  177. /**
  178. * @}
  179. */
  180. /**
  181. * @}
  182. */
  183. /**
  184. * @}
  185. */
  186. #ifdef __cplusplus
  187. }
  188. #endif
  189. #endif