at32f413_pwc.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /**
  2. **************************************************************************
  3. * @file at32f413_pwc.h
  4. * @brief at32f413 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 __AT32F413_PWC_H
  26. #define __AT32F413_PWC_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "at32f413.h"
  32. /** @addtogroup AT32F413_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(pa0) */
  52. /** @defgroup PWC_exported_types
  53. * @{
  54. */
  55. /**
  56. * @brief pwc pvm voltage type
  57. */
  58. typedef enum
  59. {
  60. PWC_PVM_VOLTAGE_2V3 = 0x01, /*!< power voltage monitoring boundary 2.3v */
  61. PWC_PVM_VOLTAGE_2V4 = 0x02, /*!< power voltage monitoring boundary 2.4v */
  62. PWC_PVM_VOLTAGE_2V5 = 0x03, /*!< power voltage monitoring boundary 2.5v */
  63. PWC_PVM_VOLTAGE_2V6 = 0x04, /*!< power voltage monitoring boundary 2.6v */
  64. PWC_PVM_VOLTAGE_2V7 = 0x05, /*!< power voltage monitoring boundary 2.7v */
  65. PWC_PVM_VOLTAGE_2V8 = 0x06, /*!< power voltage monitoring boundary 2.8v */
  66. PWC_PVM_VOLTAGE_2V9 = 0x07 /*!< power voltage monitoring boundary 2.9v */
  67. } pwc_pvm_voltage_type;
  68. /**
  69. * @brief pwc sleep enter type
  70. */
  71. typedef enum
  72. {
  73. PWC_SLEEP_ENTER_WFI = 0x00, /*!< use wfi enter sleep mode */
  74. PWC_SLEEP_ENTER_WFE = 0x01 /*!< use wfe enter sleep mode */
  75. } pwc_sleep_enter_type;
  76. /**
  77. * @brief pwc deep sleep enter type
  78. */
  79. typedef enum
  80. {
  81. PWC_DEEP_SLEEP_ENTER_WFI = 0x00, /*!< use wfi enter deepsleep mode */
  82. PWC_DEEP_SLEEP_ENTER_WFE = 0x01 /*!< use wfe enter deepsleep mode */
  83. } pwc_deep_sleep_enter_type;
  84. /**
  85. * @brief type define pwc register all
  86. */
  87. typedef struct
  88. {
  89. /**
  90. * @brief pwc ctrl register, offset:0x00
  91. */
  92. union
  93. {
  94. __IO uint32_t ctrl;
  95. struct
  96. {
  97. __IO uint32_t reserved1 : 1; /* [0] */
  98. __IO uint32_t lpsel : 1; /* [1] */
  99. __IO uint32_t clswef : 1; /* [2] */
  100. __IO uint32_t clsef : 1; /* [3] */
  101. __IO uint32_t pvmen : 1; /* [4] */
  102. __IO uint32_t pvmsel : 3; /* [7:5] */
  103. __IO uint32_t bpwen : 1; /* [8] */
  104. __IO uint32_t reserved2 : 23;/* [31:9] */
  105. } ctrl_bit;
  106. };
  107. /**
  108. * @brief pwc ctrlsts register, offset:0x04
  109. */
  110. union
  111. {
  112. __IO uint32_t ctrlsts;
  113. struct
  114. {
  115. __IO uint32_t swef : 1; /* [0] */
  116. __IO uint32_t sef : 1; /* [1] */
  117. __IO uint32_t pvmof : 1; /* [2] */
  118. __IO uint32_t reserved1 : 5; /* [7:3] */
  119. __IO uint32_t swpen : 1; /* [8] */
  120. __IO uint32_t reserved2 : 23;/* [31:9] */
  121. } ctrlsts_bit;
  122. };
  123. } pwc_type;
  124. /**
  125. * @}
  126. */
  127. #define PWC ((pwc_type *) PWC_BASE)
  128. /** @defgroup PWC_exported_functions
  129. * @{
  130. */
  131. void pwc_reset(void);
  132. void pwc_battery_powered_domain_access(confirm_state new_state);
  133. void pwc_pvm_level_select(pwc_pvm_voltage_type pvm_voltage);
  134. void pwc_power_voltage_monitor_enable(confirm_state new_state);
  135. void pwc_wakeup_pin_enable(uint32_t pin_num, confirm_state new_state);
  136. void pwc_flag_clear(uint32_t pwc_flag);
  137. flag_status pwc_flag_get(uint32_t pwc_flag);
  138. void pwc_sleep_mode_enter(pwc_sleep_enter_type pwc_sleep_enter);
  139. void pwc_deep_sleep_mode_enter(pwc_deep_sleep_enter_type pwc_deep_sleep_enter);
  140. void pwc_standby_mode_enter(void);
  141. /**
  142. * @}
  143. */
  144. /**
  145. * @}
  146. */
  147. /**
  148. * @}
  149. */
  150. #ifdef __cplusplus
  151. }
  152. #endif
  153. #endif