SAM3S8/SD8 Software Package: libraries/libboard_sam3s-ek2/source/board_cstartup_iar.c Source File

SAM3S8/SD8 Software Package 1.2

# board_cstartup_iar.c

    00001 /* ----------------------------------------------------------------------------
    00002  *         ATMEL Microcontroller Software Support
    00003  * ----------------------------------------------------------------------------
    00004  * Copyright (c) 2011, Atmel Corporation
    00005  *
    00006  * All rights reserved.
    00007  *
    00008  * Redistribution and use in source and binary forms, with or without
    00009  * modification, are permitted provided that the following conditions are met:
    00010  *
    00011  * - Redistributions of source code must retain the above copyright notice,
    00012  * this list of conditions and the disclaimer below.
    00013  *
    00014  * Atmel's name may not be used to endorse or promote products derived from
    00015  * this software without specific prior written permission.
    00016  *
    00017  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
    00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    00019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
    00020  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
    00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    00022  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
    00023  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    00026  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00027  * ----------------------------------------------------------------------------
    00028  */
    00029
    00030 /*------------------------------------------------------------------------------
    00031  *         Headers
    00032  *------------------------------------------------------------------------------*/
    00033
    00034 #include "board.h"
    00035
    00036 /*----------------------------------------------------------------------------
    00037  *        Definitions
    00038  *----------------------------------------------------------------------------*/
    00039
    00040 /*------------------------------------------------------------------------------
    00041  *         Types
    00042  *------------------------------------------------------------------------------*/
    00043 typedef union { IntFunc __fun; void * __ptr; } IntVector;
    00044
    00045 /*------------------------------------------------------------------------------
    00046  *         ProtoTypes
    00047  *------------------------------------------------------------------------------*/
    00048 extern void __iar_program_start( void ) ;
    00049
    00050 extern int __low_level_init( void ) ;
    00051
    00052 /*------------------------------------------------------------------------------
    00053  *         Exception Table
    00054  *------------------------------------------------------------------------------*/
    00055 #pragma language=extended
    00056 #pragma segment="CSTACK"
    00057
    00058 /*  The name "__vector_table" has special meaning for C-SPY: */
    00059 /*  it is where the SP start value is found, and the NVIC vector */
    00060 /*  table register (VTOR) is initialized to this address if != 0. */
    00061
    00062 #pragma section = ".intvec"
    00063 #pragma location = ".intvec"
    00064 const IntVector __vector_table[] =
    00065 {
    00066     { .__ptr = __sfe( "CSTACK" ) },
    00067     __iar_program_start,
    00068
    00069     NMI_Handler,
    00070     HardFault_Handler,
    00071     MemManage_Handler,
    00072     BusFault_Handler,
    00073     UsageFault_Handler,
    00074     0, 0, 0, 0,         /* Reserved */
    00075     SVC_Handler,
    00076     DebugMon_Handler,
    00077     0,                  /* Reserved  */
    00078     PendSV_Handler,
    00079     SysTick_Handler,
    00080
    00081     /* Configurable interrupts  */
    00082     SUPC_IrqHandler,    /* 0  Supply Controller */
    00083     RSTC_IrqHandler,    /* 1  Reset Controller */
    00084     RTC_IrqHandler,     /* 2  Real Time Clock */
    00085     RTT_IrqHandler,     /* 3  Real Time Timer */
    00086     WDT_IrqHandler,     /* 4  Watchdog Timer */
    00087     PMC_IrqHandler,     /* 5  PMC */
    00088     EEFC_IrqHandler,    /* 6  EEFC */
    00089     IrqHandlerNotUsed,  /* 7  Reserved */
    00090     UART0_IrqHandler,   /* 8  UART0 */
    00091     UART1_IrqHandler,   /* 9  UART1 */
    00092     SMC_IrqHandler,     /* 10 SMC */
    00093     PIOA_IrqHandler,    /* 11 Parallel IO Controller A */
    00094     PIOB_IrqHandler,    /* 12 Parallel IO Controller B */
    00095     PIOC_IrqHandler,    /* 13 Parallel IO Controller C */
    00096     USART0_IrqHandler,  /* 14 USART 0 */
    00097     USART1_IrqHandler,  /* 15 USART 1 */
    00098     USART2_IrqHandler,  /* 16 USART 2 */
    00099     IrqHandlerNotUsed,  /* 17 Reserved */
    00100     MCI_IrqHandler,     /* 18 MCI */
    00101     TWI0_IrqHandler,    /* 19 TWI 0 */
    00102     TWI1_IrqHandler,    /* 20 TWI 1 */
    00103     SPI_IrqHandler,     /* 21 SPI */
    00104     SSC_IrqHandler,     /* 22 SSC */
    00105     TC0_IrqHandler,     /* 23 Timer Counter 0 */
    00106     TC1_IrqHandler,     /* 24 Timer Counter 1 */
    00107     TC2_IrqHandler,     /* 25 Timer Counter 2 */
    00108     TC3_IrqHandler,     /* 26 Timer Counter 3 */
    00109     TC4_IrqHandler,     /* 27 Timer Counter 4 */
    00110     TC5_IrqHandler,     /* 28 Timer Counter 5 */
    00111     ADC_IrqHandler,     /* 29 ADC controller */
    00112     DAC_IrqHandler,     /* 30 DAC controller */
    00113     PWM_IrqHandler,     /* 31 PWM */
    00114     CRCCU_IrqHandler,   /* 32 CRC Calculation Unit */
    00115     ACC_IrqHandler,     /* 33 Analog Comparator */
    00116     USBD_IrqHandler,    /* 34 USB Device Port */
    00117     IrqHandlerNotUsed   /* 35 not used */
    00118 };
    00119
    00120 /**
    00121  * \brief This is the code that gets called on processor reset. To initialize the
    00122  * device.
    00123  */
    00124 extern int __low_level_init( void )
    00125 {
    00126     uint32_t* pSrc = __section_begin( ".intvec" ) ;
    00127
    00128     /* Low level Initialize */
    00129     LowLevelInit() ;
    00130
    00131     SCB->VTOR = ( (uint32_t)pSrc & SCB_VTOR_TBLOFF_Msk ) ;
    00132
    00133     if ( ((uint32_t)pSrc >= IRAM_ADDR) && ((uint32_t)pSrc < IRAM_ADDR+IRAM_SIZE) )
    00134     {
    00135         SCB->VTOR |= 1 << SCB_VTOR_TBLBASE_Pos ;
    00136     }
    00137
    00138     return 1 ; /*  if return 0, the data sections will not be initialized. */
    00139 }

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines