PowerControl
« Back to documentation index
Show/hide line numbers
PowerControl.h Source File
PowerControl.h
00001
00002
00003
00004
00005 #ifndef MBED_POWERCONTROL_H
00006 #define MBED_POWERCONTROL_H
00007
00008
00009 #include "LPC1768/LPC17xx.h"
00010
00011
00012
00013
00014 #define LPC1768_SCR_SLEEPONEXIT 0x2
00015
00016 #define LPC1768_SCR_SLEEPDEEP 0x4
00017
00018
00019 #define LPC1768_SCR_SEVONPEND 0x10
00020
00021
00022
00023
00024 #define LPC1768_PCON_PM0 0x1
00025
00026 #define LPC1768_PCON_PM1 0x2
00027
00028 #define LPC1768_PCON_BODRPM 0x4
00029
00030 #define LPC1768_PCON_BOGD 0x8
00031
00032 #define LPC1768_PCON_BORD 0x10
00033
00034
00035 #define LPC1768_PCON_SMFLAG 0x100
00036
00037 #define LPC1768_PCON_DSFLAG 0x200
00038
00039 #define LPC1768_PCON_PDFLAG 0x400
00040
00041 #define LPC1768_PCON_DPDFLAG 0x800
00042
00043
00044
00045 inline void Sleep(void)
00046 {
00047 __WFI();
00048 }
00049
00050
00051 inline void DeepSleep(void)
00052 {
00053 SCB->SCR |= LPC1768_SCR_SLEEPDEEP;
00054 __WFI();
00055 }
00056
00057
00058 inline void PowerDown(void)
00059 {
00060 SCB->SCR |= LPC1768_SCR_SLEEPDEEP;
00061 LPC_SC->PCON &= ~LPC1768_PCON_PM1;
00062 LPC_SC->PCON |= LPC1768_PCON_PM0;
00063 __WFI();
00064
00065 LPC_SC->PCON &= ~(LPC1768_PCON_PM1 | LPC1768_PCON_PM0);
00066 }
00067
00068
00069 inline void DeepPowerDown(void)
00070 {
00071 SCB->SCR |= LPC1768_SCR_SLEEPDEEP;
00072 LPC_SC->PCON |= LPC1768_PCON_PM1 | LPC1768_PCON_PM0;
00073 __WFI();
00074
00075 LPC_SC->PCON &= ~(LPC1768_PCON_PM1 | LPC1768_PCON_PM0);
00076 }
00077
00078
00079 inline void BrownOut_ReducedPowerMode_Enable(void)
00080 {
00081 LPC_SC->PCON |= LPC1768_PCON_BODRPM;
00082 }
00083
00084
00085 inline void BrownOut_ReducedPowerMode_Disable(void)
00086 {
00087 LPC_SC->PCON &= ~LPC1768_PCON_BODRPM;
00088 }
00089
00090
00091 inline void BrownOut_Global_Disable(void)
00092 {
00093 LPC_SC->PCON |= LPC1768_PCON_BOGD;
00094 }
00095
00096
00097 inline void BrownOut_Global_Enable(void)
00098 {
00099 LPC_SC->PCON &= !LPC1768_PCON_BOGD;
00100 }
00101
00102
00103 inline void BrownOut_Reset_Disable(void)
00104 {
00105 LPC_SC->PCON |= LPC1768_PCON_BORD;
00106 }
00107
00108
00109 inline void BrownOut_Reset_Enable(void)
00110 {
00111 LPC_SC->PCON &= ~LPC1768_PCON_BORD;
00112 }
00113
00114
00115
00116 #define LPC1768_PCONP_PCTIM0 0x2
00117
00118 #define LPC1768_PCONP_PCTIM1 0x4
00119
00120 #define LPC1768_PCONP_PCUART0 0x8
00121
00122 #define LPC1768_PCONP_PCUART1 0x10
00123
00124
00125 #define LPC1768_PCONP_PCPWM1 0x40
00126
00127 #define LPC1768_PCONP_PCI2C0 0x80
00128
00129 #define LPC1768_PCONP_PCSPI 0x100
00130
00131 #define LPC1768_PCONP_PCRTC 0x200
00132
00133 #define LPC1768_PCONP_PCSSP1 0x400
00134
00135
00136 #define LPC1768_PCONP_PCADC 0x1000
00137
00138 #define LPC1768_PCONP_PCCAN1 0x2000
00139
00140 #define LPC1768_PCONP_PCCAN2 0x4000
00141
00142 #define LPC1768_PCONP_PCGPIO 0x8000
00143
00144 #define LPC1768_PCONP_PCRIT 0x10000
00145
00146 #define LPC1768_PCONP_PCMCPWM 0x20000
00147
00148 #define LPC1768_PCONP_PCQEI 0x40000
00149
00150 #define LPC1768_PCONP_PCI2C1 0x80000
00151
00152
00153 #define LPC1768_PCONP_PCSSP0 0x200000
00154
00155 #define LPC1768_PCONP_PCTIM2 0x400000
00156
00157 #define LPC1768_PCONP_PCQTIM3 0x800000
00158
00159 #define LPC1768_PCONP_PCUART2 0x1000000
00160
00161 #define LPC1768_PCONP_PCUART3 0x2000000
00162
00163 #define LPC1768_PCONP_PCI2C2 0x4000000
00164
00165 #define LPC1768_PCONP_PCI2S 0x8000000
00166
00167
00168 #define LPC1768_PCONP_PCGPDMA 0x20000000
00169
00170 #define LPC1768_PCONP_PCENET 0x40000000
00171
00172 #define LPC1768_PCONP_PCUSB 0x80000000
00173
00174
00175 inline unsigned int Peripheral_PowerUp(unsigned int bitMask)
00176 {
00177 return LPC_SC->PCONP |= bitMask;
00178 }
00179
00180
00181 inline unsigned int Peripheral_PowerDown(unsigned int bitMask)
00182 {
00183 return LPC_SC->PCONP &= ~bitMask;
00184 }
00185
00186
00187 inline bool Peripheral_GetStatus(unsigned int peripheral)
00188 {
00189 return (LPC_SC->PCONP & peripheral) ? true : false;
00190 }
00191
00192 #endif