⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cstartup_eb55.c

📁 eb55评估板例程for ads
💻 C
字号:
//*----------------------------------------------------------------------------
//*         ATMEL Microcontroller Software Support  -  ROUSSET  -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name           : Cstartup_EB55.c
//* Object              : Low level initializations written in C for ARM ADS 1.2
//*                       tools
//* Creation            : JPP 11/Nov/02
//*----------------------------------------------------------------------------

// Include Standard chips definition
#include "include/AT91M55800A.h"
#include "include/lib_AT91M55800A.h"

// Include the board file description containing the EBI value
#include "eb55.h"

// The following functions must be write in ARM mode this function called directly
// by exception vector
extern void AT91F_Spurious_handler(void);
extern void AT91F_Default_IRQ_handler(void);
extern void AT91F_Default_FIQ_handler(void);

//*----------------------------------------------------------------------------
//* \fn    AT91F_LowLevelInit
//* \brief This function performs very low level HW initialization
//*        this function can be use a Stack, depending the compilation 
//*        optimization mode
//* Input Parameters
//* <Vector>  vector table Address determinate in Relative addressing
//* <InternalRam> Internal Address determinate in Relative addressing
//* Output Parameters 
//* <EBI address>
//*----------------------------------------------------------------------------
AT91_REG * AT91F_LowLevelInit( unsigned int * Vector, unsigned int * InternalRam)
{
 int            i;

 AT91PS_EBI     pEbi;
 AT91PS_AIC     pAic;
 AT91PS_APMC    pAPMC;

        //-----------------------------------------------------------------------------
        // Speed up the Boot sequence
        //---------------------------
        // After reset, the number of wait states on chip select 0 is 8. All AT91 
        // Evaluation Boards fits fast flash memories, so that the number of wait 
        // states can be optimized to fast up the boot sequence.
        //-----------------------------------------------------------------------------
        // set sandart Wait State
        pEbi = AT91C_BASE_EBI ;
        pEbi->EBI_CSR[0] = EBI_CSR_0 ;  

        //-----------------------------------------------------------------------------
        //  Speed up the System Frequency
        //---------------------------
        // After reset, the PLL must be setting the external Clock it fixed at 32 KHz  
        //-----------------------------------------------------------------------------
        pAPMC = AT91C_BASE_APMC;
        pAPMC->APMC_CGMR = AT91C_APMC_MOSCEN | (AT91C_APMC_OSCOUNT & (0x2F<< 16));

        // Reading the APMC Status register to detect when the oscillator is stabilized
        while ( (pAPMC->APMC_SR & AT91C_APMC_MOSCS) != AT91C_APMC_MOSCS ) {} ;

        // Commuting from Slow Clock to Main Oscillator (16Mhz)
        pAPMC->APMC_CGMR |= (AT91C_APMC_CSS & (0x1<< 14));

        // Setup the PLL
        pAPMC->APMC_CGMR |= ( AT91C_APMC_MUL & (0x1 << 8)) | (3 << 24);

        // Reading the APMC Status register to detect when the PLL is stabilized
         while ( AT91F_APMC_IsPllLocked (pAPMC) == 0 ) {} ;

        // Commuting from 16Mhz to PLL @ 32MHz
         pAPMC->APMC_CGMR  = (AT91C_APMC_CSS & (0x02 << 14)) | (pAPMC->APMC_CGMR & ~AT91C_APMC_CSS);

        // Now the Master clock is the output of PLL @ 32MHz
        //-----------------------------------------------------------------------------
        //  Set up EBI value
        //--------------------
        // After reset, All EBI register are setted at the default value 
        // The new value will be effective only after the remap command
        //-----------------------------------------------------------------------------
        // Load System pEbi Base address and CSR0 Init Value
        pEbi->EBI_CSR[1] = EBI_CSR_1 ;
        pEbi->EBI_CSR[2] = EBI_CSR_2 ;
        pEbi->EBI_CSR[3] = EBI_CSR_3 ;
        pEbi->EBI_CSR[4] = EBI_CSR_4 ;
        pEbi->EBI_CSR[5] = EBI_CSR_5 ;
        pEbi->EBI_CSR[6] = EBI_CSR_6 ;
        pEbi->EBI_CSR[7] = EBI_CSR_7 ;
        //-----------------------------------------------------------------------------
        // Reset the Interrupt Controller
        //-------------------------------
        // Normally, the code is executed only if a reset has been actually performed.
        // So, the AIC initialization resumes at setting up the default vectors.
        //-----------------------------------------------------------------------------
        // Load System pAic Base address 
        pAic = AT91C_BASE_AIC; 
        
        // Mask All interrupt
        pAic->AIC_IDCR = 0xFFFFFFFF;
        
        // Perform 8 End Of Interrupt Command to make sure AIC will not Lock out nIRQ 
        for (i=0;i < 8; i++)
        {
                AT91F_AIC_AcknowledgeIt(AT91C_BASE_AIC);
        }

        // Set up the default interrupts handler vectors
        pAic->AIC_SVR[0] = (int) AT91F_Default_FIQ_handler ;
        for (i=1;i < 31; i++)
        {
                pAic->AIC_SVR[i] = (int) AT91F_Default_IRQ_handler ;
        }
        pAic->AIC_SPU  = (int) AT91F_Spurious_handler ;
        
	//-----------------------------------------------------------------------------
	// Setup Exception Vectors in Internal RAM before Remap
	//-----------------------------------------------------
	// That's important to perform this operation before Remap in order to guarantee
	// that the core has valid vectors at any time during the remap operation.
	// Note: There are only 5 offsets as the vectoring is used.
	// Before Remap the internal RAM it's 0x300000
	// After  Remap the internal RAM it's 0x000000
	// Remap it's already executed it's no possible to write to 0x300000.
	//-----------------------------------------------------------------------------
	//  Copy the ARM exception vectors and indirect table

	for  (i=0;i < (8+5); i++ )
	{
	   *InternalRam++=*Vector++;
	}

        return ( &pEbi->EBI_RCR); 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -