8051-ELL库  beta 1.1.6
8051-ELL library API Document Center
STC8x_POWER.h
浏览该文件的文档.
1 /*-----------------------------------------------------------------------
2 | FILE DESCRIPTION |
3 -----------------------------------------------------------------------*/
4 /*----------------------------------------------------------------------
5  - File name : STC8Ax_POWER.h
6  - Author : zeweni
7  - Update date : 2020.02.06
8  - Copyright(C) : 2020-2021 zeweni. All rights reserved.
9 -----------------------------------------------------------------------*/
10 /*------------------------------------------------------------------------
11 | COPYRIGHT NOTICE |
12 ------------------------------------------------------------------------*/
13 /*
14  * Copyright (C) 2021, zeweni (17870070675@163.com)
15 
16  * This file is part of 8051 ELL low-layer libraries.
17 
18  * 8051 ELL low-layer libraries is free software: you can redistribute
19  * it and/or modify it under the terms of the Apache-2.0 License.
20 
21  * 8051 ELL low-layer libraries is distributed in the hope that it will
22  * be useful,but WITHOUT ANY WARRANTY; without even the implied warranty
23  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * Apache-2.0 License for more details.
25 
26  * You should have received a copy of the Apache-2.0 License.8051 ELL
27  * low-layer libraries. If not, see <http://www.apache.org/licenses/>.
28 **/
29 /*-----------------------------------------------------------------------
30 | INCLUDES |
31 -----------------------------------------------------------------------*/
32 #ifndef __STC8x_POWER_H_
33 #define __STC8x_POWER_H_
34 /*--------------------------------------------------------
35 | @Description: ELL library core |
36 --------------------------------------------------------*/
37 #include "ELL_CORE.h"
38 
39 /*--------------------------------------------------------
40 | @Description: STC8x MCU Register |
41 --------------------------------------------------------*/
42 
43 #if (PER_LIB_MCU_MUODEL == STC8Ax)
44  #include "STC8Ax_REG.h"
45 #elif (PER_LIB_MCU_MUODEL == STC8Cx)
46  #include "STC8Cx_REG.h"
47 #elif (PER_LIB_MCU_MUODEL == STC8Fx)
48  #include "STC8Fx_REG.h"
49 #elif (PER_LIB_MCU_MUODEL == STC8Gx)
50  #include "STC8Gx_REG.h"
51 #elif (PER_LIB_MCU_MUODEL == STC8Hx)
52  #include "STC8Hx_REG.h"
53 #endif
54 
55 /*-----------------------------------------------------------------------
56 | DATA |
57 -----------------------------------------------------------------------*/
58 
59 #ifndef PER_LIB_MCU_MUODEL
62  #define PER_LIB_MCU_MUODEL STC8Ax
63 #endif
64 
65 
66 #ifndef PER_LIB_POWER_CTRL
69  #define PER_LIB_POWER_CTRL 1
70 #endif
71 
72 
73 #ifndef PER_LIB_POWER_NVIC_CTRL
76  #define PER_LIB_POWER_NVIC_CTRL 1
77 #endif
78 
79 
80 #ifndef PER_LIB_POWER_WORK_CTRL
83  #define PER_LIB_POWER_WORK_CTRL 1
84 #endif
85 
86 
91 typedef enum
92 {
94  POWER_Mode_Stop = 0x02,
95  POWER_Mode_Idle = 0x03
97 
98 /*-----------------------------------------------------------------------
99 | API FUNCTION |
100 -----------------------------------------------------------------------*/
101 #if (PER_LIB_POWER_CTRL == 1)
102 
103  #if (PER_LIB_POWER_WORK_CTRL == 1)
104 
113 
119  #define POWER_GET_WORK_MODE() (PCON & 0x10)
120 
121 
127  #define ESH_CURRENT_ENABLE() VOCTRL = 0x80 /* Use external */
128 
129 
136  #define ESH_CURRENT_DISABLE() VOCTRL = 0x00 /* Use internal */
137 
138  #endif
139 
140  #if (PER_LIB_POWER_NVIC_CTRL == 1)
141 
150  FSCSTATE NVIC_LVD_Init(NVICPri_Type priority,BOOL run);
151 
157  #define LVD_GET_FLAG() (PCON & 0x20)
158 
164  #define LVD_CLEAR_FLAG() do{PCON &= 0xDF;}while(0)
165 
171  #define NVIC_LVD_CTRL(run) do{ELVD = run;}while(0)
172 
173 
180  #define NVIC_LVD_PRI(pri) \
181  do{ \
182  IPH = (IPH & 0xBF) | ((pri & 0x02) << 5); \
183  IP = (IP & 0xBF) | ((pri & 0x01) << 6); \
184  }while(0)
185 
186  #endif
187 
188 #endif
189 /*-----------------------------------------------------------------------
190 | END OF FLIE. (C) COPYRIGHT zeweni |
191 -----------------------------------------------------------------------*/
192 #endif
NVICPri_Type
Definition: ELL_CORE.h:99
BOOL
Definition: ELL_CORE.h:50
FSCSTATE
Definition: ELL_CORE.h:65
FSCSTATE NVIC_LVD_Init(NVICPri_Type priority, BOOL run)
低压检测中断初始化函数。
Definition: STC8x_POWER.c:65
POWERMode_Type
电源工作模式枚举体。
Definition: STC8x_POWER.h:92
@ POWER_Mode_Normal
Definition: STC8x_POWER.h:93
@ POWER_Mode_Idle
Definition: STC8x_POWER.h:95
@ POWER_Mode_Stop
Definition: STC8x_POWER.h:94
FSCSTATE POWER_Mode_Ctrl(POWERMode_Type mode)
电源工作模式控制函数。
Definition: STC8x_POWER.c:50