The LPC43xx fast start files are now included.

This commit is contained in:
Richard Barry 2011-12-13 11:36:38 +00:00
parent a0eb27a69e
commit cc06119b86
16 changed files with 34611 additions and 1705 deletions

View file

@ -0,0 +1,103 @@
/**********************************************************************
* $Id: Hitex_Fast_Startup.c 8763 2011-12-08 00:45:50Z nxp21346 $ lpc43xx_emc.c 2011-12-07
*//**
* @file lpc43xx_emc.c
* @brief Contains all functions support for Clock Generation and Control
* firmware library on lpc43xx
* @version 1.0
* @date 07. December. 2011
* @author NXP MCU SW Application Team
*
* Copyright(C) 2011, NXP Semiconductor
* All rights reserved.
*
***********************************************************************
* Software that is described herein is for illustrative purposes only
* which provides customers with programming information regarding the
* products. This software is supplied "AS IS" without any warranties.
* NXP Semiconductors assumes no responsibility or liability for the
* use of the software, conveys no license or title under any patent,
* copyright, or mask work right to the product. NXP Semiconductors
* reserves the right to make changes in the software without
* notification. NXP Semiconductors also make no representation or
* warranty that such application will be suitable for the specified
* use without further testing or modification.
**********************************************************************/
#include "LPC43xx.h"
#include "lpc43xx_cgu.h"
#include "lpc43xx_emc.h"
#include "spifi_rom_api.h"
void WaitMinUS( volatile uint32_t us, uint32_t SystemClock )
{
us *= (SystemClock / 1000000UL) / 3;
while(us--);
}
void WaitMinMS( uint32_t ms, uint32_t SystemClock )
{
WaitMinUS( ( ms * 1000 ), SystemClock );
}
/* hardware-control routine used by spifi_rom_api.c */
void pullMISO(int high) {
/* undocumented bit 7 included as 1, Aug 2 2011 */
LPC_SCU->SFSP3_6 = high == 0 ? 0xDB /* pull down */
: high == 1 ? 0xC3 /* pull up */
: 0xD3; /* neither */
}
void Hitex_CGU_Init(void)
{
__disable_irq();
MemoryPinInit(); // Make sure EMC is in high-speed pin mode
/* Set the XTAL oscillator frequency to 12MHz*/
CGU_SetXTALOSC(__CRYSTAL);
CGU_EnableEntity(CGU_CLKSRC_XTAL_OSC, ENABLE);
CGU_EntityConnect(CGU_CLKSRC_XTAL_OSC, CGU_BASE_M3);
/* Set PL160M 12*1 = 12 MHz */
CGU_EntityConnect(CGU_CLKSRC_XTAL_OSC, CGU_CLKSRC_PLL1);
CGU_SetPLL1(1);
CGU_EnableEntity(CGU_CLKSRC_PLL1, ENABLE);
/* Run SPIFI from PL160M, /2 */
CGU_EntityConnect(CGU_CLKSRC_PLL1, CGU_CLKSRC_IDIVA);
CGU_EnableEntity(CGU_CLKSRC_IDIVA, ENABLE);
CGU_SetDIV(CGU_CLKSRC_IDIVA, 2);
CGU_EntityConnect(CGU_CLKSRC_IDIVA, CGU_BASE_SPIFI);
CGU_UpdateClock();
LPC_CCU1->CLK_M4_EMCDIV_CFG |= (1<<0) | (1<<5); // Turn on clock / 2
LPC_CREG->CREG6 |= (1<<16); // EMC divided by 2
LPC_CCU1->CLK_M4_EMC_CFG |= (1<<0); // Turn on clock
/* Set PL160M @ 12*9=108 MHz */
CGU_SetPLL1(9);
/* Run base M3 clock from PL160M, no division */
CGU_EntityConnect(CGU_CLKSRC_PLL1, CGU_BASE_M3);
WaitMinMS(10, 108000000UL);
/* Change the clock to 204 MHz */
/* Set PL160M @ 12*15=180 MHz */
CGU_SetPLL1(17);
WaitMinMS(10, 180000000UL);
CGU_UpdateClock();
EMCFlashInit();
vEMC_InitSRDRAM(SDRAM_BASE_ADDR, SDRAM_WIDTH, SDRAM_SIZE_MBITS, SDRAM_DATA_BUS_BITS, SDRAM_COL_ADDR_BITS);
LPC_SCU->SFSP3_3 = 0xF3; /* high drive for SCLK */
/* IO pins */
LPC_SCU->SFSP3_4=LPC_SCU->SFSP3_5=LPC_SCU->SFSP3_6=LPC_SCU->SFSP3_7 = 0xD3;
LPC_SCU->SFSP3_8 = 0x13; /* CS doesn't need feedback */
__enable_irq();
}

File diff suppressed because it is too large Load diff

View file

@ -25,15 +25,16 @@
#define PIN_OFFSET 0x04
/* Pin modes */
//#define MD_PUP (0x0<<3)
//#define MD_BUK (0x1<<3)
//#define MD_PLN (0x2<<3)
//#define MD_PDN (0x3<<3)
//#define MD_EHS (0x1<<5)
//#define MD_EZI (0x1<<6)
//#define MD_ZI (0x1<<7)
//#define MD_EHD0 (0x1<<8)
//#define MD_EHD1 (0x1<<8)
#define MD_PUP (0x0<<3)
#define MD_BUK (0x1<<3)
#define MD_PLN (0x2<<3)
#define MD_PDN (0x3<<3)
#define MD_EHS (0x1<<5)
#define MD_EZI (0x1<<6)
#define MD_ZI (0x1<<7)
#define MD_EHD0 (0x1<<8)
#define MD_EHD1 (0x1<<8)
#define MD_PLN_FAST (MD_PLN | MD_EHS | MD_EZI | MD_ZI)
/* Pin modes
* =========

View file

@ -22,14 +22,14 @@
#include <stdint.h>
#if defined CORE_M4
#include "LPC43xx.h" /* LPC18xx definitions */
#include "LPC43xx.h"
#endif
#ifdef CORE_M0
#include "LPC43xx_M0.h" /* LPC18xx definitions */
#include "LPC43xx_M0.h"
#endif
#include "scu.h"
#include "scu.h"
#include "type.h"
#include "config.h"
@ -145,27 +145,6 @@ uint32_t SPARE1Frequency = 0;
*/
void SystemInit(void)
{
#ifdef OTP
// Set IRC trim if OTP is not programmed.
if( *(uint32_t *)LPC_OTP_CTRL_BASE == 0x00FF ||
*(uint32_t *)(LPC_OTP_CTRL_BASE+4) == 0x0000)
{
LPC_CREG->IRCTRM = IRC_TRIM_VAL;
}
#else
LPC_CREG->IRCTRM = IRC_TRIM_VAL;
#endif
// Set all GPIO as input.
LPC_GPIO0->DIR = 0x0000;
LPC_GPIO1->DIR = 0x0000;
LPC_GPIO2->DIR = 0x0000;
LPC_GPIO3->DIR = 0x0000;
LPC_GPIO4->DIR = 0x0000;
LPC_GPIO5->DIR = 0x0000;
LPC_GPIO6->DIR = 0x0000;
LPC_GPIO7->DIR = 0x0000;
// M4 runs on IRC by default
M4Frequency = IRC_OSC;
XtalFrequency = XTAL_FREQ;
@ -548,14 +527,16 @@ void SetPLLUSB(CLKSRC_Type src_clk, uint8_t enable)
void EnableSourceClk(CLKSRC_Type src_clk)
{
uint32_t i=0;
const uint32_t PlainEnable = (0x2 << 3); /* no pull up, no pull down (plain) */
if(src_clk == SRC_OSC32K)
{
LPC_CREG->CREG0 &= ~((1<<3)|(1<<2)); // Active mode of 32 KHz osc and release reset
LPC_CREG->CREG0 |= (1<<1)|(1<<0); // Enable 32 kHz & 1 kHz on osc32k
}
if(src_clk == SRC_ENET_RX_CLK)scu_pinmux(0xC ,0 , PLAIN_ENABLE, FUNC3); // enet_rx_clk on PC_0 func 3
if(src_clk == SRC_ENET_TX_CLK)scu_pinmux(0x1 ,19, PLAIN_ENABLE, FUNC0); // enet_tx_clk on P1_19 func 0
if(src_clk == SRC_ENET_RX_CLK)scu_pinmux(0xC ,0 , PlainEnable, FUNC3); // enet_rx_clk on PC_0 func 3
if(src_clk == SRC_ENET_TX_CLK)scu_pinmux(0x1 ,19, PlainEnable, FUNC0); // enet_tx_clk on P1_19 func 0
if(src_clk == SRC_XTAL && (LPC_CGU->XTAL_OSC_CTRL&0x1))
{
LPC_CGU->XTAL_OSC_CTRL &= ~(1<<0); // Enable Xo50M
@ -574,14 +555,15 @@ void EnableSourceClk(CLKSRC_Type src_clk)
void DisableSourceClk(CLKSRC_Type src_clk)
{
uint32_t i=0;
const uint32_t PlainEnable = (0x2 << 3); /* no pull up, no pull down (plain) */
if(src_clk == SRC_OSC32K)
{
LPC_CREG->CREG0 &= ~((1<<1)|(1<<0)); // Disable 32 kHz & 1 kHz on osc32k
LPC_CREG->CREG0 |= ((1<<3)|(1<<2)); // osc32k in power down and in reset mode
}
if(src_clk == SRC_ENET_RX_CLK)scu_pinmux(0xC ,0 , PLAIN_ENABLE, FUNC0); // nc on PC_0 func 0
if(src_clk == SRC_ENET_TX_CLK)scu_pinmux(0x1 ,19, PLAIN_ENABLE, FUNC2); // nc on P1_19 func 2
if(src_clk == SRC_ENET_RX_CLK)scu_pinmux(0xC ,0 , PlainEnable, FUNC0); // nc on PC_0 func 0
if(src_clk == SRC_ENET_TX_CLK)scu_pinmux(0x1 ,19, PlainEnable, FUNC2); // nc on P1_19 func 2
if(src_clk == SRC_XTAL)
{
LPC_CGU->XTAL_OSC_CTRL = (1<<0); // Disable Xo50M