📄 power.lst
字号:
C51 COMPILER V7.05 POWER 09/09/2004 17:04:06 PAGE 1
C51 COMPILER V7.05, COMPILATION OF MODULE POWER
OBJECT MODULE PLACED IN power.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE power.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 //power.c - code recommendation for C header file
2 /***********************************************************************
3 MODULE: POWER MANAGEMENT
4 VERSION: 1.01
5 CONTAINS: Routines for controlling the power features on the Philips
6 P89LPC932
7 COPYRIGHT: Embedded Systems Academy, Inc. - www.esacademy.com
8 LICENSE: May be freely used in commercial and non-commercial code
9 without royalties provided this copyright notice remains
10 in this file and unaltered
11 WARNING: IF THIS FILE IS REGENERATED BY CODE ARCHITECT ANY CHANGES
12 MADE WILL BE LOST. WHERE POSSIBLE USE ONLY CODE ARCHITECT
13 TO CHANGE THE CONTENTS OF THIS FILE
14 GENERATED: On "Feb 24 2004" at "19:07:23" by Code Architect 2.03
15 ***********************************************************************/
16
17 // SFR description needs to be included
18 #include<REG922.h>
19 #include "power.h"
20
21 /***********************************************************************
22 DESC: Enables brownout detection to generate either a reset or
23 interrupt
24 RETURNS: Nothing
25 CAUTION: If interrupts are being used then EA must be set to 1
26 after calling this function
27 UCFG1.5 (BOE) must be set to 1
28 Turns off any power reduction mode currently in effect
29 ************************************************************************/
30 void power_brownoutenable(unsigned char type ) // POWER_BORESET or POWER_BOINTERRUPT
31
32 {
33 1 if (type == POWER_BORESET)
34 1 {
35 2 // no power reduction, enable brownout, disable interrupt
36 2 PCON &= 0xCC;
37 2 // enable brownout detect
38 2 EBO = 1;
39 2 }
40 1 else if (type == POWER_BOINTERRUPT)
41 1 {
42 2 // no power reduction, enable brownout, enable interrupt
43 2 PCON &= 0xCC;
44 2 PCON |= 0x10;
45 2
46 2 // set isr priority to 0
47 2 IP0 &= 0xDF;
48 2 IP0H &= 0xDF;
49 2
50 2 // enable brownout detect
51 2 EBO = 1;
52 2 }
53 1 } // power_brownoutenable
54
55 /***********************************************************************
C51 COMPILER V7.05 POWER 09/09/2004 17:04:06 PAGE 2
56 DESC: Disables brownout detection
57 RETURNS: Nothing
58 CAUTION: UCFG1.5 (BOE) is ignored
59 ************************************************************************/
60 void power_brownoutdisable(void)
61 {
62 1 // disable brownout
63 1 PCON |= 0x20;
64 1 } // power_brownoutdisable
65
66 /***********************************************************************
67 DESC: Indicates if the last reset was caused by a brownout reset
68 Only use this if brownout is enabled with POWER_BORESET
69 RETURNS: 0 if the reset was not a brownout reset
70 1 if the reset was a brownout reset
71 ************************************************************************/
72 unsigned char power_isbrownoutreset(void)
73 {
74 1 unsigned char bof;
75 1
76 1 // get bof
77 1 bof = (RSTSRC >> 5) & 0x01;
78 1
79 1 // clear bof
80 1 RSTSRC &= ~0x20;
81 1
82 1 // return bof
83 1 return bof;
84 1 } // power_isbrownoutreset
85
86 /***********************************************************************
87 DESC: Brownout Interrupt
88 RETURNS: Nothing
89 CAUTION: uart_init must be called first
90 EA must be set to 1
91 ************************************************************************/
92 void power_brownoutisr(void ) interrupt 5 using 1
93 {
94 1 // clear bof
95 1 RSTSRC &= ~0x20;
96 1 } // power_brownoutisr
97
98 /***********************************************************************
99 DESC: Indicates if the last reset was caused by power on
100 RETURNS: 0 if the reset was not power on
101 1 if the reset was power on
102 ************************************************************************/
103 unsigned char power_ispoweronreset(void)
104 {
105 1 unsigned char pof;
106 1
107 1 // get pof
108 1 pof = (RSTSRC >> 4) & 0x01;
109 1
110 1 // clear pof
111 1 RSTSRC &= ~0x10;
112 1
113 1 // return pof
114 1 return pof;
115 1 } // power_ispoweronreset
116
117 /***********************************************************************
C51 COMPILER V7.05 POWER 09/09/2004 17:04:06 PAGE 3
118 DESC: Selects a power reduction mode
119 RETURNS: nothing
120 CAUTION: Some modes will cause various peripherals to either work
121 differently or stop working
122 ************************************************************************/
123 void power_mode(unsigned char mode ) // power reduction mode POWER_NORMAL, POWER_IDLE
124 // POWER_POWERDOWN or POWER_TOTALPOWERDOWN
125
126 {
127 1 // disable power reduction
128 1 PCON &= 0xFC;
129 1
130 1 if (mode == POWER_IDLE)
131 1 PCON |= 0x01;
132 1 else if (mode == POWER_POWERDOWN)
133 1 PCON |= 0x02;
134 1 else if (mode == POWER_TOTALPOWERDOWN)
135 1 PCON |= 0x03;
136 1 } // power_mode
137
138 /***********************************************************************
139 DESC: Powers down one or more peripherals
140 RETURNS: nothing
141 ************************************************************************/
142 void power_powerdown( unsigned char peripherals ) // ORd list of peripherals to power down
143 // e.g. POWER_RTC | POWER_SPI
144
145 {
146 1 // power down peripherals
147 1 PCONA |= peripherals;
148 1 } // power_powerdown
149
150 /***********************************************************************
151 DESC: Powers up one or more peripherals that were previously powered
152 down
153 RETURNS: nothing
154 ************************************************************************/
155 void power_powerup(unsigned char peripherals ) // ORd list of peripherals to power up
156 // e.g. POWER_RTC | POWER_SPI
157
158 {
159 1 // power up peripherals
160 1 PCONA &= ~peripherals;
161 1 } // power_powerup
162
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 89 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -