apm32f0xx_pmu.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*!
  2. * @file apm32f0xx_pmu.h
  3. *
  4. * @brief This file contains all functions prototype and macros for the PMU peripheral
  5. *
  6. * @version V1.0.3
  7. *
  8. * @date 2022-09-20
  9. *
  10. * @attention
  11. *
  12. * Copyright (C) 2020-2022 Geehy Semiconductor
  13. *
  14. * You may not use this file except in compliance with the
  15. * GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
  16. *
  17. * The program is only for reference, which is distributed in the hope
  18. * that it will be useful and instructional for customers to develop
  19. * their software. Unless required by applicable law or agreed to in
  20. * writing, the program is distributed on an "AS IS" BASIS, WITHOUT
  21. * ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
  23. * and limitations under the License.
  24. */
  25. #ifndef __APM32F0XX_PMU_H
  26. #define __APM32F0XX_PMU_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. #include "apm32f0xx.h"
  31. /** @addtogroup APM32F0xx_StdPeriphDriver
  32. @{
  33. */
  34. /** @addtogroup PMU_Driver PMU Driver
  35. @{
  36. */
  37. /** @defgroup PMU_Macros Macros
  38. @{
  39. */
  40. /**@} end of group PMU_Macros */
  41. /** @defgroup PMU_Enumerations Enumerations
  42. @{
  43. */
  44. /**
  45. * @brief PVD detection level (Not for APM32F030 devices)
  46. */
  47. typedef enum
  48. {
  49. PMU_PVDLEVEL_0 = ((uint8_t)0x00), /*!< PVD detection level set to 2.2V */
  50. PMU_PVDLEVEL_1 = ((uint8_t)0x01), /*!< PVD detection level set to 2.3V */
  51. PMU_PVDLEVEL_2 = ((uint8_t)0x02), /*!< PVD detection level set to 2.4V */
  52. PMU_PVDLEVEL_3 = ((uint8_t)0x03), /*!< PVD detection level set to 2.5V */
  53. PMU_PVDLEVEL_4 = ((uint8_t)0x04), /*!< PVD detection level set to 2.6V */
  54. PMU_PVDLEVEL_5 = ((uint8_t)0x05), /*!< PVD detection level set to 2.7V */
  55. PMU_PVDLEVEL_6 = ((uint8_t)0x06), /*!< PVD detection level set to 2.8V */
  56. PMU_PVDLEVEL_7 = ((uint8_t)0x07), /*!< PVD detection level set to 2.9V */
  57. } PMU_PVDLEVEL_T;
  58. /**
  59. * @brief Wake Up PIN
  60. */
  61. typedef enum
  62. {
  63. PMU_WAKEUPPIN_1 = ((uint16_t)0x0100), /*!< PIN_1 wakeup mcu */
  64. PMU_WAKEUPPIN_2 = ((uint16_t)0x0200), /*!< PIN_2 wakeup mcu */
  65. PMU_WAKEUPPIN_3 = ((uint16_t)0x0400), /*!< PIN_3 wakeup mcu, only for APM32F072/091 devices */
  66. PMU_WAKEUPPIN_4 = ((uint16_t)0x0800), /*!< PIN_4 wakeup mcu, only for APM32F072/091 devices */
  67. PMU_WAKEUPPIN_5 = ((uint16_t)0x1000), /*!< PIN_5 wakeup mcu , only for APM32F072/091 devices */
  68. PMU_WAKEUPPIN_6 = ((uint16_t)0x2000), /*!< PIN_6, only for APM32F072/091 devices */
  69. PMU_WAKEUPPIN_7 = ((uint16_t)0x4000), /*!< PIN_7, only for APM32F072/091 devices */
  70. PMU_WAKEUPPIN_8 = ((uint16_t)0x8000), /*!< PIN_8, only for APM32F072/091 devices */
  71. } PMU_WAKEUPPIN_T;
  72. /**
  73. * @brief Sleep mode entry
  74. */
  75. typedef enum
  76. {
  77. PMU_SLEEPENTRY_WFI = 0x00, /*!< enter SLEEP mode with WFI instruction */
  78. PMU_SLEEPENTRY_WFE = 0x01, /*!< enter SLEEP mode with WFE instruction */
  79. } PMU_SLEEPENTRY_T;
  80. /**
  81. * @brief Regulator state is Sleep/Stop mode
  82. */
  83. typedef enum
  84. {
  85. PMU_REGULATOR_ON = 0x00, /*!< STOP mode with regulator ON */
  86. PMU_REGULATOR_LowPower = 0x01, /*!< STOP mode with regulator in low power mode */
  87. } PMU_REGULATOR_T;
  88. /**
  89. * @brief Stop mode entry
  90. */
  91. typedef enum
  92. {
  93. PMU_STOPENTRY_WFI = 0x00, /*!< Enter STOP mode with WFI instruction */
  94. PMU_STOPENTRY_WFE = 0x01, /*!< Enter STOP mode with WFE instruction */
  95. PMU_STOPENTRY_SLEEPONEXIT = 0x02, /*!< Enter STOP mode with SLEEPONEXIT instruction */
  96. } PMU_STOPENTRY_T;
  97. /**
  98. * @brief Flag
  99. */
  100. typedef enum
  101. {
  102. PMU_FLAG_WUPF = 0x01, /*!< Wake Up flag */
  103. PMU_FLAG_STDBYF = 0x02, /*!< StandBy flag */
  104. PMU_FLAG_PVDOF = 0x04, /*!< Not for APM32F030 devices */
  105. PMU_FLAG_VREFINTF = 0x08, /*!<VREFINT flag */
  106. } PMU_FLAG_T;
  107. /**@} end of group PMU_Enumerations*/
  108. /** @defgroup PMU_Structures Structures
  109. @{
  110. */
  111. /**@} end of group PMU_Structures */
  112. /** @defgroup PMU_Variables Variables
  113. @{
  114. */
  115. /**@} end of group PMU_Variables */
  116. /** @defgroup PMU_Fuctions Fuctions
  117. @{
  118. */
  119. /** Function used to set the PMU configuration to the default reset state */
  120. void PMU_Reset(void);
  121. /** Backup Domain Access function */
  122. void PMU_EnableBackupAccess(void);
  123. void PMU_DisableBackupAccess(void);
  124. /** PVD configuration functions */
  125. void PMU_ConfigPVDLevel(PMU_PVDLEVEL_T level); /*!< Not for APM32F030 devices */
  126. void PMU_EnablePVD(void); /*!< Not for APM32F030 devices */
  127. void PMU_DisablePVD(void); /*!< Not for APM32F030 devices */
  128. /** WakeUp pins configuration functions */
  129. void PMU_EnableWakeUpPin(PMU_WAKEUPPIN_T pin);
  130. void PMU_DisableWakeUpPin(PMU_WAKEUPPIN_T pin);
  131. /** Low Power modes configuration functions */
  132. void PMU_EnterSleepMode(PMU_SLEEPENTRY_T entry);
  133. void PMU_EnterSTOPMode(PMU_REGULATOR_T regulator, PMU_STOPENTRY_T entry);
  134. void PMU_EnterSTANDBYMode(void);
  135. /** Flags management functions */
  136. uint8_t PMU_ReadStatusFlag(PMU_FLAG_T flag);
  137. void PMU_ClearStatusFlag(uint8_t flag);
  138. #ifdef __cplusplus
  139. }
  140. #endif
  141. #endif /* __APM32F0XX_PMU_H */
  142. /**@} end of group PMU_Functions */
  143. /**@} end of group PMU_Driver */
  144. /**@} end of group APM32F0xx_StdPeriphDriver */