1 |
577 |
jeremybenn |
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
|
2 |
|
|
* File Name : pcu.h
|
3 |
|
|
* Author : MCD Application Team
|
4 |
|
|
* Date First Issued : 30/05/2003
|
5 |
|
|
* Description : This file contains all the functions prototypes for the
|
6 |
|
|
* PCU software library.
|
7 |
|
|
********************************************************************************
|
8 |
|
|
* History:
|
9 |
|
|
* 30/11/2004 : V2.0
|
10 |
|
|
* 14/07/2004 : V1.3
|
11 |
|
|
* 01/01/2004 : V1.2
|
12 |
|
|
*******************************************************************************
|
13 |
|
|
THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
|
14 |
|
|
CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
15 |
|
|
AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
|
16 |
|
|
OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
|
17 |
|
|
OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
|
18 |
|
|
CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
19 |
|
|
*******************************************************************************/
|
20 |
|
|
#ifndef __PCU_H
|
21 |
|
|
#define __PCU_H
|
22 |
|
|
|
23 |
|
|
#include "71x_map.h"
|
24 |
|
|
|
25 |
|
|
typedef enum
|
26 |
|
|
{
|
27 |
|
|
PCU_WREN = 0x8000,
|
28 |
|
|
PCU_VROK = 0x1000
|
29 |
|
|
} PCU_Flags;
|
30 |
|
|
|
31 |
|
|
typedef enum
|
32 |
|
|
{
|
33 |
|
|
PCU_STABLE,
|
34 |
|
|
PCU_UNSTABLE
|
35 |
|
|
} PCU_VR_Status;
|
36 |
|
|
|
37 |
|
|
typedef enum
|
38 |
|
|
{
|
39 |
|
|
PCU_MVR = 0x0008,
|
40 |
|
|
PCU_LPR = 0x0020
|
41 |
|
|
} PCU_VR;
|
42 |
|
|
|
43 |
|
|
typedef enum
|
44 |
|
|
{
|
45 |
|
|
WFI_CLOCK2_16,
|
46 |
|
|
WFI_EXTERNAL
|
47 |
|
|
} WFI_CLOCKS;
|
48 |
|
|
|
49 |
|
|
typedef enum
|
50 |
|
|
{
|
51 |
|
|
PCU_SLOW,
|
52 |
|
|
PCU_STOP,
|
53 |
|
|
PCU_STANDBY
|
54 |
|
|
} LPM_MODES;
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
// VR_OK : Voltage Regulator OK
|
58 |
|
|
#define PCU_VROK_Mask 0x1000
|
59 |
|
|
|
60 |
|
|
// Main Voltage Regulator
|
61 |
|
|
#define PCU_MVR_Mask 0x0008
|
62 |
|
|
|
63 |
|
|
// Low Power Voltage Regulator
|
64 |
|
|
#define PCU_LPR_Mask 0x0020
|
65 |
|
|
|
66 |
|
|
// PCU register Write Enable Bit
|
67 |
|
|
#define PCU_WREN_Mask 0x8000
|
68 |
|
|
|
69 |
|
|
// Low Voltage Detector
|
70 |
|
|
#define PCU_LVD_Mask 0x0100
|
71 |
|
|
|
72 |
|
|
// Power Down Flag
|
73 |
|
|
#define PCU_PWRDWN_Mask 0x0040
|
74 |
|
|
|
75 |
|
|
// WFI Mode Clock Selection Bit
|
76 |
|
|
#define PCU_WFI_CKSEL_Mask 0x00000002
|
77 |
|
|
|
78 |
|
|
// Halt Mode Enable Bit
|
79 |
|
|
#define PCU_EN_HALT_Mask 0x00000800
|
80 |
|
|
|
81 |
|
|
// Halt Mode Flag
|
82 |
|
|
#define PCU_HALT_Mask 0x0002
|
83 |
|
|
|
84 |
|
|
// Stop Mode Enable Bit
|
85 |
|
|
#define PCU_STOP_EN_Mask 0x00000400
|
86 |
|
|
|
87 |
|
|
// Low Power Regulator in Wait For interrupt Mode
|
88 |
|
|
#define PCU_LPRWFI_Mask 0x0020
|
89 |
|
|
|
90 |
|
|
// Low Power Mode in Wait For interrupt Mode
|
91 |
|
|
#define PCU_LPOWFI_Mask 0x00000001
|
92 |
|
|
|
93 |
|
|
// Software Reset Enable
|
94 |
|
|
#define PCU_SRESEN_Mask 0x00000001
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
/*******************************************************************************
|
98 |
|
|
* Function Name : PCU_MVRStatus
|
99 |
|
|
* Description : This routine is used to check the Main Voltage Regulator
|
100 |
|
|
* : NewState.
|
101 |
|
|
* Input : None
|
102 |
|
|
* Return : STABLE, UNSTABLE
|
103 |
|
|
*******************************************************************************/
|
104 |
|
|
inline PCU_VR_Status PCU_MVRStatus ( void )
|
105 |
|
|
{
|
106 |
|
|
return (PCU->PWRCR & PCU_VROK_Mask) == 0x00 ? PCU_UNSTABLE : PCU_STABLE;
|
107 |
|
|
}
|
108 |
|
|
|
109 |
|
|
/*******************************************************************************
|
110 |
|
|
* Function Name : PCU_FlagStatus
|
111 |
|
|
* Description : This routine is used to return the PCU register flag
|
112 |
|
|
* Input 1 : The flag to get
|
113 |
|
|
* Return : RESET, SET
|
114 |
|
|
*******************************************************************************/
|
115 |
|
|
inline FlagStatus PCU_FlagStatus ( PCU_Flags Xflag )
|
116 |
|
|
{
|
117 |
|
|
return ( PCU->PWRCR & Xflag ) == 0x00 ? RESET : SET;
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
/*******************************************************************************
|
121 |
|
|
* Function Name : PCU_VRConfig
|
122 |
|
|
* Description : This routine is used to configure PCU voltage regultors
|
123 |
|
|
* Input 1 : MVR : Main voltage Regulator
|
124 |
|
|
LPR : Low Power Regulator
|
125 |
|
|
* Input 2 : ENABLE : Enable the Voltage Regulator
|
126 |
|
|
DISABLE: Disable ( ByPass ) the VR
|
127 |
|
|
* Return : None
|
128 |
|
|
*******************************************************************************/
|
129 |
|
|
void PCU_VRConfig ( PCU_VR xVR, FunctionalState NewState );
|
130 |
|
|
|
131 |
|
|
/*******************************************************************************
|
132 |
|
|
* Function Name : PCU_VRStatus
|
133 |
|
|
* Description : This routine is used to get the PCU voltage regultors status
|
134 |
|
|
* Input : MVR : Main voltage Regulator
|
135 |
|
|
LPR : Low Power Regulator
|
136 |
|
|
* Return : ENABLE : Enable the Voltage Regulator
|
137 |
|
|
DISABLE: Disable ( ByPass ) the VR
|
138 |
|
|
*******************************************************************************/
|
139 |
|
|
inline FunctionalState PCU_VRStatus ( PCU_VR xVR )
|
140 |
|
|
{
|
141 |
|
|
return ( PCU->PWRCR & xVR ) == 0 ? ENABLE : DISABLE;
|
142 |
|
|
}
|
143 |
|
|
|
144 |
|
|
/*******************************************************************************
|
145 |
|
|
* Function Name : PCU_LVDDisable
|
146 |
|
|
* Description : This routine is used to disable the Low Voltage Detector.
|
147 |
|
|
* Input : None
|
148 |
|
|
* Return : None
|
149 |
|
|
*******************************************************************************/
|
150 |
|
|
inline void PCU_LVDDisable ( void )
|
151 |
|
|
{
|
152 |
|
|
PCU->PWRCR |= PCU_WREN_Mask; // Unlock Power Control Register
|
153 |
|
|
PCU->PWRCR |= PCU_LVD_Mask; // Set the LVD DIS Flag
|
154 |
|
|
}
|
155 |
|
|
|
156 |
|
|
/*******************************************************************************
|
157 |
|
|
* Function Name : PCU_LVDStatus
|
158 |
|
|
* Description : This routine is used to get the LVD NewState.
|
159 |
|
|
* Input : None
|
160 |
|
|
* Return : ENABLE, DISABLE
|
161 |
|
|
*******************************************************************************/
|
162 |
|
|
inline FunctionalState PCU_LVDStatus ( void )
|
163 |
|
|
{
|
164 |
|
|
return ( PCU->PWRCR & PCU_LVD_Mask ) == 0 ? ENABLE : DISABLE;
|
165 |
|
|
}
|
166 |
|
|
|
167 |
|
|
/*******************************************************************************
|
168 |
|
|
* Function Name : PCU_WFIEnter
|
169 |
|
|
* Description : This routine is used to force the Device to enter in WFI mode
|
170 |
|
|
* Input 1 : CLOCK2_16 : Clock2_16 as system clock for WFI mode
|
171 |
|
|
* EXTERNAL : external clock as system clock for WFI mode
|
172 |
|
|
* Input 2 : ENABLE : Enable Low Power Regulator during Wait For Interrupt Mode
|
173 |
|
|
* DISABLE: Disable Low Power Regulator during Wait For Interrupt Mode
|
174 |
|
|
* Input 3 : ENABLE : Enable Low Power Mode during Wait For Interrupt Mode
|
175 |
|
|
* DISABLE: Disable Low Power Mode during Wait For Interrupt Mode
|
176 |
|
|
* Return : None
|
177 |
|
|
*******************************************************************************/
|
178 |
|
|
void PCU_WFIEnter ( WFI_CLOCKS Xclock, FunctionalState Xlpr, FunctionalState Xlpm );
|
179 |
|
|
|
180 |
|
|
/*******************************************************************************
|
181 |
|
|
* Function Name : PCU_LPMEnter
|
182 |
|
|
* Description : This routine is used to force the Device to enter low
|
183 |
|
|
* power mode
|
184 |
|
|
* Input : SLOW : Slow Mode
|
185 |
|
|
STOP : Stop Mode
|
186 |
|
|
HALT : Halt Mode
|
187 |
|
|
* Return : None
|
188 |
|
|
*******************************************************************************/
|
189 |
|
|
void PCU_LPMEnter ( LPM_MODES Xmode);
|
190 |
|
|
|
191 |
|
|
#endif // __PCU_H
|
192 |
|
|
|
193 |
|
|
/******************* (C) COPYRIGHT 2003 STMicroelectronics *****END OF FILE****/
|