;****************************************************************************************************************************************** 
; 文件名称:	startup_SWM050.s
; 功能说明:	SWM050单片机的启动文件
; 技术支持:	http://www.synwit.com.cn/e/tool/gbook/?bid=1
; 注意事项:
; 版本日期: V1.0.0		2012年10月30日
; 升级记录: 
;
;
;******************************************************************************************************************************************
; @attention
;
; THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION 
; REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, SYNWIT SHALL NOT BE HELD LIABLE 
; FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT 
; OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONN-
; -ECTION WITH THEIR PRODUCTS.
;
; COPYRIGHT 2012 Synwit Technology
;******************************************************************************************************************************************



; <h> Stack Configuration
;   <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>

Stack_Size      EQU     0x180;

                AREA    STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem       SPACE   Stack_Size
__initial_sp    


; <h> Heap Configuration
;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>

Heap_Size       EQU     0x000;

                AREA    HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem        SPACE   Heap_Size
__heap_limit


                PRESERVE8
                THUMB


; Vector Table Mapped to Address 0 at Reset

                AREA    RESET, DATA, READONLY
                EXPORT  __Vectors
                EXPORT  __Vectors_End
                EXPORT  __Vectors_Size

__Vectors       DCD     Stack_Mem + Stack_Size    ; Top of Stack 
                DCD     Reset_Handler             ; Reset Handler
                DCD     BOD_Handler               ; NMI Handler
                DCD     HardFault_Handler         ; Hard Fault Handler
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     0                         ; Encryption flag
                DCD     0			              ; Reserved
                DCD     0                         ; Reserved
                DCD     0                         ; Switch sram
                DCD     SVC_Handler               ; SVCall Handler
                DCD     0                         ; Reserved
                DCD     0                         ; Reserved
                DCD     PendSV_Handler            ; PendSV Handler
                DCD     SysTick_Handler           ; SysTick Handler

                ; External Interrupts
                DCD     TMRSE0_Handler            ;  0: Default
				DCD     TMRSE1_Handler            ;  1: Default
				DCD     WDT_Handler       	      ;  2: Default
				DCD		ACMP_Handler			  ;  3: Default
				DCD     GPIO0_Handler             ;  4: Default
				DCD     GPIO1_Handler             ;  5: Default
				DCD     GPIO2_Handler             ;  6: Default
			   	DCD     GPIO3_Handler             ;  7: Default
				DCD     GPIO4_Handler             ;  8: Default
				DCD     GPIO5_Handler             ;  9: Default
				DCD     GPIO6_Handler             ;  10:Default
			   	DCD     GPIO7_Handler             ;  11:Default
				DCD     GPIO8_Handler             ;  12:Default
				DCD     GPIO9_Handler             ;  13:Default
				DCD     Default_Handler
				DCD     Default_Handler
				DCD     Default_Handler
				DCD     Default_Handler
				DCD     Default_Handler
				DCD     Default_Handler
				DCD     Default_Handler
				DCD     Default_Handler
				DCD     Default_Handler
				DCD     Default_Handler
				DCD     Default_Handler
				DCD     Default_Handler
				DCD     Default_Handler
				DCD     Default_Handler
				DCD     Default_Handler
				DCD     Default_Handler
				DCD     Default_Handler
				DCD     Default_Handler

__Vectors_End

__Vectors_Size 	EQU 	__Vectors_End - __Vectors


; Encryption Configuration
;	0xABCD1234	:	No Encryption
;   0xFFFFFFFF	:   Level 1	
;	0xD1C2B3A4	:	Level 2	Highest, be careful
				IF      :LNOT::DEF:NO_CRP
                AREA    |.ARM.__at_0x01FC|, CODE, READONLY
CRP_Key         DCD     0xFFFFFFFF
                ENDIF
				
				

                AREA    |.text|, CODE, READONLY


; Reset Handler

Reset_Handler   PROC
                EXPORT  Reset_Handler             [WEAK]
                IMPORT  __main

                LDR     R0, =__main
                BX      R0
                ENDP


; Dummy Exception Handlers (infinite loops which can be modified)

BOD_Handler     PROC
                EXPORT  BOD_Handler               	[WEAK]
                B       .
                ENDP

HardFault_Handler	PROC
                EXPORT  HardFault_Handler         	[WEAK]
                B       .
                ENDP

SVC_Handler     PROC
                EXPORT  SVC_Handler               	[WEAK]
                B       .
                ENDP

PendSV_Handler  PROC
                EXPORT  PendSV_Handler            	[WEAK]
                B       .
                ENDP

SysTick_Handler PROC
                EXPORT  SysTick_Handler           	[WEAK]
                B       .
                ENDP


TMRSE0_Handler PROC
			  	EXPORT TMRSE0_Handler		  		[WEAK]
                B       .
                ENDP
				
TMRSE1_Handler PROC
			  	EXPORT TMRSE1_Handler		  		[WEAK]
                B       .
                ENDP
				
WDT_Handler   PROC
			  	EXPORT WDT_Handler		  		    [WEAK]
                B       .
                ENDP
				
ACMP_Handler  PROC
                EXPORT  ACMP_Handler           	    [WEAK]
                B       .
                ENDP
							
GPIO0_Handler  PROC
			  	EXPORT GPIO0_Handler		  		[WEAK]
                B       .
                ENDP
								
GPIO1_Handler  PROC
                EXPORT  GPIO1_Handler           	[WEAK]
				B       .
                ENDP

GPIO2_Handler PROC
			  	EXPORT GPIO2_Handler		  		[WEAK]
                B       .
                ENDP
				
GPIO3_Handler  PROC
			  	EXPORT GPIO3_Handler 		  		[WEAK]
                B       .
                ENDP
				
GPIO4_Handler  PROC
			  	EXPORT GPIO4_Handler		  		[WEAK]
                B       .
                ENDP	
				
GPIO5_Handler  PROC
			  	EXPORT GPIO5_Handler		  		[WEAK]
                B       .
                ENDP
				
GPIO6_Handler  PROC
			  	EXPORT GPIO6_Handler		  		[WEAK]
                B       .
                ENDP
				
GPIO7_Handler  PROC
			  	EXPORT GPIO7_Handler		  		[WEAK]
                B       .
                ENDP

GPIO8_Handler  PROC
			  	EXPORT GPIO8_Handler		  		[WEAK]
                B       .
                ENDP

GPIO9_Handler  PROC
			  	EXPORT GPIO9_Handler		  		[WEAK]
                B       .
                ENDP

Default_Handler PROC
                EXPORT  Default_Handler           	[WEAK]
                B       .
                ENDP


; User Initial Stack & Heap

                IF      :DEF:__MICROLIB
                
                EXPORT  __initial_sp
                EXPORT  __heap_base
                EXPORT  __heap_limit
                
                ELSE
                
                IMPORT  __use_two_region_memory
                EXPORT  __user_initial_stackheap
__user_initial_stackheap

                LDR     R0, =  Heap_Mem
                LDR     R1, =(Stack_Mem + Stack_Size)
                LDR     R2, = (Heap_Mem +  Heap_Size)
                LDR     R3, = Stack_Mem
                BX      LR

                ALIGN

                ENDIF


                END
