1 /**********************************************************************
2 * $Id$      lpc177x_8x_clkpwr.h         2011-06-02
3 *//**
4 * @file     lpc177x_8x_clkpwr.h
5 * @brief    Contains all macro definitions and function prototypes
6 *           support for Clock and Power Control firmware library on
7 *           LPC177x_8x
8 * @version  1.0
9 * @date     02. June. 2011
10 * @author   NXP MCU SW Application Team
11 *
12 * Copyright(C) 2011, NXP Semiconductor
13 * All rights reserved.
14 *
15 ***********************************************************************
16 * Software that is described herein is for illustrative purposes only
17 * which provides customers with programming information regarding the
18 * products. This software is supplied "AS IS" without any warranties.
19 * NXP Semiconductors assumes no responsibility or liability for the
20 * use of the software, conveys no license or title under any patent,
21 * copyright, or mask work right to the product. NXP Semiconductors
22 * reserves the right to make changes in the software without
23 * notification. NXP Semiconductors also make no representation or
24 * warranty that such application will be suitable for the specified
25 * use without further testing or modification.
26 **********************************************************************/
27 
28 /* Peripheral group ----------------------------------------------------------- */
29 /** @defgroup CLKPWR    Clock Power
30  * @ingroup LPC177x_8xCMSIS_FwLib_Drivers
31  * @{
32  */
33 
34 #ifndef __LPC177X_8X_CLKPWR_H_
35 #define __LPC177X_8X_CLKPWR_H_
36 
37 /* Includes ------------------------------------------------------------------- */
38 #include "LPC177x_8x.h"
39 #include "lpc_types.h"
40 #include "system_LPC177x_8x.h"
41 
42 #ifdef __cplusplus
43 extern "C"
44 {
45 #endif
46 
47 /* Public Macros -------------------------------------------------------------- */
48 /** @defgroup CLKPWR_Public_Macros CLKPWR Public Macros
49  * @{
50  */
51 
52 /********************************************************************
53 * Clock Source Selection Definitions
54 **********************************************************************/
55 #define CLKPWR_CLKSRCSEL_IRCOSC     ((uint32_t)(0))
56 #define CLKPWR_CLKSRCSEL_MAINOSC    ((uint32_t)(1))
57 
58 /********************************************************************
59 * Clock type/domain Definitions (calculated from input and pre-configuration
60 * parameter(s)
61 **********************************************************************/
62 #define CLKPWR_CLKTYPE_CPU          ((uint32_t)(0))
63 #define CLKPWR_CLKTYPE_PER          ((uint32_t)(1))
64 #define CLKPWR_CLKTYPE_EMC          ((uint32_t)(2))
65 #define CLKPWR_CLKTYPE_USB          ((uint32_t)(3))
66 
67 /********************************************************************
68 * Power Control for Peripherals Definitions
69 **********************************************************************/
70 /** LCD controller power/clock control bit */
71 #define CLKPWR_PCONP_PCLCD      ((uint32_t)(1<<0))
72 
73 /** Timer/Counter 0 power/clock control bit */
74 #define CLKPWR_PCONP_PCTIM0     ((uint32_t)(1<<1))
75 
76 /* Timer/Counter 1 power/clock control bit */
77 #define CLKPWR_PCONP_PCTIM1     ((uint32_t)(1<<2))
78 
79 /** UART0 power/clock control bit */
80 #define CLKPWR_PCONP_PCUART0    ((uint32_t)(1<<3))
81 
82 /** UART1 power/clock control bit */
83 #define CLKPWR_PCONP_PCUART1    ((uint32_t)(1<<4))
84 
85 /** PWM0 power/clock control bit */
86 #define CLKPWR_PCONP_PCPWM0     ((uint32_t)(1<<5))
87 
88 /** PWM1 power/clock control bit */
89 #define CLKPWR_PCONP_PCPWM1     ((uint32_t)(1<<6))
90 
91 /** The I2C0 interface power/clock control bit */
92 #define CLKPWR_PCONP_PCI2C0     ((uint32_t)(1<<7))
93 
94 /** UART4 power/clock control bit */
95 #define CLKPWR_PCONP_PCUART4    ((uint32_t)(1<<8))
96 
97 /** The RTC power/clock control bit */
98 #define CLKPWR_PCONP_PCRTC      ((uint32_t)(1<<9))
99 
100 /** The SSP1 interface power/clock control bit */
101 #define CLKPWR_PCONP_PCSSP1     ((uint32_t)(1<<10))
102 
103 /** External Memory controller power/clock control bit */
104 #define CLKPWR_PCONP_PCEMC      ((uint32_t)(1<<11))
105 
106 /** A/D converter 0 (ADC0) power/clock control bit */
107 #define CLKPWR_PCONP_PCADC      ((uint32_t)(1<<12))
108 
109 /** CAN Controller 1 power/clock control bit */
110 #define CLKPWR_PCONP_PCAN1      ((uint32_t)(1<<13))
111 
112 /** CAN Controller 2 power/clock control bit */
113 #define CLKPWR_PCONP_PCAN2  ((uint32_t)(1<<14))
114 
115 /** GPIO power/clock control bit */
116 #define CLKPWR_PCONP_PCGPIO     ((uint32_t)(1<<15))
117 
118 /** Motor Control PWM */
119 #define CLKPWR_PCONP_PCMCPWM    ((uint32_t)(1<<17))
120 
121 /** Quadrature Encoder Interface power/clock control bit */
122 #define CLKPWR_PCONP_PCQEI      ((uint32_t)(1<<18))
123 
124 /** The I2C1 interface power/clock control bit */
125 #define CLKPWR_PCONP_PCI2C1     ((uint32_t)(1<<19))
126 
127 /** The SSP2 interface power/clock control bit */
128 #define CLKPWR_PCONP_PCSSP2     ((uint32_t)(1<<20))
129 
130 /** The SSP0 interface power/clock control bit */
131 #define CLKPWR_PCONP_PCSSP0     ((uint32_t)(1<<21))
132 
133 /** Timer 2 power/clock control bit */
134 #define CLKPWR_PCONP_PCTIM2 ((uint32_t)(1<<22))
135 
136 /** Timer 3 power/clock control bit */
137 #define CLKPWR_PCONP_PCTIM3 ((uint32_t)(1<<23))
138 
139 /** UART 2 power/clock control bit */
140 #define CLKPWR_PCONP_PCUART2    ((uint32_t)(1<<24))
141 
142 /** UART 3 power/clock control bit */
143 #define CLKPWR_PCONP_PCUART3    ((uint32_t)(1<<25))
144 
145 /** I2C interface 2 power/clock control bit */
146 #define CLKPWR_PCONP_PCI2C2 ((uint32_t)(1<<26))
147 
148 /** I2S interface power/clock control bit*/
149 #define CLKPWR_PCONP_PCI2S      ((uint32_t)(1<<27))
150 
151 /** SD card interface power/clock control bit */
152 #define CLKPWR_PCONP_PCSDC      ((uint32_t)(1<<28))
153 
154 /** GP DMA function power/clock control bit*/
155 #define  CLKPWR_PCONP_PCGPDMA   ((uint32_t)(1<<29))
156 
157 /** Ethernet block power/clock control bit*/
158 #define  CLKPWR_PCONP_PCENET    ((uint32_t)(1<<30))
159 
160 /** USB interface power/clock control bit*/
161 #define  CLKPWR_PCONP_PCUSB     ((uint32_t)(1<<31))
162 
163 /********************************************************************
164 * Power Control for Peripherals Definitions
165 **********************************************************************/
166 #define CLKPWR_RSTCON0_LCD      ((uint32_t)(0))
167 #define CLKPWR_RSTCON0_TIM0     ((uint32_t)(1))
168 #define CLKPWR_RSTCON0_TIM1     ((uint32_t)(2))
169 #define CLKPWR_RSTCON0_UART0    ((uint32_t)(3))
170 #define CLKPWR_RSTCON0_UART1    ((uint32_t)(4))
171 #define CLKPWR_RSTCON0_PWM0     ((uint32_t)(5))
172 #define CLKPWR_RSTCON0_PWM1     ((uint32_t)(6))
173 #define CLKPWR_RSTCON0_I2C0     ((uint32_t)(7))
174 #define CLKPWR_RSTCON0_UART4    ((uint32_t)(8))
175 #define CLKPWR_RSTCON0_RTC      ((uint32_t)(9))
176 #define CLKPWR_RSTCON0_SSP1     ((uint32_t)(10))
177 #define CLKPWR_RSTCON0_EMC      ((uint32_t)(11))
178 #define CLKPWR_RSTCON0_ADC      ((uint32_t)(12))
179 #define CLKPWR_RSTCON0_CAN1     ((uint32_t)(13))
180 #define CLKPWR_RSTCON0_CAN2     ((uint32_t)(14))
181 #define CLKPWR_RSTCON0_GPIO     ((uint32_t)(15))
182 #define CLKPWR_RSTCON0_MCPWM    ((uint32_t)(17))
183 #define CLKPWR_RSTCON0_QEI      ((uint32_t)(18))
184 #define CLKPWR_RSTCON0_I2C1     ((uint32_t)(19))
185 #define CLKPWR_RSTCON0_SSP2     ((uint32_t)(20))
186 #define CLKPWR_RSTCON0_SSP0     ((uint32_t)(21))
187 #define CLKPWR_RSTCON0_TIM2     ((uint32_t)(22))
188 #define CLKPWR_RSTCON0_TIM3     ((uint32_t)(23))
189 #define CLKPWR_RSTCON0_UART2    ((uint32_t)(24))
190 #define CLKPWR_RSTCON0_UART3    ((uint32_t)(25))
191 #define CLKPWR_RSTCON0_I2C2     ((uint32_t)(26))
192 #define CLKPWR_RSTCON0_I2S      ((uint32_t)(27))
193 #define CLKPWR_RSTCON0_SDC      ((uint32_t)(28))
194 #define CLKPWR_RSTCON0_GPDMA    ((uint32_t)(29))
195 #define CLKPWR_RSTCON0_ENET     ((uint32_t)(30))
196 #define CLKPWR_RSTCON0_USB      ((uint32_t)(31))
197 
198 #define CLKPWR_RSTCON1_IOCON    ((uint32_t)(32))
199 #define CLKPWR_RSTCON1_DAC      ((uint32_t)(33))
200 #define CLKPWR_RSTCON1_CANACC   ((uint32_t)(34))
201 /**
202  * @}
203  */
204 
205 /* External clock variable from system_LPC177x_8x.h */
206 extern uint32_t SystemCoreClock;     /*!< System Clock Frequency (Core Clock)   */
207 extern uint32_t PeripheralClock;     /*!< Peripheral Clock Frequency (Pclk)     */
208 extern uint32_t EMCClock;        /*!< EMC Clock Frequency                       */
209 
210 /* External clock variable from lpc177x_8x_clkpwr.h */
211 extern uint32_t USBClock;       /*!< USB Frequency                              */
212 
213 /* Public Functions ----------------------------------------------------------- */
214 /** @defgroup CLKPWR_Public_Functions CLKPWR Public Functions
215  * @{
216  */
217 
218 void CLKPWR_SetCLKDiv(uint8_t ClkType, uint8_t DivVal);
219 uint32_t CLKPWR_GetCLK(uint8_t ClkType);
220 void CLKPWR_ConfigPPWR(uint32_t PPType, FunctionalState NewState);
221 void CLKPWR_ConfigReset(uint8_t PType, FunctionalState NewState);
222 void CLKPWR_Sleep(void);
223 void CLKPWR_DeepSleep(void);
224 void CLKPWR_PowerDown(void);
225 void CLKPWR_DeepPowerDown(void);
226 
227 /**
228  * @}
229  */
230 
231 
232 #ifdef __cplusplus
233 }
234 #endif
235 
236 #endif /* __LPC177X_8X_CLKPWR_H_ */
237 
238 /**
239  * @}
240  */
241 
242 /* --------------------------------- End Of File ------------------------------ */
243