www.pudn.com > RS485_USART-ok.rar > bsp.c, change:2007-09-18,size:4955b


/* 
********************************************************************************************************* 
*                                            Atmel AT91 SAM7 
*                                         Board Support Package 
* 
* 
* File : BSP.C 
* By   : Jean J. Labrosse 
********************************************************************************************************* 
*/ 
 
#include "includes.h" 
 
/* 
********************************************************************************************************* 
*                                              CONSTANTS 
********************************************************************************************************* 
*/ 
 
#define  BSP_XTAL_FREQ                                        18432L   /* onboard crystal frequency (khz) */ 
 
#define  BSP_RAM_REMAP_TEST_BYTE             (*(INT8U  *)0x00000030L) 
 
#define  BSP_UNDEF_INSTRUCTION_VECTOR_ADDR   (*(INT32U *)0x00000004L) 
#define  BSP_SWI_VECTOR_ADDR                 (*(INT32U *)0x00000008L) 
#define  BSP_PREFETCH_ABORT_VECTOR_ADDR      (*(INT32U *)0x0000000CL) 
#define  BSP_DATA_ABORT_VECTOR_ADDR          (*(INT32U *)0x00000010L) 
#define  BSP_IRQ_VECTOR_ADDR                 (*(INT32U *)0x00000018L) 
#define  BSP_FIQ_VECTOR_ADDR                 (*(INT32U *)0x0000001CL) 
 
#define  BSP_IRQ_ISR_ADDR                    (*(INT32U *)0x00000038L) 
#define  BSP_FIQ_ISR_ADDR                    (*(INT32U *)0x0000003CL) 
 
/* 
********************************************************************************************************* 
*                                               DATA TYPES 
********************************************************************************************************* 
*/ 
 
typedef  void (*BSP_PFNCT)(void); 
 
/* 
********************************************************************************************************* 
*                                              PROTOTYPES 
********************************************************************************************************* 
*/ 
 
 
 
/* 
********************************************************************************************************* 
*                                          PLL INITIALIZATION 
* 
* Description : This function initializes the AT91SAM7X256 PLL thereby setting the frequency of MCK 
*               which is used by PIT to generate the OS tick interrupt. 
* 
* Arguments   : none 
********************************************************************************************************* 
*/ 
 
void  PLL_Init (void) 
{ 
    AT91C_BASE_WDTC->WDTC_WDMR |= (1 << 15);            /* Disable the watchdog timer                  */ 
                                                        /* Set the number of flash wait states to 2    */ 
    AT91C_BASE_MC->MC_FMR      |= (1 << 8);             /* Since we are running > 30mhz out of flash   */ 
 
                                                        /* Enable the Main Oscillator                  */ 
    AT91C_BASE_CKGR->CKGR_MOR   = AT91C_CKGR_OSCOUNT | AT91C_CKGR_MOSCEN; 
 
                                                        /* Wait for the Main Oscillator to start up    */ 
    while ((AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MOSCS) == 0) { 
        ; 
    } 
 
    AT91C_BASE_CKGR->CKGR_PLLR  = 0x01033F64;           /* Enable and set PLL to 48MHZ MCK, 48MHZ USB  */ 
 
                                                        /* Wait for the PLL to start up                */ 
    while ((AT91C_BASE_PMC->PMC_SR & AT91C_PMC_LOCK) == 0) { 
        ; 
    } 
                                                         /* Master clock select = PLL w/ no prescaler   */ 
    AT91C_BASE_PMC->PMC_MCKR    = AT91C_PMC_PRES_CLK | AT91C_PMC_CSS_PLL_CLK; 
 
                                                        /* Wait for the Master Clock (MCK) to start up */ 
    while ((AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY) == 0) { 
        ; 
    } 
} 
 
/* 
********************************************************************************************************* 
*                                    DETERMINE AND RETURN CPU OPERATING FREQUENCY 
* 
* Description : This function is called by OSView_c.c : OSView_GetCPUName(). 
* 
* Arguments   : none 
* Returns     : INT32U, CPU frequency in khz. 
********************************************************************************************************* 
*/ 
 
 
 
/* 
********************************************************************************************************* 
*                                          DISABLE ALL INTERRUPTS 
* 
* Description : This function is called to disable ALL interrupts. 
* 
* Arguments   : none 
********************************************************************************************************* 
*/ 
void  BSP_IntDisAll (void) 
{ 
    AT91C_BASE_AIC->AIC_IDCR = 0xFFFFFFFF;                         /* Disable all interrupts           */ 
}