?? cstartup_sam9.c
字號:
#include "project.h"
__irq void AT91F_Spurious_handler(void){
re:
goto re;
}
__irq void AT91F_Default_IRQ_handler(void){
re:
goto re;
}
__irq void AT91F_Default_FIQ_handler(void){
re:
goto re;
}
//*----------------------------------------------------------------------------
//* \fn AT91F_TestRemap
//* \brief This function test if the SRAM is remapped to zero
//* \return value:
//* 0 : Remap done
//* 1 : Remap not Done
//*----------------------------------------------------------------------------
unsigned int AT91F_TestRemap()
{
volatile unsigned int *pSram = (unsigned int *)0;
unsigned int val, data_test;
val = *pSram;
(val != 0xAA55AA55)?(data_test=0xAA55AA55):(data_test=0x55AA55AA);
*pSram = data_test;
(*pSram == data_test)?(data_test = 0):(data_test=1);
*pSram = val;
return data_test;
}
//*---------------------------------------------------------------------------*/
//* Function Name : AT91F_SetPLL
//* Object : Set the PLLA to 200 and Master clock to 100 Mhz
//*---------------------------------------------------------------------------*/
static void AT91F_SetPLL(void)
{
AT91PS_PMC pPmc = AT91C_BASE_PMC;
///////////////////////////////////////////////////////////////////////////
// Init PMC Step 1. Enable Main Oscillator
// Main Oscillator startup time is board specific:
// Main Oscillator Startup Time worst case (18MHz) corresponds to 1,4ms
// (0x08 for AT91C_CKGR_OSCOUNT field)
///////////////////////////////////////////////////////////////////////////
pPmc->PMC_MOR = (( AT91C_CKGR_OSCOUNT & (0x8 <<8) | AT91C_CKGR_MOSCEN )); //使能主振蕩器
// Wait Main Oscillator stabilization
while(!(pPmc->PMC_SR & AT91C_PMC_MOSCS)); //等待主振蕩器穩定
// Switch to main ocilator
AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_CSS_MAIN_CLK;
///////////////////////////////////////////////////////////////////////////
// Init PMC Step 2.
// Set PLL to 96MHz (96,109MHz) and UDP Clock to 48MHz
// PLL Startup time depends on PLL RC filter: worst case is choosen
// UDP Clock (48,058MHz) is compliant with the Universal Serial Bus
// Specification (+/- 0.25% for full speed)
/* -Setup the PLL A */
AT91C_BASE_CKGR->CKGR_PLLAR = (AT91C_CKGR_SRCA) |
((172 << 16) & AT91C_CKGR_MULA) |
(AT91C_CKGR_PLLACOUNT) |
(AT91C_CKGR_OUTA_2) |
(16);
while (!(pPmc->PMC_SR & AT91C_PMC_LOCKA));
// Wait until the master clock is established for the case we already
// turn on the PLL
///////////////////////////////////////////////////////////////////////////
// Init PMC Step 3.
// Selection of Master Clock MCK equal to (Processor Clock PCK) PLL/2=48MHz
///////////////////////////////////////////////////////////////////////////
AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_CSS_PLLA_CLK | AT91C_PMC_PRES_CLK | AT91C_PMC_MDIV_2;;
// Wait until the master clock is established
while( !(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY) );
}
//*----------------------------------------------------------------------------
//* \fn AT91F_LowLevelInit
//* \brief This function performs very low level HW initialization
//*----------------------------------------------------------------------------
void AT91F_LowLevelInit(void)
{
unsigned int i;
AT91C_BASE_CCFG->CCFG_EBICSA |= 0x1003A; //CS1-->SDRAM VDDIOM=3.3V
if (AT91F_TestRemap())
AT91F_MATRIX_Remap_ARM (AT91C_BASE_MATRIX);
///////////////////////////////////////////////////////////////////////////
// PLL setting
///////////////////////////////////////////////////////////////////////////
AT91F_SetPLL();
///////////////////////////////////////////////////////////////////////////
// Disable Watchdog (write once register)
///////////////////////////////////////////////////////////////////////////
AT91C_BASE_WDTC->WDTC_WDMR = AT91C_WDTC_WDDIS;
///////////////////////////////////////////////////////////////////////////
// Init AIC: assign corresponding handler for each interrupt source
///////////////////////////////////////////////////////////////////////////
AT91C_BASE_AIC->AIC_SVR[0] = (int) AT91F_Default_FIQ_handler ;
for (i = 1; i < 31; i++) {
AT91C_BASE_AIC->AIC_SVR[i] = (int) AT91F_Default_IRQ_handler ;
}
AT91C_BASE_AIC->AIC_SPU = (unsigned int) AT91F_Spurious_handler;
AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_SYS; //zyf
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -