1 /*!
2  * @file        apm32f4xx_pmu.h
3  *
4  * @brief       This file contains all the functions prototypes for the PMU firmware library.
5  *
6  * @version     V1.0.2
7  *
8  * @date        2022-06-23
9  *
10  * @attention
11  *
12  *  Copyright (C) 2021-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 usefull 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 /* Define to prevent recursive inclusion */
27 #ifndef __APM32F4XX_PMU_H
28 #define __APM32F4XX_PMU_H
29 
30 #ifdef __cplusplus
31   extern "C" {
32 #endif
33 
34 /* Includes */
35 #include "apm32f4xx.h"
36 
37 /** @addtogroup APM32F4xx_StdPeriphDriver
38   @{
39 */
40 
41 /** @addtogroup PMU_Driver
42   @{
43 */
44 
45 /** @defgroup PMU_Enumerations
46   @{
47 */
48 
49 /**
50  * @brief PMU PVD detection level
51  */
52 typedef enum
53 {
54     PMU_PVD_LEVEL_2V0    = 0x00,    /*!< PVD detection level set to 2.0V */
55     PMU_PVD_LEVEL_2V1    = 0x01,    /*!< PVD detection level set to 2.1V */
56     PMU_PVD_LEVEL_2V3    = 0x02,    /*!< PVD detection level set to 2.3V */
57     PMU_PVD_LEVEL_2V5    = 0x03,    /*!< PVD detection level set to 2.5V */
58     PMU_PVD_LEVEL_2V6    = 0x04,    /*!< PVD detection level set to 2.6V */
59     PMU_PVD_LEVEL_2V7    = 0x05,    /*!< PVD detection level set to 2.7V */
60     PMU_PVD_LEVEL_2V8    = 0x06,    /*!< PVD detection level set to 2.8V */
61     PMU_PVD_LEVEL_2V9    = 0x07,    /*!< PVD detection level set to 2.9V */
62 } PMU_PVD_LEVEL_T;
63 
64 /**
65  * @brief PMU Regulator state in STOP mode
66  */
67 typedef enum
68 {
69     PMU_REGULATOR_ON       = 0x00,  /*!< STOP mode with regulator ON */
70     PMU_REGULATOR_LOWPOWER = 0x01   /*!< STOP mode with regulator in low power mode */
71 } PMU_REGULATOR_T;
72 
73 /**
74  * @brief PMU STOP mode entry
75  */
76 typedef enum
77 {
78     PMU_STOP_ENTRY_WFI     = 0x01,  /*!< Enter STOP mode with WFI instruction */
79     PMU_STOP_ENTRY_WFE     = 0x02   /*!< Enter STOP mode with WFE instruction */
80 } PMU_STOP_ENTRY_T;
81 
82 /**
83  * @brief PMU Regulator Voltage Scale
84  */
85 typedef enum
86 {
87     PMU_REGULATOR_VOLTAGE_SCALE1 = 0x03,    /*!< Select regulator voltage scale 1 */
88     PMU_REGULATOR_VOLTAGE_SCALE2 = 0x02,    /*!< Select regulator voltage scale 2 */
89     PMU_REGULATOR_VOLTAGE_SCALE3 = 0x01,    /*!< Select regulator voltage scale 3 */
90 } PMU_REGULATOR_VOLTAGE_SCALE_T;
91 
92 /**
93  * @brief PMU Flag
94  */
95 typedef enum
96 {
97     PMU_FLAG_WUE,   /*!< Wake Up flag */
98     PMU_FLAG_SB,    /*!< StandBy flag */
99     PMU_FLAG_PVDO,  /*!< PVD Output */
100     PMU_FLAG_BKPR,  /*!< Backup regulator ready flag */
101     PMU_FLAG_VOSR   /*!< This flag indicates that the Regulator voltage
102                             scaling output selection is ready */
103 } PMU_FLAG_T;
104 
105 /**@} end of group PMU_Enumerations*/
106 
107 /** @defgroup PMU_Functions
108   @{
109 */
110 
111 /* PMU Reset */
112 void PMU_Reset(void);
113 
114 /* Configuration and Operation modes */
115 void PMU_EnableBackupAccess(void);
116 void PMU_DisableBackupAccess(void);
117 void PMU_EnablePVD(void);
118 void PMU_DisablePVD(void);
119 void PMU_ConfigPVDLevel(PMU_PVD_LEVEL_T level);
120 void PMU_EnableWakeUpPin(void);
121 void PMU_DisableWakeUpPin(void);
122 void PMU_EnableBackupRegulator(void);
123 void PMU_DisableBackupRegulator(void);
124 void PMU_ConfigMainRegulatorMode(PMU_REGULATOR_VOLTAGE_SCALE_T scale);
125 void PMU_EnableFlashPowerDown(void);
126 void PMU_DisableFlashPowerDown(void);
127 void PMU_EnterSTOPMode(PMU_REGULATOR_T regulator, PMU_STOP_ENTRY_T entry);
128 void PMU_EnterSTANDBYMode(void);
129 
130 /* flags */
131 uint8_t PMU_ReadStatusFlag(PMU_FLAG_T flag);
132 void PMU_ClearStatusFlag(PMU_FLAG_T flag);
133 
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 #endif /* __APM32F4XX_PMU_H */
139 
140 /**@} end of group PMU_Enumerations */
141 /**@} end of group PMU_Driver */
142 /**@} end of group APM32F4xx_StdPeriphDriver */
143