LPCOpen Platform for LPC112X microcontrollers  112X
LPCOpen Platform for the NXP LPC112X family of Microcontrollers
syscon_112x.c
Go to the documentation of this file.
1 /*
2  * @brief LPC11125 System Control functions
3  *
4  * Copyright(C) NXP Semiconductors, 2015
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 /* PDSLEEPCFG register mask */
36 #define PDSLEEPUSEMASK 0x000018FF
37 #define PDSLEEPMASKTMP (SYSCON_DEEPSLP_BOD_PD | SYSCON_DEEPSLP_WDTOSC_PD)
38 #define PDSLEEPMASK ((PDSLEEPUSEMASK) &~(PDSLEEPMASKTMP))
39 
40 /* PDWAKECFG register mask */
41 #define PDWAKEUPUSEMASK 0x0000ED00
42 #define PDWAKEUPMASKTMP 0x000000FF
43 
44 /* PDRUNCFG register mask */
45 #define PDRUNCFGUSEMASK 0x0000ED00
46 #define PDRUNCFGMASKTMP 0x000000FF
47 
48 /*****************************************************************************
49  * Public types/enumerations/variables
50  ****************************************************************************/
51 
52 /*****************************************************************************
53  * Private functions
54  ****************************************************************************/
55 
56 /*****************************************************************************
57  * Public functions
58  ****************************************************************************/
59 
60 /* Setup deep sleep behaviour for power down */
61 void Chip_SYSCON_SetDeepSleepPD(uint32_t sleepmask)
62 {
63  /* Update new value */
64  LPC_SYSCON->PDSLEEPCFG = PDSLEEPMASK | (sleepmask & PDSLEEPMASKTMP);
65 }
66 
67 /* Setup wakeup behaviour from deep sleep */
68 void Chip_SYSCON_SetWakeup(uint32_t wakeupmask)
69 {
70  /* Update new value */
71  LPC_SYSCON->PDWAKECFG = PDWAKEUPUSEMASK | (wakeupmask & PDWAKEUPMASKTMP);
72 }
73 
74 /* Power down one or more blocks or peripherals */
75 void Chip_SYSCON_PowerDown(uint32_t powerdownmask)
76 {
77  uint32_t pdrun;
78 
79  pdrun = LPC_SYSCON->PDRUNCFG & PDRUNCFGMASKTMP;
80  pdrun |= (powerdownmask & PDRUNCFGMASKTMP);
81 
82  LPC_SYSCON->PDRUNCFG = (pdrun | PDRUNCFGUSEMASK);
83 }
84 
85 /* Power up one or more blocks or peripherals */
86 void Chip_SYSCON_PowerUp(uint32_t powerupmask)
87 {
88  uint32_t pdrun;
89 
90  pdrun = LPC_SYSCON->PDRUNCFG & PDRUNCFGMASKTMP;
91  pdrun &= ~(powerupmask & PDRUNCFGMASKTMP);
92 
93  LPC_SYSCON->PDRUNCFG = (pdrun | PDRUNCFGUSEMASK);
94 }