clock_11xx.h
Go to the documentation of this file.
1 /*
2  * @brief LPC11XX Clock control functions
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 licensor 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_11XX_H_
33 #define __CLOCK_11XX_H_
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
45 #define SYSCTL_IRC_FREQ (12000000)
46 
55 {
56  LPC_SYSCTL->SYSPLLCTRL = (msel & 0x1F) | ((psel & 0x3) << 5);
57 }
58 
64 {
65  return (bool) ((LPC_SYSCTL->SYSPLLSTAT & 1) != 0);
66 }
67 
71 typedef enum CHIP_SYSCTL_PLLCLKSRC {
74 #if defined(CHIP_LPC11AXX)
75  SYSCTL_PLLCLKSRC_EXT_CLKIN,
76 #else
78 #endif
81 
89 void Chip_Clock_SetSystemPLLSource(CHIP_SYSCTL_PLLCLKSRC_T src);
90 
91 #if defined(CHIP_LPC11UXX)
92 
99 STATIC INLINE void Chip_Clock_SetupUSBPLL(uint8_t msel, uint8_t psel)
100 {
101  LPC_SYSCTL->USBPLLCTRL = (msel & 0x1F) | ((psel & 0x3) << 5);
102 }
103 
108 STATIC INLINE bool Chip_Clock_IsUSBPLLLocked(void)
109 {
110  return (bool) ((LPC_SYSCTL->USBPLLSTAT & 1) != 0);
111 }
112 
120 void Chip_Clock_SetUSBPLLSource(CHIP_SYSCTL_PLLCLKSRC_T src);
121 
122 #endif /*defined(CHIP_LPC11UXX)*/
123 
133 void Chip_Clock_SetPLLBypass(bool bypass, bool highfr);
134 
138 typedef enum CHIP_WDTLFO_OSC {
156 
164 STATIC INLINE void Chip_Clock_SetWDTOSC(CHIP_WDTLFO_OSC_T wdtclk, uint8_t div)
165 {
166  LPC_SYSCTL->WDTOSCCTRL = (((uint32_t) wdtclk) << 5) | ((div >> 1) - 1);
167 }
168 
169 #if defined(CHIP_LPC11AXX)
170 
177 STATIC INLINE void Chip_Clock_SetLFOSC(CHIP_WDTLFO_OSC_T lfoclk, uint8_t div)
178 {
179  LPC_SYSCTL->LFOSCCTRL = (((uint32_t) lfoclk) << 5) | ((div >> 1) - 1);
180 }
181 
182 #endif /*CHIP_LPC11AXX*/
183 
194 
202 void Chip_Clock_SetMainClockSource(CHIP_SYSCTL_MAINCLKSRC_T src);
203 
208 STATIC INLINE CHIP_SYSCTL_MAINCLKSRC_T Chip_Clock_GetMainClockSource(void)
209 {
210  return (CHIP_SYSCTL_MAINCLKSRC_T) (LPC_SYSCTL->MAINCLKSEL);
211 }
212 
221 {
222  LPC_SYSCTL->SYSAHBCLKDIV = div;
223 }
224 
228 typedef enum CHIP_SYSCTL_CLOCK {
234 #if defined(CHIP_LPC110X)
235  SYSCTL_CLOCK_RESERVED5,
236 #else
238 #endif
247 #if defined(CHIP_LPC11UXX)
248  SYSCTL_CLOCK_USB,
249 #else
251 #endif
254 #if defined(CHIP_LPC11CXX)
255  SYSCTL_CLOCK_CAN,
256 #else
258 #endif
259 #if !(defined(CHIP_LPC110X) || defined(CHIP_LPC11XXLV))
261 #if !defined(CHIP_LPC11CXX)
263 #if defined(CHIP_LPC11AXX)
264  SYSCTL_CLOCK_ACOMP,
265  SYSCTL_CLOCK_DAC,
266 #else
269 #endif
276 #if defined(CHIP_LPC11EXX) || defined(CHIP_LPC11UXX)
277  SYSCTL_CLOCK_RAM1,
278 #else
280 #endif
281 #if defined(CHIP_LPC11UXX)
282  SYSCTL_CLOCK_USBRAM,
283 #else
285 #endif
286 #endif /* !defined(CHIP_LPC11CXX) */
287 #endif /* !(defined(CHIP_LPC110X) || defined(CHIP_LPC11XXLV)) */
289 
295 STATIC INLINE void Chip_Clock_EnablePeriphClock(CHIP_SYSCTL_CLOCK_T clk)
296 {
297  LPC_SYSCTL->SYSAHBCLKCTRL |= (1 << clk);
298 }
299 
305 STATIC INLINE void Chip_Clock_DisablePeriphClock(CHIP_SYSCTL_CLOCK_T clk)
306 {
307  LPC_SYSCTL->SYSAHBCLKCTRL &= ~(1 << clk);
308 }
309 
318 {
319  LPC_SYSCTL->SSP0CLKDIV = div;
320 }
321 
328 {
329  return LPC_SYSCTL->SSP0CLKDIV;
330 }
331 
340 {
341  LPC_SYSCTL->USARTCLKDIV = div;
342 }
343 
350 {
351  return LPC_SYSCTL->USARTCLKDIV;
352 }
353 
354 #if defined(CHIP_LPC11CXX) || defined(CHIP_LPC11EXX) || defined(CHIP_LPC11AXX) || defined(CHIP_LPC11UXX) || defined(CHIP_LPC1125)
355 
362 STATIC INLINE void Chip_Clock_SetSSP1ClockDiv(uint32_t div)
363 {
364  LPC_SYSCTL->SSP1CLKDIV = div;
365 }
366 
372 STATIC INLINE uint32_t Chip_Clock_GetSSP1ClockDiv(void)
373 {
374  return LPC_SYSCTL->SSP1CLKDIV;
375 }
376 
377 #endif /*defined(CHIP_LPC11CXX) || defined(CHIP_LPC11EXX) || defined(CHIP_LPC11AXX) || defined(CHIP_LPC11UXX)*/
378 
379 #if defined(CHIP_LPC11UXX)
380 
383 typedef enum CHIP_SYSCTL_USBCLKSRC {
384  SYSCTL_USBCLKSRC_PLLOUT = 0,
385  SYSCTL_USBCLKSRC_MAINSYSCLK,
386 } CHIP_SYSCTL_USBCLKSRC_T;
387 
398 void Chip_Clock_SetUSBClockSource(CHIP_SYSCTL_USBCLKSRC_T src, uint32_t div);
399 
400 #endif /*CHIP_LPC11UXX*/
401 
402 #if defined(CHIP_LPC110X) || defined(CHIP_LPC11XXLV) || defined(CHIP_LPC11CXX) || defined(CHIP_LPC11EXX) || defined(CHIP_LPC1125)
403 
406 typedef enum CHIP_SYSCTL_WDTCLKSRC {
407  SYSCTL_WDTCLKSRC_IRC = 0,
408  SYSCTL_WDTCLKSRC_MAINSYSCLK,
409  SYSCTL_WDTCLKSRC_WDTOSC,
410 } CHIP_SYSCTL_WDTCLKSRC_T;
411 
422 void Chip_Clock_SetWDTClockSource(CHIP_SYSCTL_WDTCLKSRC_T src, uint32_t div);
423 
424 #endif
425 
426 #if !defined(CHIP_LPC110X)
427 
430 typedef enum CHIP_SYSCTL_CLKOUTSRC {
437 
448 void Chip_Clock_SetCLKOUTSource(CHIP_SYSCTL_CLKOUTSRC_T src, uint32_t div);
449 
450 #endif
451 
457 {
458  return OscRateIn;
459 }
460 
466 {
467  return SYSCTL_IRC_FREQ;
468 }
469 
470 #if defined(CHIP_LPC11AXX)
471 
476 STATIC INLINE uint32_t Chip_Clock_GetExtClockInRate(void)
477 {
478  return ExtRateIn;
479 }
480 
481 #endif
482 
489 
490 #if defined(CHIP_LPC11AXX)
491 
496 uint32_t Chip_Clock_GetLFOOSCRate(void);
497 
498 #endif
499 
505 
511 
512 #if defined(CHIP_LPC11UXX)
513 
517 uint32_t Chip_Clock_GetUSBPLLInClockRate(void);
518 
523 uint32_t Chip_Clock_GetUSBPLLOutClockRate(void);
524 
525 #endif
526 
532 
538 
543 #ifdef __cplusplus
544 }
545 #endif
546 
547 #endif /* __CLOCK_11XX_H_ */
std::uint8_t uint8_t
Definition: std.hpp:24
CHIP_SYSCTL_CLOCK
Definition: clock_11xx.h:228
#define STATIC
Definition: lpc_types.h:140
void Chip_Clock_SetPLLBypass(bool bypass, bool highfr)
Bypass System Oscillator and set oscillator frequency range.
Definition: clock_11xx.c:98
const uint32_t OscRateIn
System oscillator rate This value is defined externally to the chip layer and contains the value in H...
Definition: board.cpp:15
enum CHIP_SYSCTL_CLKOUTSRC CHIP_SYSCTL_CLKOUTSRC_T
STATIC INLINE void Chip_Clock_SetSSP0ClockDiv(uint32_t div)
Set SSP0 divider.
Definition: clock_11xx.h:317
enum CHIP_SYSCTL_MAINCLKSRC CHIP_SYSCTL_MAINCLKSRC_T
void Chip_Clock_SetSystemPLLSource(CHIP_SYSCTL_PLLCLKSRC_T src)
Set System PLL clock source.
Definition: clock_11xx.c:90
STATIC INLINE uint32_t Chip_Clock_GetUARTClockDiv(void)
Return UART divider.
Definition: clock_11xx.h:349
STATIC INLINE void Chip_Clock_SetWDTOSC(CHIP_WDTLFO_OSC_T wdtclk, uint8_t div)
Setup Watchdog oscillator rate and divider.
Definition: clock_11xx.h:164
STATIC INLINE uint32_t Chip_Clock_GetSSP0ClockDiv(void)
Return SSP0 divider.
Definition: clock_11xx.h:327
uint32_t Chip_Clock_GetWDTOSCRate(void)
Return estimated watchdog oscillator rate.
Definition: clock_11xx.c:168
STATIC INLINE bool Chip_Clock_IsSystemPLLLocked(void)
Read System PLL lock status.
Definition: clock_11xx.h:63
enum CHIP_SYSCTL_CLOCK CHIP_SYSCTL_CLOCK_T
uint32_t Chip_Clock_GetMainClockRate(void)
Return main clock rate.
Definition: clock_11xx.c:248
STATIC INLINE CHIP_SYSCTL_MAINCLKSRC_T Chip_Clock_GetMainClockSource(void)
Returns the main clock source.
Definition: clock_11xx.h:208
enum CHIP_WDTLFO_OSC CHIP_WDTLFO_OSC_T
std::uint32_t uint32_t
Definition: std.hpp:26
uint32_t Chip_Clock_GetSystemPLLInClockRate(void)
Return System PLL input clock rate.
Definition: clock_11xx.c:183
enum CHIP_SYSCTL_PLLCLKSRC CHIP_SYSCTL_PLLCLKSRC_T
CHIP_SYSCTL_PLLCLKSRC
Definition: clock_11xx.h:71
CHIP_WDTLFO_OSC
Definition: clock_11xx.h:138
STATIC INLINE void Chip_Clock_SetSysClockDiv(uint32_t div)
Set system clock divider.
Definition: clock_11xx.h:220
#define INLINE
Definition: lpc_types.h:205
STATIC INLINE void Chip_Clock_SetUARTClockDiv(uint32_t div)
Set UART divider clock.
Definition: clock_11xx.h:339
uint32_t Chip_Clock_GetSystemClockRate(void)
Return system clock rate.
Definition: clock_11xx.c:281
STATIC INLINE uint32_t Chip_Clock_GetMainOscRate(void)
Returns the main oscillator clock rate.
Definition: clock_11xx.h:456
STATIC INLINE void Chip_Clock_DisablePeriphClock(CHIP_SYSCTL_CLOCK_T clk)
Disable a system or peripheral clock.
Definition: clock_11xx.h:305
#define LPC_SYSCTL
Definition: chip.h:181
CHIP_SYSCTL_CLKOUTSRC
Definition: clock_11xx.h:430
STATIC INLINE void Chip_Clock_EnablePeriphClock(CHIP_SYSCTL_CLOCK_T clk)
Enable a system or peripheral clock.
Definition: clock_11xx.h:295
#define SYSCTL_IRC_FREQ
Definition: clock_11xx.h:45
void Chip_Clock_SetMainClockSource(CHIP_SYSCTL_MAINCLKSRC_T src)
Set main system clock source.
Definition: clock_11xx.c:124
STATIC INLINE uint32_t Chip_Clock_GetIntOscRate(void)
Returns the internal oscillator (IRC) clock rate.
Definition: clock_11xx.h:465
void Chip_Clock_SetCLKOUTSource(CHIP_SYSCTL_CLKOUTSRC_T src, uint32_t div)
Set CLKOUT clock source and divider.
Definition: clock_11xx.c:157
CHIP_SYSCTL_MAINCLKSRC
Definition: clock_11xx.h:187
const uint32_t ExtRateIn
Clock rate on the CLKIN pin This value is defined externally to the chip layer and contains the value...
Definition: board.cpp:16
STATIC INLINE void Chip_Clock_SetupSystemPLL(uint8_t msel, uint8_t psel)
Set System PLL divider values.
Definition: clock_11xx.h:54
uint32_t Chip_Clock_GetSystemPLLOutClockRate(void)
Return System PLL output clock rate.
Definition: clock_11xx.c:210


uavcan_communicator
Author(s):
autogenerated on Wed Jan 11 2023 03:59:39