LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
creg_18xx_43xx.h
Go to the documentation of this file.
1 /*
2  * @brief LPC18XX/43XX CREG 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 __CREG_18XX_43XX_H_
33 #define __CREG_18XX_43XX_H_
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
47 typedef struct {
49  __IO uint32_t CREG0;
50  __I uint32_t RESERVED1[62];
52 #if defined(CHIP_LPC18XX)
53  __I uint32_t RESERVED2[5];
54 #else
60 #endif
61  __IO uint32_t CREG5;
66  __IO uint32_t CREG6;
67 #if defined(CHIP_LPC18XX)
68  __I uint32_t RESERVED4[52];
69 #else
71  __I uint32_t RESERVED4[51];
72 #endif
74 #if defined(CHIP_LPC18XX)
75  __I uint32_t RESERVED5[191];
76 #else
77  __I uint32_t RESERVED5[127];
80  __I uint32_t RESERVED6[62];
81 #endif
83  __I uint32_t RESERVED7[63];
85 } LPC_CREG_T;
86 
92 {
93  return LPC_CREG->CHIPID != 0x3284E02B;
94 }
95 
105 {
106  uint32_t FAValue = Hz / 21510000;
107 
108  LPC_CREG->FLASHCFGA = (LPC_CREG->FLASHCFGA & (~(0xF << 12))) | (FAValue << 12);
109  LPC_CREG->FLASHCFGB = (LPC_CREG->FLASHCFGB & (~(0xF << 12))) | (FAValue << 12);
110 }
111 
120 {
121  if (Enable) {
122  LPC_CREG->CREG0 &= ~(1 << 5);
123  }
124  else {
125  LPC_CREG->CREG0 |= (1 << 5);
126  }
127 }
128 
136 {
137  LPC_CREG->CREG0 = (LPC_CREG->CREG0 & ~((3 << 8) | (3 << 10))) | (BODVL << 8) | (BORVL << 10);
138 }
139 
140 #if (defined(CHIP_LPC43XX) && defined(LPC_CREG))
141 
146 STATIC INLINE void Chip_CREG_SetM0AppMemMap(uint32_t memaddr)
147 {
148  LPC_CREG->M0APPMEMMAP = memaddr & ~0xFFF;
149 }
150 
155 STATIC INLINE void Chip_CREG_ClearM4Event(void)
156 {
157  LPC_CREG->M4TXEVENT = 0;
158 }
159 
164 STATIC INLINE void Chip_CREG_ClearM0Event(void)
165 {
166  LPC_CREG->M0TXEVENT = 0;
167 }
168 
169 #endif
170 
175 #ifdef __cplusplus
176 }
177 #endif
178 
179 #endif /* __CREG_18XX_43XX_H_ */