1 /*!
2  * @file        apm32f10x_pmu.h
3  *
4  * @brief       This file contains all the functions prototypes for the PMU firmware library.
5  *
6  * @version     V1.0.4
7  *
8  * @date        2022-12-01
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 /* Define to prevent recursive inclusion */
27 #ifndef __APM32F10X_PMU_H
28 #define __APM32F10X_PMU_H
29 
30 /* Includes */
31 #include "apm32f10x.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /** @addtogroup APM32F10x_StdPeriphDriver
38   @{
39 */
40 
41 /** @addtogroup PMU_Driver 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 /**
74  * @brief PMU STOP mode entry
75  */
76 typedef enum
77 {
78     PMU_STOP_ENTRY_WFI     = 0x01,
79     PMU_STOP_ENTRY_WFE     = 0x02
80 } PMU_STOP_ENTRY_T;
81 
82 /**
83  * @brief PMU Flag
84  */
85 typedef enum
86 {
87     PMU_FLAG_WUE,
88     PMU_FLAG_SB,
89     PMU_FLAG_PVDO
90 } PMU_FLAG_T;
91 
92 /**@} end of group PMU_Enumerations*/
93 
94 
95 /** @addtogroup PMU_Functions Functions
96   @{
97 */
98 
99 /* PMU Reset */
100 void PMU_Reset(void);
101 
102 /* Configuration and Operation modes */
103 void PMU_EnableBackupAccess(void);
104 void PMU_DisableBackupAccess(void);
105 void PMU_EnablePVD(void);
106 void PMU_DisablePVD(void);
107 void PMU_ConfigPVDLevel(PMU_PVD_LEVEL_T level);
108 void PMU_EnableWakeUpPin(void);
109 void PMU_DisableWakeUpPin(void);
110 void PMU_EnterSTOPMode(PMU_REGULATOR_T regulator, PMU_STOP_ENTRY_T entry);
111 void PMU_EnterSTANDBYMode(void);
112 
113 /* flags */
114 uint8_t PMU_ReadStatusFlag(PMU_FLAG_T flag);
115 void PMU_ClearStatusFlag(PMU_FLAG_T flag);
116 
117 /**@} end of group PMU_Functions*/
118 /**@} end of group PMU_Driver */
119 /**@} end of group APM32F10x_StdPeriphDriver*/
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif /* __APM32F10X_PMU_H */
126