1 /*!
2  * @file       apm32e10x_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-12-31
9  *
10  * @attention
11  *
12  *  Copyright (C) 2021-2023 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 /* Define to prevent recursive inclusion */
27 #ifndef __APM32E10X_PMU_H
28 #define __APM32E10X_PMU_H
29 
30 /* Includes */
31 #include "apm32e10x.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /** @addtogroup APM32E10x_StdPeriphDriver
38   @{
39 */
40 
41 /** @addtogroup PMU_Driver
42   @{
43 */
44 
45 /** @defgroup PMU_Enumerations Enumerations
46   @{
47 */
48 
49 /**
50  * @brief PMU PVD detection level
51  */
52 typedef enum
53 {
54     PMU_PVD_LEVEL_2V2    = 0x00,    /*!< PVD detection level set to 2.2V */
55     PMU_PVD_LEVEL_2V3    = 0x01,    /*!< PVD detection level set to 2.3V */
56     PMU_PVD_LEVEL_2V4    = 0x02,    /*!< PVD detection level set to 2.4V */
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,
70     PMU_REGULATOR_LOWPOWER = 0x01
71 } PMU_REGULATOR_T;
72 
73 typedef enum
74 {
75     PMU_STOP_ENTRY_WFI     = 0x01,
76     PMU_STOP_ENTRY_WFE     = 0x02
77 } PMU_STOP_ENTRY_T;
78 
79 /**
80  * @brief PMU Flag
81  */
82 typedef enum
83 {
84     PMU_FLAG_WUE,
85     PMU_FLAG_SB,
86     PMU_FLAG_PVDO
87 } PMU_FLAG_T;
88 
89 /**@} end of group PMU_Enumerations */
90 
91 
92 /** @addtogroup PMU_Functions Functions
93   @{
94 */
95 
96 /* PMU Reset */
97 void PMU_Reset(void);
98 
99 /* Configuration and Operation modes */
100 void PMU_EnableBackupAccess(void);
101 void PMU_DisableBackupAccess(void);
102 void PMU_EnablePVD(void);
103 void PMU_DisablePVD(void);
104 void PMU_ConfigPVDLevel(PMU_PVD_LEVEL_T level);
105 void PMU_EnableWakeUpPin(void);
106 void PMU_DisableWakeUpPin(void);
107 void PMU_EnterSTOPMode(PMU_REGULATOR_T regulator, PMU_STOP_ENTRY_T entry);
108 void PMU_EnterSTANDBYMode(void);
109 
110 /* flags */
111 uint8_t PMU_ReadStatusFlag(PMU_FLAG_T flag);
112 void PMU_ClearStatusFlag(PMU_FLAG_T flag);
113 
114 /**@} end of group PMU_Functions */
115 /**@} end of group PMU_Driver */
116 /**@} end of group APM32E10x_StdPeriphDriver*/
117 
118 #ifdef __cplusplus
119 }
120 #endif
121 
122 #endif /* __APM32E10X_PMU_H */
123