/**************************************************************************//**
 * @file     startup_spc1168.s
 * @brief    SPC1168 device vector table for EWARM toolchain
 * @version  V1.1.0
 * @date     31-May-2019
 *
 * @note
 * Copyright (C) 2019 Spintrol Limited Corporation. All rights reserved.
 *
 * @attention
 * THIS SOFTWARE JUST PROVIDES CUSTOMERS WITH CODING INFORMATION REGARDING 
 * THEIR PRODUCTS, WHICH AIMS AT SAVING TIME FOR THEM. SPINTROL SHALL NOT BE
 * LIABLE FOR THE USE OF THE SOFTWARE. SPINTROL DOES NOT GUARANTEE THE 
 * CORRECTNESS OF THIS SOFTWARE AND RESERVES THE RIGHT TO MODIFY THE SOFTWARE 
 * WITHOUT NOTIFICATION.
 *
 ******************************************************************************/
;
;
; The modules in this file are included in the libraries, and may be replaced
; by any user-defined modules that define the PUBLIC symbol _program_start or
; a user defined start symbol.
; To override the cstartup defined in the library, simply add your modified
; version to the workbench project.
;
; The vector table is normally located at address 0.
; When debugging in RAM, it can be located in RAM, aligned to at least 2^6.
; The name "__vector_table" has special meaning for C-SPY:
; it is where the SP start value is found, and the NVIC vector
; table register (VTOR) is initialized to this address if != 0.
;
; Cortex-M version
;

        MODULE  ?cstartup                 ; Defining the module name

        ;; Forward declaration of sections.
        SECTION CSTACK:DATA:NOROOT(3)     ; Define data section for stack, 8-byte alignment

        SECTION .intvec:CODE:NOROOT(2)    ; Define code section for .intvec, 4-byte alignment

        EXTERN  __iar_program_start       ; Import __iar_program_start function
        EXTERN  SystemInit                ; Import SystemInit function
        PUBLIC  __vector_table            ; Declare the interrupt vector table address

        DATA                              ; Define the data of the data section
