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_1347.c
Go to the documentation of this file.
1 /*
2  * @brief Xpresso 1347 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 
52 /*****************************************************************************
53  * Private types/enumerations/variables
54  ****************************************************************************/
55 
56 /* IOCON pin definitions for pin muxing */
57 typedef struct {
58  uint32_t port:8; /* Pin port */
59  uint32_t pin:8; /* Pin number */
60  uint32_t modefunc:16; /* Pin mode */
61 } PINMUX_GRP_T;
62 
63 /*****************************************************************************
64  * Public types/enumerations/variables
65  ****************************************************************************/
66 
67 /* Pin muxing table, only items that need changing from their default pin
68  state are in this table. */
70  {0, 1, (IOCON_FUNC1 | IOCON_MODE_INACT)}, /* PIO0_1 used for CLKOUT */
71  {0, 2, (IOCON_FUNC1 | IOCON_MODE_PULLUP)}, /* PIO0_2 used for SSEL */
72  {0, 3, (IOCON_FUNC1 | IOCON_MODE_INACT)}, /* PIO0_3 used for USB_VBUS */
73  {0, 4, (IOCON_FUNC1 | IOCON_SFI2C_EN)}, /* PIO0_4 used for SCL */
74  {0, 5, (IOCON_FUNC1 | IOCON_SFI2C_EN)}, /* PIO0_5 used for SDA */
75  {0, 6, (IOCON_FUNC1 | IOCON_MODE_INACT)}, /* PIO0_6 used for USB_CONNECT */
76  {0, 8, (IOCON_FUNC1 | IOCON_MODE_INACT)}, /* PIO0_8 used for MISO0 */
77  {0, 9, (IOCON_FUNC1 | IOCON_MODE_INACT)}, /* PIO0_9 used for MOSI0 */
78  {0, 11, (IOCON_FUNC1 | IOCON_ADMODE_EN | IOCON_FILT_DIS)},/* PIO0_11 used for AD0 */
79  {0, 18, (IOCON_FUNC1 | IOCON_MODE_INACT)}, /* PIO0_18 used for RXD */
80  {0, 19, (IOCON_FUNC1 | IOCON_MODE_INACT)}, /* PIO0_19 used for TXD */
81  {1, 29, (IOCON_FUNC1 | IOCON_MODE_INACT)}, /* PIO1_29 used for SCK0 */
82 };
83 
84 /*****************************************************************************
85  * Private functions
86  ****************************************************************************/
87 
88 /* Setup system clocking */
90 {
91  int i;
92 
93  /* Powerup main oscillator */
95 
96  /* Wait an estimated 200us for OSC to be stablized, no status
97  indication, dummy wait */
98  for (i = 0; i < 0x100; i++) {}
99 
100  /* Set system PLL input to main oscillator */
102 
103  /* Powerup system PLL */
105 
106  /* Setup PLL for main oscillator rate (FCLKIN = 12MHz) * 6 = 72MHz
107  MSEL = 5 (this is pre-decremented), PSEL = 1 (for P = 2)
108  FCLKOUT = FCLKIN * (MSEL + 1) = 12MHz * 6 = 72MHz
109  FCCO = FCLKOUT * 2 * P = 72MHz * 2 * 2 = 288MHz (within FCCO range) */
111 
112  /* Wait for PLL to lock */
113  while (!Chip_Clock_IsSystemPLLLocked()) {}
114 
115  /* Set system clock divider to 1 */
117 
118  /* Setup FLASH access to 3 clocks (72MHz clock) */
120 
121  /* Set main clock source to the system PLL. This will drive 72MHz
122  for the main clock and 72MHz for the system clock */
124 
125  /* Enable IOCON clock */
127 }
128 
129 /* Sets up system pin muxing */
131 {
132  int i;
133 
134  for (i = 0; i < (sizeof(pinmuxing) / sizeof(PINMUX_GRP_T)); i++) {
136  pinmuxing[i].modefunc);
137  }
138 }
139 
140 /*****************************************************************************
141  * Public functions
142  ****************************************************************************/
143 
151 void SystemInit(void)
152 {
153  /* Booting from FLASH, so remap vector table to FLASH */
155 
156  /* Setup system clocking and muxing */
159 }