;/*!
; * @file        startup_bmp561.s
; *
; * @brief       CMSIS Cortex-M0+ based Core Device Startup File for Device startup_bmp561
; *
; * @version     V1.0.0
; *
; * @date        2024-02-04
; *
; */


; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
;   <o> Stack Size (in Bytes) <0x0-0x1FFFFFFF:8>
; </h>

Stack_Size      EQU     0x00000400

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


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

Heap_Size       EQU     0x00000000

                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     __initial_sp               ; Top of Stack
                DCD     Reset_Handler              ; Reset Handler
                DCD     NMI_Handler                ; NMI Handler
                DCD     HardFault_Handler          ; Hard Fault Handler

;attention!!!
;(1)There four reserved address is used for application code valid flag.If the content of this four Address
;   is fllowing value(0x5A5A5A5A...) means application code is valid,vice-versa. And check this four Address
;   is valid or not is in bootloader, if invalid, will stay boot and could not be jump to application program.
;(2)There four reserved address must be initialized to 0xFFFFFFFF, and after you have download or updated application
;   code,you have to write the four address to valid value(0x5A5A5A5A...). But,when you debugging program in MDK,you
;   can write this four address to valid value directly in order to convenience.
                DCD     0x5A5A5A5A                 ; Reserved
                DCD     0x4B4B4B4B                 ; Reserved
                DCD     0x3C3C3C3C                 ; Reserved
                DCD     0x2D2D2D2D                 ; Reserved
                DCD     0                          ; Reserved
                DCD     0                          ; Reserved
                DCD     0                          ; Reserved
                DCD     SVC_Handler                ; SVCall Handler
                DCD     0                          ; Reserved
                DCD     0                          ; Reserved
                DCD     PendSV_Handler             ; PendSV Handler
                DCD     SysTick_Handler            ; SysTick Handler

                ; External Interrupts
                DCD     I2C_Handler
				DCD     HSC_Handler
				DCD     UART_Handler
				DCD     0
                DCD     WWDT_Handler
				DCD     TMR0_Handler
				DCD     TMR1_Handler
				DCD     CADC_Handler
				DCD     VADC_Handler
				DCD     FLASH_Handler
				DCD     WUPT_Handler
				DCD     I2C_STA_Handler
				DCD     EINT0_Handler
				DCD     EINT1_Handler
				DCD     EINT2_Handler
				DCD     SHA256_Handler

__Vectors_End

__Vectors_Size  EQU  __Vectors_End - __Vectors

                AREA    |.text|, CODE, READONLY

; Reset handler
Reset_Handler    PROC
                 EXPORT  Reset_Handler             [WEAK]
                 IMPORT  SystemInit
                 IMPORT  __main
                 LDR     R0, =SystemInit
                 BLX     R0
                 LDR     R0, =__main
                 BX      R0
                 ENDP

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

NMI_Handler     PROC
                EXPORT  NMI_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

Default_Handler PROC

                EXPORT  I2C_Handler                [WEAK]
                EXPORT  HSC_Handler                [WEAK]
                EXPORT  UART_Handler               [WEAK]
                EXPORT  WWDT_Handler               [WEAK]
                EXPORT  TMR0_Handler               [WEAK]
                EXPORT  TMR1_Handler               [WEAK]
                EXPORT  CADC_Handler               [WEAK]
                EXPORT  VADC_Handler               [WEAK]
                EXPORT  FLASH_Handler              [WEAK]
                EXPORT  WUPT_Handler               [WEAK]
                EXPORT  I2C_STA_Handler            [WEAK]
                EXPORT  EINT0_Handler              [WEAK]
                EXPORT  EINT1_Handler              [WEAK]
                EXPORT  EINT2_Handler              [WEAK]
                EXPORT  SHA256_Handler             [WEAK]


I2C_Handler
HSC_Handler
UART_Handler
WWDT_Handler
TMR0_Handler
TMR1_Handler
CADC_Handler
VADC_Handler
FLASH_Handler
WUPT_Handler
I2C_STA_Handler
EINT0_Handler
EINT1_Handler
EINT2_Handler
SHA256_Handler

                B       .

                ENDP

                ALIGN

; 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