__vector_table                            ; The starting address of the interrupt vector table
                                          ; The following is the interrupt vector table definition
        DCD     sfe(CSTACK)               ;-16 Top of Stack
        DCD     Reset_Handler             ;-15 Reset Handler
        
        DCD     NMI_Handler               ;-14 NMI Handler
        DCD     HardFault_Handler         ;-13 Hard Fault Handler
        DCD     MemManage_Handler         ;-12 MPU Fault Handler
        DCD     BusFault_Handler          ;-11 Bus Fault Handler
        DCD     UsageFault_Handler        ;-10 Usage Fault Handler
        DCD     0                         ;- 9 Reserved
        DCD     0                         ;- 8 Reserved
        DCD     0                         ;- 7 Reserved
        DCD     0                         ;- 6 Reserved
        DCD     SVC_Handler               ;- 5 SVCall Handler
        DCD     DebugMon_Handler          ;- 4 Debug Monitor Handler
        DCD     0                         ;- 3 Reserved
        DCD     PendSV_Handler            ;- 2 PendSV Handler
        DCD     SysTick_Handler           ;- 1 SysTick Handler

        ; External Interrupts
        DCD     MEM_IRQHandler            ;  0 Memory Error IRQHandler
        DCD     POWER_IRQHandler          ;  1 Power Error IRQHandler
        DCD     CLOCK_IRQHandler          ;  2 Clock Error IRQHandler
        DCD     WDT1_IRQHandler           ;  3 Watchdog 1 IRQHandler
        DCD     GPIO_LEVEL_IRQHandler     ;  4 GPIO Level IRQHandler
        DCD     GPIO_EDGE_IRQHandler      ;  5 GPIO Edge IRQHandler
        DCD     SIO0A_IRQHandler          ;  6 SIO0 Int A IRQHandler
        DCD     SIO0B_IRQHandler          ;  7 SIO0 Int B IRQHandler
        DCD     0                         ;  8 Reserved
        DCD     0                         ;  9 Reserved
        DCD     0                         ; 10 Reserved
        DCD     0                         ; 11 Reserved
        DCD     UART_IRQHandler           ; 12 UART IRQHandler
        DCD     SSP_IRQHandler            ; 13 SSP IRQHandler
        DCD     I2C_IRQHandler            ; 14 I2C IRQHandler
        DCD     ADC0_IRQHandler           ; 15 ADC EOC0  IRQHandler
        DCD     ADC1_IRQHandler           ; 16 ADC EOC1  IRQHandler
        DCD     ADC2_IRQHandler           ; 17 ADC EOC2  IRQHandler
        DCD     ADC3_IRQHandler           ; 18 ADC EOC3  IRQHandler
        DCD     ADC4_IRQHandler           ; 19 ADC EOC4  IRQHandler
        DCD     ADC5_IRQHandler           ; 20 ADC EOC5  IRQHandler
        DCD     ADC6_IRQHandler           ; 21 ADC EOC6  IRQHandler
        DCD     ADC7_IRQHandler           ; 22 ADC EOC7  IRQHandler
        DCD     ADC8_IRQHandler           ; 23 ADC EOC8  IRQHandler
        DCD     ADC9_IRQHandler           ; 24 ADC EOC9  IRQHandler
        DCD     ADC10_IRQHandler          ; 25 ADC EOC10 IRQHandler
        DCD     ADC11_IRQHandler          ; 26 ADC EOC11 IRQHandler
        DCD     ADC12_IRQHandler          ; 27 ADC EOC12 IRQHandler
        DCD     ADC13_IRQHandler          ; 28 ADC EOC13 IRQHandler
        DCD     ADC14_IRQHandler          ; 29 ADC EOC14 IRQHandler
        DCD     ADC15_IRQHandler          ; 30 ADC EOC15 IRQHandler
        DCD     ADCPPU0_IRQHandler        ; 31 ADC PPU0 IRQHandler
        DCD     ADCPPU1_IRQHandler        ; 32 ADC PPU1 IRQHandler
        DCD     ADCPPU2_IRQHandler        ; 33 ADC PPU2 IRQHandler
        DCD     ADCPPU3_IRQHandler        ; 34 ADC PPU3 IRQHandler
        DCD     ADCPPU4_IRQHandler        ; 35 ADC PPU4 IRQHandler
        DCD     ADCPPU5_IRQHandler        ; 36 ADC PPU5 IRQHandler
        DCD     0                         ; 37 Reserved
        DCD     0                         ; 38 Reserved
        DCD     PWM0_IRQHandler           ; 39 PWM0 IRQHandler
        DCD     PWM1_IRQHandler           ; 40 PWM1 IRQHandler
        DCD     PWM2_IRQHandler           ; 41 PWM2 IRQHandler
        DCD     PWM3_IRQHandler           ; 42 PWM3 IRQHandler
        DCD     PWM4_IRQHandler           ; 43 PWM4 IRQHandler
        DCD     PWM5_IRQHandler           ; 44 PWM5 IRQHandler
        DCD     0                         ; 45 Reserved
        DCD     0                         ; 46 Reserved
        DCD     PWM0TZ_IRQHandler         ; 47 PWM0 Trip-Zone IRQHandler
        DCD     PWM1TZ_IRQHandler         ; 48 PWM1 Trip-Zone IRQHandler
        DCD     PWM2TZ_IRQHandler         ; 49 PWM2 Trip-Zone IRQHandler
        DCD     PWM3TZ_IRQHandler         ; 50 PWM3 Trip-Zone IRQHandler
        DCD     PWM4TZ_IRQHandler         ; 51 PWM4 Trip-Zone IRQHandler
        DCD     PWM5TZ_IRQHandler         ; 52 PWM5 Trip-Zone IRQHandler
        DCD     0                         ; 53 Reserved
        DCD     0                         ; 54 Reserved
        DCD     ECAP_IRQHandler           ; 55 ECAP IRQHandler
        DCD     TIMER0_IRQHandler         ; 56 Timer0 IRQHandler
        DCD     TIMER1_IRQHandler         ; 57 Timer1 IRQHandler
        DCD     TIMER2_IRQHandler         ; 58 Timer2 IRQHandler
        DCD     CRC_IRQHandler            ; 59 CRC IRQHandler
        DCD     AES_IRQHandler            ; 60 AES IRQHandler


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Default interrupt handlers.
;;
        THUMB                                   ; Enter Thumb instruction mode
        PUBWEAK Reset_Handler                   ; Define the Reset_Handler function as the weak function,
                                                ; can be overridden by user-defined interrupt functions
        SECTION .text:CODE:REORDER:NOROOT(2)    ; Define code section
