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