LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sysctl_11xx.c
Go to the documentation of this file.
1 /*
2  * @brief LPC11XX System Control functions
3  *
4  * Copyright(C) NXP Semiconductors, 2012
5  * All rights reserved.
6  *
7  * Software that is described herein is for illustrative purposes only
8  * which provides customers with programming information regarding the
9  * LPC products. This software is supplied "AS IS" without any warranties of
10  * any kind, and NXP Semiconductors and its licensor disclaim any and
11  * all warranties, express or implied, including all implied warranties of
12  * merchantability, fitness for a particular purpose and non-infringement of
13  * intellectual property rights. NXP Semiconductors assumes no responsibility
14  * or liability for the use of the software, conveys no license or rights under any
15  * patent, copyright, mask work right, or any other intellectual property rights in
16  * or to any products. NXP Semiconductors reserves the right to make changes
17  * in the software without notification. NXP Semiconductors also makes no
18  * representation or warranty that such application will be suitable for the
19  * specified use without further testing or modification.
20  *
21  * Permission to use, copy, modify, and distribute this software and its
22  * documentation is hereby granted, under NXP Semiconductors' and its
23  * licensor's relevant copyrights in the software, without fee, provided that it
24  * is used in conjunction with NXP Semiconductors microcontrollers. This
25  * copyright, permission, and disclaimer notice must appear in all copies of
26  * this code.
27  */
28 
29 #include "chip.h"
30 
31 /*****************************************************************************
32  * Private types/enumerations/variables
33  ****************************************************************************/
34 
35 #if !defined(LPC11AXX)
36 /* PDSLEEPCFG register mask */
37 #define PDSLEEPUSEMASK 0x000018FF
38 #if defined(CHIP_LPC11XXLV)
39 #define PDSLEEPMASKTMP (SYSCTL_DEEPSLP_BOD_PD | SYSCTL_DEEPSLP_WDTOSC_PD | \
40  SYSCTL_DEEPSLP_IRCOUT_PD | SYSCTL_DEEPSLP_IRC_PD)
41 #else
42 #define PDSLEEPMASKTMP (SYSCTL_DEEPSLP_BOD_PD | SYSCTL_DEEPSLP_WDTOSC_PD)
43 #endif
44 #define PDSLEEPMASK ((PDSLEEPUSEMASK) &~(PDSLEEPMASKTMP))
45 
46 /* PDWAKECFG register mask */
47 #if defined(CHIP_LPC11UXX)
48 #define PDWAKEUPUSEMASK 0x0000E800
49 #define PDWAKEUPMASKTMP 0x000000FF
50 #else
51 #define PDWAKEUPUSEMASK 0x0000ED00
52 #define PDWAKEUPMASKTMP 0x000005FF
53 #endif
54 #endif /* !defined(LPC11AXX) */
55 
56 /* PDRUNCFG register mask */
57 #if defined(CHIP_LPC11AXX)
58 #define PDRUNCFGUSEMASK 0x00000D08
59 #define PDRUNCFGMASKTMP 0x0001E0F7
60 #elif defined(CHIP_LPC11UXX)
61 #define PDRUNCFGUSEMASK 0x0000E800
62 #define PDRUNCFGMASKTMP 0x000005FF
63 #else
64 #define PDRUNCFGUSEMASK 0x0000ED00
65 #define PDRUNCFGMASKTMP 0x000000FF
66 #endif
67 
68 /*****************************************************************************
69  * Public types/enumerations/variables
70  ****************************************************************************/
71 
72 /*****************************************************************************
73  * Private functions
74  ****************************************************************************/
75 
76 /*****************************************************************************
77  * Public functions
78  ****************************************************************************/
79 
80 #if !defined(LPC11AXX)
81 /* Setup deep sleep behaviour for power down */
83 {
84  /* Update new value */
85  LPC_SYSCTL->PDSLEEPCFG = PDSLEEPMASK | (sleepmask & PDSLEEPMASKTMP);
86 }
87 
88 /* Setup wakeup behaviour from deep sleep */
90 {
91  /* Update new value */
92  LPC_SYSCTL->PDWAKECFG = PDWAKEUPUSEMASK | (wakeupmask & PDWAKEUPMASKTMP);
93 }
94 
95 #endif
96 
97 /* Power down one or more blocks or peripherals */
98 void Chip_SYSCTL_PowerDown(uint32_t powerdownmask)
99 {
100  uint32_t pdrun;
101 
102  pdrun = LPC_SYSCTL->PDRUNCFG & PDRUNCFGMASKTMP;
103  pdrun |= (powerdownmask & PDRUNCFGMASKTMP);
104 
105  LPC_SYSCTL->PDRUNCFG = (pdrun | PDRUNCFGUSEMASK);
106 }
107 
108 /* Power up one or more blocks or peripherals */
109 void Chip_SYSCTL_PowerUp(uint32_t powerupmask)
110 {
111  uint32_t pdrun;
112 
113  pdrun = LPC_SYSCTL->PDRUNCFG & PDRUNCFGMASKTMP;
114  pdrun &= ~(powerupmask & PDRUNCFGMASKTMP);
115 
116  LPC_SYSCTL->PDRUNCFG = (pdrun | PDRUNCFGUSEMASK);
117 }