Reset_Handler                                   ; Reset_Handler function entry address
                                                ; The following is implementation of the Reset_Handler function
        
        ; Set VTOR register, Remap vector table
        LDR     R0, =__vector_table
        LDR     R1, =0xE000ED08 ;*VTOR register
        STR     R0,[R1]
        
        ;* C routines are likely to be called. Setup the stack now
        LDR     SP,=sfe(CSTACK)                 ; Set the stack pointer
        
        LDR     R0, =SystemInit                 ; Call the SystemInit function
        BLX     R0
        
        ;* Reset stack pointer before zipping off to user application
        LDR     SP,=sfe(CSTACK)
        
        LDR     R0, =__iar_program_start        ; Jump to the IAR program entry address and finally enter the main() function
        BX      R0


        PUBWEAK NMI_Handler                     ; Define the NMI_Handler function as the weak function, 
                                                ; can be overridden by user-defined interrupt functions
        SECTION .text:CODE:REORDER:NOROOT(1)    ; Define code section
NMI_Handler                                     ; NMI_Handler function entry address
        B NMI_Handler                           ; The following is implementation of the Reset_Handler function£ºwhile(1)

        PUBWEAK HardFault_Handler
        SECTION .text:CODE:REORDER:NOROOT(1)
HardFault_Handler
        B HardFault_Handler
        
        PUBWEAK MemManage_Handler
        SECTION .text:CODE:REORDER:NOROOT(1)
MemManage_Handler
        B MemManage_Handler

        PUBWEAK BusFault_Handler
        SECTION .text:CODE:REORDER:NOROOT(1)
BusFault_Handler
        B  BusFault_Handler

        PUBWEAK UsageFault_Handler
        SECTION .text:CODE:REORDER:NOROOT(1)
UsageFault_Handler
        B UsageFault_Handler

        PUBWEAK SVC_Handler
        SECTION .text:CODE:REORDER:NOROOT(1)
SVC_Handler
        B SVC_Handler

        PUBWEAK DebugMon_Handler
        SECTION .text:CODE:REORDER:NOROOT(1)
DebugMon_Handler
        B DebugMon_Handler

        PUBWEAK PendSV_Handler
        SECTION .text:CODE:REORDER:NOROOT(1)
PendSV_Handler
        B PendSV_Handler

        PUBWEAK SysTick_Handler
        SECTION .text:CODE:REORDER:NOROOT(1)
SysTick_Handler
        B  SysTick_Handler


        PUBWEAK MEM_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1)
MEM_IRQHandler
        B MEM_IRQHandler
        
        PUBWEAK POWER_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
POWER_IRQHandler
        B POWER_IRQHandler
        
        PUBWEAK CLOCK_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
CLOCK_IRQHandler
        B CLOCK_IRQHandler
        
        PUBWEAK WDT1_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
WDT1_IRQHandler
        B WDT1_IRQHandler

        PUBWEAK GPIO_LEVEL_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
GPIO_LEVEL_IRQHandler
        B GPIO_LEVEL_IRQHandler
        
        PUBWEAK GPIO_EDGE_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
GPIO_EDGE_IRQHandler
        B GPIO_EDGE_IRQHandler
        
        PUBWEAK SIO0A_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
SIO0A_IRQHandler
        B SIO0A_IRQHandler
        
        PUBWEAK SIO0B_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
SIO0B_IRQHandler
        B SIO0B_IRQHandler
        
        PUBWEAK UART_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
UART_IRQHandler
        B UART_IRQHandler
        
        PUBWEAK SSP_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
SSP_IRQHandler
        B SSP_IRQHandler
        
        PUBWEAK I2C_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
