LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sysinit_nxp_xpresso_11u14.c
Go to the documentation of this file.
1 /*
2  * @brief NXP XPRESSO 11U14 Sysinit file
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  #include "board.h"
33  #include "string.h"
34 
50 /*****************************************************************************
51  * Private types/enumerations/variables
52  ****************************************************************************/
53 
54 /* IOCON pin definitions for pin muxing */
55 typedef struct {
56  uint32_t port:8; /* Pin port */
57  uint32_t pin:8; /* Pin number */
58  uint32_t modefunc:16; /* Function and mode */
59 } PINMUX_GRP_T;
60 
61 /*****************************************************************************
62  * Public types/enumerations/variables
63  ****************************************************************************/
64 
65 /* Pin muxing table, only items that need changing from their default pin
66  state are in this table. */
68  {0, 1, (IOCON_FUNC1 | IOCON_MODE_INACT)}, /* PIO0_1 used for CLKOUT */
69  {0, 2, (IOCON_FUNC1 | IOCON_MODE_INACT)}, /* PIO0_2 used for SSEL */
70  {0, 3, (IOCON_FUNC1 | IOCON_MODE_INACT)}, /* PIO0_3 used for USB_VBUS */
71  {0, 4, (IOCON_FUNC1 | IOCON_SFI2C_EN)}, /* PIO0_4 used for SCL */
72  {0, 5, (IOCON_FUNC1 | IOCON_SFI2C_EN)}, /* PIO0_5 used for SDA */
73  {0, 6, (IOCON_FUNC1 | IOCON_MODE_INACT)}, /* PIO0_6 used for USB_CONNECT */
74  {0, 11, (IOCON_FUNC1 | IOCON_ADMODE_EN | IOCON_FILT_DIS)}, /* PIO0_11 used for AD0 */
75  {0, 18, (IOCON_FUNC1 | IOCON_MODE_INACT)}, /* PIO0_18 used for RXD */
76  {0, 19, (IOCON_FUNC1 | IOCON_MODE_INACT)}, /* PIO0_19 used for TXD */
77 };
78 
79 /*****************************************************************************
80  * Private functions
81  ****************************************************************************/
82 
83 /* Setup system clocking */
85 {
86  int i;
87 
88  /* Powerup main oscillator */
90 
91  /* Wait 200us for OSC to be stablized, no status
92  indication, dummy wait. */
93  for (i = 0; i < 0x100; i++) {}
94 
95  /* Set system PLL input to main oscillator */
97 
98  /* Powerup system PLL */
100 
101  /* Setup PLL for main oscillator rate (FCLKIN = 12MHz) * 4 = 48MHz
102  MSEL = 3 (this is pre-decremented), PSEL = 1 (for P = 2)
103  FCLKOUT = FCLKIN * (MSEL + 1) = 12MHz * 4 = 48MHz
104  FCCO = FCLKOUT * 2 * P = 48MHz * 2 * 2 = 192MHz (within FCCO range) */
106 
107  /* Wait for PLL to lock */
108  while (!Chip_Clock_IsSystemPLLLocked()) {}
109 
110  /* Set system clock divider to 1 */
112 
113  /* Setup FLASH access to 3 clocks */
115 
116  /* Set main clock source to the system PLL. This will drive 48MHz
117  for the main clock and 48MHz for the system clock */
119 
120  /* Enable IOCON clock */
122 }
123 
124 /* Sets up system pin muxing */
126 {
127  int i;
128 
129  for (i = 0; i < (sizeof(pinmuxing) / sizeof(PINMUX_GRP_T)); i++) {
131  pinmuxing[i].modefunc);
132  }
133 }
134 
135 /*****************************************************************************
136  * Public functions
137  ****************************************************************************/
138 
146 void SystemInit(void)
147 {
148  /* Booting from FLASH, so remap vector table to FLASH */
150 
151  /* Setup system clocking and muxing */
154 }