2 * @brief LPC18XX/43XX CREG control functions
\r
5 * Copyright(C) NXP Semiconductors, 2012
\r
6 * All rights reserved.
\r
9 * Software that is described herein is for illustrative purposes only
\r
10 * which provides customers with programming information regarding the
\r
11 * LPC products. This software is supplied "AS IS" without any warranties of
\r
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
\r
13 * all warranties, express or implied, including all implied warranties of
\r
14 * merchantability, fitness for a particular purpose and non-infringement of
\r
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
\r
16 * or liability for the use of the software, conveys no license or rights under any
\r
17 * patent, copyright, mask work right, or any other intellectual property rights in
\r
18 * or to any products. NXP Semiconductors reserves the right to make changes
\r
19 * in the software without notification. NXP Semiconductors also makes no
\r
20 * representation or warranty that such application will be suitable for the
\r
21 * specified use without further testing or modification.
\r
24 * Permission to use, copy, modify, and distribute this software and its
\r
25 * documentation is hereby granted, under NXP Semiconductors' and its
\r
26 * licensor's relevant copyrights in the software, without fee, provided that it
\r
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
\r
28 * copyright, permission, and disclaimer notice must appear in all copies of
\r
32 #ifndef __CREG_18XX_43XX_H_
\r
33 #define __CREG_18XX_43XX_H_
\r
39 /** @defgroup CREG_18XX_43XX CHIP: LPC18xx/43xx CREG driver
\r
40 * @ingroup CHIP_18XX_43XX_Drivers
\r
45 * @brief CREG Register Block
\r
47 typedef struct { /*!< CREG Structure */
\r
48 __I uint32_t RESERVED0;
\r
49 __IO uint32_t CREG0; /*!< Chip configuration register 32 kHz oscillator output and BOD control register. */
\r
50 __I uint32_t RESERVED1[62];
\r
51 __IO uint32_t MXMEMMAP; /*!< ARM Cortex-M3/M4 memory mapping */
\r
52 #if defined(CHIP_LPC18XX)
\r
53 __I uint32_t RESERVED2[5];
\r
55 __I uint32_t RESERVED2;
\r
56 __I uint32_t CREG1; /*!< Configuration Register 1 */
\r
57 __I uint32_t CREG2; /*!< Configuration Register 2 */
\r
58 __I uint32_t CREG3; /*!< Configuration Register 3 */
\r
59 __I uint32_t CREG4; /*!< Configuration Register 4 */
\r
61 __IO uint32_t CREG5; /*!< Chip configuration register 5. Controls JTAG access. */
\r
62 __IO uint32_t DMAMUX; /*!< DMA muxing control */
\r
63 __IO uint32_t FLASHCFGA; /*!< Flash accelerator configuration register for flash bank A */
\r
64 __IO uint32_t FLASHCFGB; /*!< Flash accelerator configuration register for flash bank B */
\r
65 __IO uint32_t ETBCFG; /*!< ETB RAM configuration */
\r
66 __IO uint32_t CREG6; /*!< Chip configuration register 6. */
\r
67 #if defined(CHIP_LPC18XX)
\r
68 __I uint32_t RESERVED4[52];
\r
70 __IO uint32_t M4TXEVENT; /*!< M4 IPC event register */
\r
71 __I uint32_t RESERVED4[51];
\r
73 __I uint32_t CHIPID; /*!< Part ID */
\r
74 #if defined(CHIP_LPC18XX)
\r
75 __I uint32_t RESERVED5[191];
\r
77 __I uint32_t RESERVED5[127];
\r
78 __IO uint32_t M0TXEVENT; /*!< M0 IPC Event register */
\r
79 __IO uint32_t M0APPMEMMAP; /*!< ARM Cortex M0 memory mapping */
\r
80 __I uint32_t RESERVED6[62];
\r
82 __IO uint32_t USB0FLADJ; /*!< USB0 frame length adjust register */
\r
83 __I uint32_t RESERVED7[63];
\r
84 __IO uint32_t USB1FLADJ; /*!< USB1 frame length adjust register */
\r
88 * @brief Identifies whether on-chip flash is present
\r
89 * @return true if on chip flash is available, otherwise false
\r
91 STATIC INLINE uint32_t Chip_CREG_OnChipFlashIsPresent(void)
\r
93 return LPC_CREG->CHIPID != 0x3284E02B;
\r
97 * @brief Configures the onboard Flash Accelerator in flash-based LPC18xx/LPC43xx parts.
\r
98 * @param Hz : Current frequency in Hz of the CPU
\r
100 * This function should be called with the higher frequency before the clock frequency is
\r
101 * increased and it should be called with the new lower value after the clock frequency is
\r
104 STATIC INLINE void Chip_CREG_SetFlashAcceleration(uint32_t Hz)
\r
106 uint32_t FAValue = Hz / 21510000;
\r
108 LPC_CREG->FLASHCFGA = (LPC_CREG->FLASHCFGA & (~(0xF << 12))) | (FAValue << 12);
\r
109 LPC_CREG->FLASHCFGB = (LPC_CREG->FLASHCFGB & (~(0xF << 12))) | (FAValue << 12);
\r
113 * @brief Enables the USB0 high-speed PHY on LPC18xx/LPC43xx parts
\r
114 * @param Enable : true to enable PHY, false to disable
\r
116 * The USB0 PLL & clock should be configured before calling this function. This function
\r
117 * should be called before the USB0 registers are accessed.
\r
119 STATIC INLINE void Chip_CREG_EnableUSB0Phy(bool Enable)
\r
122 LPC_CREG->CREG0 &= ~(1 << 5);
\r
125 LPC_CREG->CREG0 |= (1 << 5);
\r
130 * @brief Configures the BOD and Reset on LPC18xx/LPC43xx parts.
\r
131 * @param BODVL : Brown-Out Detect voltage level (0-3)
\r
132 * @param BORVL : Brown-Out Reset voltage level (0-3)
\r
135 STATIC INLINE void Chip_CREG_ConfigureBODaR(uint32_t BODVL, uint32_t BORVL)
\r
137 LPC_CREG->CREG0 = (LPC_CREG->CREG0 & ~((3 << 8) | (3 << 10))) | (BODVL << 8) | (BORVL << 10);
\r
140 #if (defined(CHIP_LPC43XX) && defined(LPC_CREG))
\r
142 * @brief Configures base address of image to be run in the Cortex M0 Core.
\r
143 * @param memaddr : Address of the image (must be aligned to 4K)
\r
146 STATIC INLINE void Chip_CREG_SetM0AppMemMap(uint32_t memaddr)
\r
148 LPC_CREG->M0APPMEMMAP = memaddr & ~0xFFF;
\r
152 * @brief Clear M4 IPC Event
\r
155 STATIC INLINE void Chip_CREG_ClearM4Event(void)
\r
157 LPC_CREG->M4TXEVENT = 0;
\r
161 * @brief Clear M0 IPC Event
\r
164 STATIC INLINE void Chip_CREG_ClearM0Event(void)
\r
166 LPC_CREG->M0TXEVENT = 0;
\r
179 #endif /* __CREG_18XX_43XX_H_ */
\r