I2C_IRQHandler
        B I2C_IRQHandler
        
        PUBWEAK ADC0_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADC0_IRQHandler
        B ADC0_IRQHandler
         
        PUBWEAK ADC1_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADC1_IRQHandler
        B ADC1_IRQHandler

        PUBWEAK ADC2_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADC2_IRQHandler
        B ADC2_IRQHandler

        PUBWEAK ADC3_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADC3_IRQHandler
        B ADC3_IRQHandler

        PUBWEAK ADC4_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADC4_IRQHandler
        B ADC4_IRQHandler
        
        PUBWEAK ADC5_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADC5_IRQHandler
        B ADC5_IRQHandler
        
        PUBWEAK ADC6_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADC6_IRQHandler
        B ADC6_IRQHandler
        
        PUBWEAK ADC7_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADC7_IRQHandler
        B ADC7_IRQHandler
        
        PUBWEAK ADC8_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADC8_IRQHandler
        B ADC8_IRQHandler
        
        PUBWEAK ADC9_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADC9_IRQHandler
        B ADC9_IRQHandler
        
        PUBWEAK ADC10_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADC10_IRQHandler
        B ADC10_IRQHandler
        
        PUBWEAK ADC11_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADC11_IRQHandler
        B ADC11_IRQHandler
        
        PUBWEAK ADC12_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADC12_IRQHandler
        B ADC12_IRQHandler

        PUBWEAK ADC13_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADC13_IRQHandler
        B ADC13_IRQHandler

        PUBWEAK ADC14_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADC14_IRQHandler
        B ADC14_IRQHandler

        PUBWEAK ADC15_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADC15_IRQHandler
        B ADC15_IRQHandler
        
        PUBWEAK ADCPPU0_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADCPPU0_IRQHandler
        B ADCPPU0_IRQHandler
        
        PUBWEAK ADCPPU1_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADCPPU1_IRQHandler
        B ADCPPU1_IRQHandler
        
        PUBWEAK ADCPPU2_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADCPPU2_IRQHandler
        B ADCPPU2_IRQHandler
        
        PUBWEAK ADCPPU3_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADCPPU3_IRQHandler
        B ADCPPU3_IRQHandler
        
        PUBWEAK ADCPPU4_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADCPPU4_IRQHandler
        B ADCPPU4_IRQHandler
        
        PUBWEAK ADCPPU5_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ADCPPU5_IRQHandler
        B ADCPPU5_IRQHandler
        
        PUBWEAK PWM0_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
PWM0_IRQHandler
        B PWM0_IRQHandler
        
        PUBWEAK PWM1_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
PWM1_IRQHandler
        B PWM1_IRQHandler
        
        PUBWEAK PWM2_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
PWM2_IRQHandler
        B PWM2_IRQHandler
        
        PUBWEAK PWM3_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
PWM3_IRQHandler
        B PWM3_IRQHandler
        
        PUBWEAK PWM4_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1)
PWM4_IRQHandler
        B PWM4_IRQHandler
        
        PUBWEAK PWM5_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1)
PWM5_IRQHandler
        B PWM5_IRQHandler

        PUBWEAK PWM0TZ_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
PWM0TZ_IRQHandler
        B PWM0TZ_IRQHandler
       
        PUBWEAK PWM1TZ_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
PWM1TZ_IRQHandler
        B PWM1TZ_IRQHandler

        PUBWEAK PWM2TZ_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
PWM2TZ_IRQHandler
        B PWM2TZ_IRQHandler
        
        PUBWEAK PWM3TZ_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1)
PWM3TZ_IRQHandler
        B PWM3TZ_IRQHandler
        
        PUBWEAK PWM4TZ_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1)
PWM4TZ_IRQHandler
        B PWM4TZ_IRQHandler
      
        PUBWEAK PWM5TZ_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
PWM5TZ_IRQHandler
        B PWM5TZ_IRQHandler
      
        PUBWEAK ECAP_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
ECAP_IRQHandler
        B ECAP_IRQHandler

        PUBWEAK TIMER0_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
TIMER0_IRQHandler
        B TIMER0_IRQHandler
        
        PUBWEAK TIMER1_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
TIMER1_IRQHandler
        B TIMER1_IRQHandler
        
        PUBWEAK TIMER2_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
TIMER2_IRQHandler
        B TIMER2_IRQHandler
        
        PUBWEAK CRC_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
CRC_IRQHandler
        B CRC_IRQHandler
        
        PUBWEAK AES_IRQHandler
        SECTION .text:CODE:REORDER:NOROOT(1) 
AES_IRQHandler
        B AES_IRQHandler


        END

/******************* (C) COPYRIGHT 2019 SPINTROL LIMITED CO. *****END OF FILE****/
