LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
clock_8xx.h
Go to the documentation of this file.
1 /*
2  * @brief LPC8xx clock driver
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2012
6  * All rights reserved.
7  *
8  * @par
9  * Software that is described herein is for illustrative purposes only
10  * which provides customers with programming information regarding the
11  * LPC products. This software is supplied "AS IS" without any warranties of
12  * any kind, and NXP Semiconductors and its licenser disclaim any and
13  * all warranties, express or implied, including all implied warranties of
14  * merchantability, fitness for a particular purpose and non-infringement of
15  * intellectual property rights. NXP Semiconductors assumes no responsibility
16  * or liability for the use of the software, conveys no license or rights under any
17  * patent, copyright, mask work right, or any other intellectual property rights in
18  * or to any products. NXP Semiconductors reserves the right to make changes
19  * in the software without notification. NXP Semiconductors also makes no
20  * representation or warranty that such application will be suitable for the
21  * specified use without further testing or modification.
22  *
23  * @par
24  * Permission to use, copy, modify, and distribute this software and its
25  * documentation is hereby granted, under NXP Semiconductors' and its
26  * licensor's relevant copyrights in the software, without fee, provided that it
27  * is used in conjunction with NXP Semiconductors microcontrollers. This
28  * copyright, permission, and disclaimer notice must appear in all copies of
29  * this code.
30  */
31 
32 #ifndef __CLOCK_8XX_H_
33 #define __CLOCK_8XX_H_
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
61 /* Internal oscillator frequency */
62 #define SYSCTL_IRC_FREQ (12000000)
63 
67 typedef enum CHIP_SYSCTL_PLLCLKSRC {
73 
78 typedef enum CHIP_WDTLFO_OSC {
96 
100 typedef enum CHIP_SYSCTL_MAINCLKSRC{
106 
110 typedef enum CHIP_SYSCTL_CLOCK{
132 
136 typedef enum CHIP_SYSCTL_CLKOUTSRC{
142 
150 STATIC INLINE void Chip_Clock_SetupSystemPLL(uint8_t msel, uint8_t psel)
151 {
152  LPC_SYSCTL->SYSPLLCTRL = (msel & 0x1F) | ((psel & 0x3) << 5);
153 }
154 
160 {
161  return (bool) ((LPC_SYSCTL->SYSPLLSTAT & 1) != 0);
162 }
163 
172 {
173  LPC_SYSCTL->WDTOSCCTRL = (((uint32_t) wdtclk) << 5) | ((div >> 1) - 1);
174 }
175 
181 {
182  return (CHIP_SYSCTL_MAINCLKSRC_T) (LPC_SYSCTL->MAINCLKSEL);
183 }
184 
193 {
194  LPC_SYSCTL->SYSAHBCLKDIV = div;
195 }
196 
203 {
204  LPC_SYSCTL->SYSAHBCLKCTRL |= (1 << clk);
205 }
206 
213 {
214  LPC_SYSCTL->SYSAHBCLKCTRL &= ~(1 << clk);
215 }
216 
225 {
226  LPC_SYSCTL->UARTCLKDIV = div;
227 }
228 
235 {
236  return LPC_SYSCTL->UARTCLKDIV;
237 }
238 
244 {
245  return CRYSTAL_MAIN_FREQ_IN;
246 }
247 
253 {
254  return SYSCTL_IRC_FREQ;
255 }
256 
262 {
263  return EXTCLKIN_FREQ_IN;
264 }
265 
274 
284 void Chip_Clock_SetPLLBypass(bool bypass, bool highfr);
285 
294 
306 
313 
319 
325 
331 
337 
342 #ifdef __cplusplus
343 }
344 #endif
345 
346 #endif /* __CLOCK_8XX_H_ */