;/*****************************************************************************/
;/*  Startup for IAR                                                          */
;/*  Version     V1.0                                                         */
;/*  Date        2020-04-14                                                   */
;/*  Target-mcu  UM321xF                                                   */
;/*****************************************************************************/
                MODULE  ?cstartup

                ;; Forward declaration of sections.
                SECTION CSTACK:DATA:NOROOT(3)

                EXTERN  __iar_program_start
                PUBLIC  __vector_table
                
                SECTION .intvec:CODE:ROOT(8)
                DATA
__vector_table  DCD     sfe(CSTACK)                 
                DCD     Reset_Handler
                DCD     NMI_Handler               ; NMI
                DCD     HardFault_Handler         ; Hard Fault
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     SVC_Handler               ; SVCall
                DCD     0                         ; Debug Monitor
                DCD     0                         ; Reserved
                DCD     PendSV_Handler            ; PendSV
                DCD     SysTick_Handler           ; SysTick

; External Interrupts

                DCD     GPIO_PA_IRQHandler			; 0:  GPIO_PA_IRQHandler    
                DCD     GPIO_PB_IRQHandler			; 1:  GPIO_PB_IRQHandler 
                DCD     GPIO_PC_IRQHandler			; 2:  GPIO_PC_IRQHandler 
                DCD     GPIO_PD_IRQHandler			; 3:  GPIO_PD_IRQHandler 
                DCD     DMA_IRQHandler          	; 4:  DMA_IRQHandler
                DCD     LPTIMER23_IRQHandler        ; 5:  LPTIMER23_IRQHandler
                DCD     UART0_IRQHandler            ; 6:  UART0_IRQHandler
                DCD     LPUART_IRQHandler	        ; 7:  LPUART_IRQHandler
                DCD     UART1_IRQHandler	        ; 8:  UART1_IRQHandler
                DCD     I2C0_IRQHandler	          	; 9:  I2C0_IRQHandler
                DCD     SPI0_IRQHandler           	; 10: SPI0_IRQHandler
                DCD     SPI1_IRQHandler				; 11: SPI1_IRQHandler  
                DCD    	CAN_IRQHandler				; 12: CAN_IRQHandler
                DCD     GPIO_PF_IRQHandler			; 13: GPIO_PF_IRQHandler
                DCD     GTIMER0_IRQHandler			; 14: GTIMER0_IRQHandler
                DCD     GTIMER1_IRQHandler			; 15: GTIMER1_IRQHandler
                DCD     GTIMER2_IRQHandler			; 16: GTIMER2_IRQHandler
                DCD     QSPI_IRQHandler          	; 17: QSPI_IRQHandler
                DCD     LPTIMER01_IRQHandler        ; 18: LPTIMER01_IRQHandler
                DCD     ANALOG_IRQHandler		    ; 19: ANALOG_IRQHandler
                DCD     GPIO_PE_IRQHandler          ; 20: GPIO_PE_IRQHandler
                DCD     ATIMER_IRQHandler           ; 21: ATIMER_IRQHandler
                DCD     WDT_IRQHandler           	; 22: WDT_IRQHandler
                DCD     RTC_IRQHandler              ; 23: RTC_IRQHandler
                DCD     ADC_IRQHandler              ; 24: ADC_IRQHandler
                DCD     BTIMER0_IRQHandler         	; 25: BTIMER0_IRQHandler
                DCD     I2C1_IRQHandler            	; 26: I2C1_IRQHandler
                DCD     WWDT_IRQHandler            	; 27: WWDT_IRQHandler
                DCD     UART2_IRQHandler            ; 28: UART2_IRQHandler 
                DCD     BTIMER1_IRQHandler         	; 29: BTIMER1_IRQHandler
                DCD     FLASH_IRQHandler            ; 30: FLASH_IRQHandler
                DCD     GPIO_PG_IRQHandler          ; 31: GPIO_PG_IRQHandler

                THUMB

                PUBWEAK Reset_Handler
                SECTION .text:CODE:REORDER:NOROOT(2)
Reset_Handler
                LDR     R0, =__iar_program_start
                BX      R0

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

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


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

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

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


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


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


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


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


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

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


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


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


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


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


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

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

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

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


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


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


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


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

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

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

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

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


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


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

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

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

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

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

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

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

                END
