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 26 #ifndef __APM32F0XX_PMU_H 27 #define __APM32F0XX_PMU_H 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #include "apm32f0xx.h" 34 35 /** @addtogroup APM32F0xx_StdPeriphDriver 36 @{ 37 */ 38 39 /** @addtogroup PMU_Driver PMU Driver 40 @{ 41 */ 42 43 /** @defgroup PMU_Macros Macros 44 @{ 45 */ 46 47 /**@} end of group PMU_Macros */ 48 49 /** @defgroup PMU_Enumerations Enumerations 50 @{ 51 */ 52 53 /** 54 * @brief PVD detection level (Not for APM32F030 devices) 55 */ 56 typedef enum 57 { 58 PMU_PVDLEVEL_0 = ((uint8_t)0x00), /*!< PVD detection level set to 2.2V */ 59 PMU_PVDLEVEL_1 = ((uint8_t)0x01), /*!< PVD detection level set to 2.3V */ 60 PMU_PVDLEVEL_2 = ((uint8_t)0x02), /*!< PVD detection level set to 2.4V */ 61 PMU_PVDLEVEL_3 = ((uint8_t)0x03), /*!< PVD detection level set to 2.5V */ 62 PMU_PVDLEVEL_4 = ((uint8_t)0x04), /*!< PVD detection level set to 2.6V */ 63 PMU_PVDLEVEL_5 = ((uint8_t)0x05), /*!< PVD detection level set to 2.7V */ 64 PMU_PVDLEVEL_6 = ((uint8_t)0x06), /*!< PVD detection level set to 2.8V */ 65 PMU_PVDLEVEL_7 = ((uint8_t)0x07), /*!< PVD detection level set to 2.9V */ 66 } PMU_PVDLEVEL_T; 67 68 69 /** 70 * @brief Wake Up PIN 71 */ 72 typedef enum 73 { 74 PMU_WAKEUPPIN_1 = ((uint16_t)0x0100), /*!< PIN_1 wakeup mcu */ 75 PMU_WAKEUPPIN_2 = ((uint16_t)0x0200), /*!< PIN_2 wakeup mcu */ 76 PMU_WAKEUPPIN_3 = ((uint16_t)0x0400), /*!< PIN_3 wakeup mcu, only for APM32F072/091 devices */ 77 PMU_WAKEUPPIN_4 = ((uint16_t)0x0800), /*!< PIN_4 wakeup mcu, only for APM32F072/091 devices */ 78 PMU_WAKEUPPIN_5 = ((uint16_t)0x1000), /*!< PIN_5 wakeup mcu , only for APM32F072/091 devices */ 79 PMU_WAKEUPPIN_6 = ((uint16_t)0x2000), /*!< PIN_6, only for APM32F072/091 devices */ 80 PMU_WAKEUPPIN_7 = ((uint16_t)0x4000), /*!< PIN_7, only for APM32F072/091 devices */ 81 PMU_WAKEUPPIN_8 = ((uint16_t)0x8000), /*!< PIN_8, only for APM32F072/091 devices */ 82 } PMU_WAKEUPPIN_T; 83 84 /** 85 * @brief Sleep mode entry 86 */ 87 typedef enum 88 { 89 PMU_SLEEPENTRY_WFI = 0x00, /*!< enter SLEEP mode with WFI instruction */ 90 PMU_SLEEPENTRY_WFE = 0x01, /*!< enter SLEEP mode with WFE instruction */ 91 } PMU_SLEEPENTRY_T; 92 93 /** 94 * @brief Regulator state is Sleep/Stop mode 95 */ 96 typedef enum 97 { 98 PMU_REGULATOR_ON = 0x00, /*!< STOP mode with regulator ON */ 99 PMU_REGULATOR_LowPower = 0x01, /*!< STOP mode with regulator in low power mode */ 100 } PMU_REGULATOR_T; 101 102 /** 103 * @brief Stop mode entry 104 */ 105 typedef enum 106 { 107 PMU_STOPENTRY_WFI = 0x00, /*!< Enter STOP mode with WFI instruction */ 108 PMU_STOPENTRY_WFE = 0x01, /*!< Enter STOP mode with WFE instruction */ 109 PMU_STOPENTRY_SLEEPONEXIT = 0x02, /*!< Enter STOP mode with SLEEPONEXIT instruction */ 110 } PMU_STOPENTRY_T; 111 112 /** 113 * @brief Flag 114 */ 115 typedef enum 116 { 117 PMU_FLAG_WUPF = 0x01, /*!< Wake Up flag */ 118 PMU_FLAG_STDBYF = 0x02, /*!< StandBy flag */ 119 PMU_FLAG_PVDOF = 0x04, /*!< Not for APM32F030 devices */ 120 PMU_FLAG_VREFINTF = 0x08, /*!<VREFINT flag */ 121 } PMU_FLAG_T; 122 123 /**@} end of group PMU_Enumerations*/ 124 125 /** @defgroup PMU_Structures Structures 126 @{ 127 */ 128 129 /**@} end of group PMU_Structures */ 130 131 /** @defgroup PMU_Variables Variables 132 @{ 133 */ 134 135 /**@} end of group PMU_Variables */ 136 137 /** @defgroup PMU_Fuctions Fuctions 138 @{ 139 */ 140 141 /** Function used to set the PMU configuration to the default reset state */ 142 void PMU_Reset(void); 143 144 /** Backup Domain Access function */ 145 void PMU_EnableBackupAccess(void); 146 void PMU_DisableBackupAccess(void); 147 148 /** PVD configuration functions */ 149 void PMU_ConfigPVDLevel(PMU_PVDLEVEL_T level); /*!< Not for APM32F030 devices */ 150 void PMU_EnablePVD(void); /*!< Not for APM32F030 devices */ 151 void PMU_DisablePVD(void); /*!< Not for APM32F030 devices */ 152 153 /** WakeUp pins configuration functions */ 154 void PMU_EnableWakeUpPin(PMU_WAKEUPPIN_T pin); 155 void PMU_DisableWakeUpPin(PMU_WAKEUPPIN_T pin); 156 157 /** Low Power modes configuration functions */ 158 void PMU_EnterSleepMode(PMU_SLEEPENTRY_T entry); 159 void PMU_EnterSTOPMode(PMU_REGULATOR_T regulator, PMU_STOPENTRY_T entry); 160 void PMU_EnterSTANDBYMode(void); 161 162 /** Flags management functions */ 163 uint8_t PMU_ReadStatusFlag(PMU_FLAG_T flag); 164 void PMU_ClearStatusFlag(uint8_t flag); 165 166 #ifdef __cplusplus 167 } 168 #endif 169 170 #endif /* __APM32F0XX_PMU_H */ 171 172 /**@} end of group PMU_Functions */ 173 /**@} end of group PMU_Driver */ 174 /**@} end of group APM32F0xx_StdPeriphDriver */ 175