mirror of
https://github.com/QuantumLeaps/qpc.git
synced 2025-02-04 07:13:16 +08:00
309 lines
11 KiB
ArmAsm
309 lines
11 KiB
ArmAsm
;/***************************************************************************/
|
|
; * @file startup_startup_stm32l053xx.s for IAR ARM assembler
|
|
; * @brief CMSIS Cortex-M0+ Core Device Startup File for STM32L053xx.s
|
|
; * @version CMSIS 5.5.1
|
|
; * @date 13 May 2019
|
|
; *
|
|
; * @description
|
|
; * Created from the CMSIS template for the specified device
|
|
; * Quantum Leaps, www.state-machine.com
|
|
; *
|
|
; * @note
|
|
; * The function assert_failed defined at the end of this file defines
|
|
; * the error/assertion handling policy for the application and might
|
|
; * need to be customized for each project. This function is defined in
|
|
; * assembly to re-set the stack pointer, in case it is corrupted by the
|
|
; * time assert_failed is called.
|
|
; *
|
|
; ***************************************************************************/
|
|
;/* Copyright (c) 2012 ARM LIMITED
|
|
;
|
|
; All rights reserved.
|
|
; Redistribution and use in source and binary forms, with or without
|
|
; modification, are permitted provided that the following conditions are met:
|
|
; - Redistributions of source code must retain the above copyright
|
|
; notice, this list of conditions and the following disclaimer.
|
|
; - Redistributions in binary form must reproduce the above copyright
|
|
; notice, this list of conditions and the following disclaimer in the
|
|
; documentation and/or other materials provided with the distribution.
|
|
; - Neither the name of ARM nor the names of its contributors may be used
|
|
; to endorse or promote products derived from this software without
|
|
; specific prior written permission.
|
|
;
|
|
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
; ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
|
|
; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
; POSSIBILITY OF SUCH DAMAGE.
|
|
;---------------------------------------------------------------------------*/
|
|
|
|
MODULE ?cstartup
|
|
|
|
;; Forward declaration of sections.
|
|
SECTION CSTACK:DATA:NOROOT(3)
|
|
|
|
SECTION .intvec:CODE:NOROOT(2)
|
|
|
|
PUBLIC __vector_table
|
|
PUBLIC __Vectors
|
|
PUBLIC __Vectors_End
|
|
PUBLIC __Vectors_Size
|
|
|
|
;******************************************************************************
|
|
; The vector table
|
|
;
|
|
DATA
|
|
__vector_table
|
|
DCD sfe(CSTACK)
|
|
DCD Reset_Handler ; Reset Handler
|
|
DCD NMI_Handler ; NMI Handler
|
|
DCD HardFault_Handler ; Hard Fault Handler
|
|
DCD MemManage_Handler ; The MPU fault handler
|
|
DCD BusFault_Handler ; The bus fault handler
|
|
DCD UsageFault_Handler ; The usage fault handler
|
|
DCD 0 ; Reserved
|
|
DCD 0 ; Reserved
|
|
DCD 0 ; Reserved
|
|
DCD 0 ; Reserved
|
|
DCD SVC_Handler ; SVCall handler
|
|
DCD DebugMon_Handler ; Debug monitor handler
|
|
DCD 0 ; Reserved
|
|
DCD PendSV_Handler ; The PendSV handler
|
|
DCD SysTick_Handler ; The SysTick handler
|
|
|
|
; IRQ handlers...
|
|
DCD WWDG_IRQHandler ; Window Watchdog
|
|
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
|
DCD RTC_IRQHandler ; RTC through EXTI Line
|
|
DCD FLASH_IRQHandler ; FLASH
|
|
DCD RCC_CRS_IRQHandler ; RCC and CRS
|
|
DCD EXTI0_1_IRQHandler ; EXTI Line 0 and 1
|
|
DCD EXTI2_3_IRQHandler ; EXTI Line 2 and 3
|
|
DCD EXTI4_15_IRQHandler ; EXTI Line 4 to 15
|
|
DCD TSC_IRQHandler ; TSC
|
|
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
|
DCD DMA1_Channel2_3_IRQHandler ; DMA1 Channel 2 and Channel 3
|
|
DCD DMA1_Channel4_5_6_7_IRQHandler ; DMA1 Channel 4, 5, 6 and 7
|
|
DCD ADC1_COMP_IRQHandler ; ADC1, COMP1 and COMP2
|
|
DCD LPTIM1_IRQHandler ; LPTIM1
|
|
DCD 0 ; Reserved
|
|
DCD TIM2_IRQHandler ; TIM2
|
|
DCD 0 ; Reserved
|
|
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC
|
|
DCD 0 ; Reserved
|
|
DCD 0 ; Reserved
|
|
DCD TIM21_IRQHandler ; TIM21
|
|
DCD 0 ; Reserved
|
|
DCD TIM22_IRQHandler ; TIM22
|
|
DCD I2C1_IRQHandler ; I2C1
|
|
DCD I2C2_IRQHandler ; I2C2
|
|
DCD SPI1_IRQHandler ; SPI1
|
|
DCD SPI2_IRQHandler ; SPI2
|
|
DCD USART1_IRQHandler ; USART1
|
|
DCD USART2_IRQHandler ; USART2
|
|
DCD RNG_LPUART1_IRQHandler ; RNG and LPUART1
|
|
DCD LCD_IRQHandler ; LCD
|
|
DCD USB_IRQHandler ; USB
|
|
|
|
__Vectors_End
|
|
|
|
__Vectors EQU __vector_table
|
|
__Vectors_Size EQU __Vectors_End - __Vectors
|
|
|
|
;******************************************************************************
|
|
;
|
|
; Weak fault handlers...
|
|
;
|
|
SECTION .text:CODE:REORDER:NOROOT(2)
|
|
|
|
;.............................................................................
|
|
PUBWEAK Reset_Handler
|
|
EXTERN SystemInit
|
|
EXTERN __iar_program_start
|
|
Reset_Handler
|
|
BL SystemInit ; CMSIS system initialization
|
|
BL __iar_program_start ; IAR startup code
|
|
;.............................................................................
|
|
PUBWEAK NMI_Handler
|
|
NMI_Handler
|
|
LDR r0,=str_NMI
|
|
MOVS r1,#1
|
|
B assert_failed
|
|
str_NMI
|
|
DCB "NMI"
|
|
ALIGNROM 2
|
|
;.............................................................................
|
|
PUBWEAK HardFault_Handler
|
|
HardFault_Handler
|
|
LDR r0,=str_HardFault
|
|
MOVS r1,#1
|
|
B assert_failed
|
|
str_HardFault
|
|
DCB "HardFault"
|
|
ALIGNROM 2
|
|
;.............................................................................
|
|
PUBWEAK MemManage_Handler
|
|
MemManage_Handler
|
|
LDR r0,=str_MemManage
|
|
MOVS r1,#1
|
|
B assert_failed
|
|
str_MemManage
|
|
DCB "MemManage"
|
|
ALIGNROM 2
|
|
;.............................................................................
|
|
PUBWEAK BusFault_Handler
|
|
BusFault_Handler
|
|
LDR r0,=str_BusFault
|
|
MOVS r1,#1
|
|
B assert_failed
|
|
str_BusFault
|
|
DCB "BusFault"
|
|
ALIGNROM 2
|
|
;.............................................................................
|
|
PUBWEAK UsageFault_Handler
|
|
UsageFault_Handler
|
|
LDR r0,=str_UsageFault
|
|
MOVS r1,#1
|
|
B assert_failed
|
|
str_UsageFault
|
|
DCB "UsageFault"
|
|
ALIGNROM 2
|
|
|
|
;******************************************************************************
|
|
;
|
|
; Weak non-fault handlers...
|
|
;
|
|
|
|
PUBWEAK SVC_Handler
|
|
SVC_Handler
|
|
LDR r0,=str_SVC
|
|
MOVS r1,#1
|
|
B assert_failed
|
|
str_SVC
|
|
DCB "SVC"
|
|
ALIGNROM 2
|
|
;.............................................................................
|
|
PUBWEAK DebugMon_Handler
|
|
DebugMon_Handler
|
|
LDR r0,=str_DebugMon
|
|
MOVS r1,#1
|
|
B assert_failed
|
|
str_DebugMon
|
|
DCB "DebugMon"
|
|
ALIGNROM 2
|
|
;.............................................................................
|
|
PUBWEAK PendSV_Handler
|
|
PendSV_Handler
|
|
LDR r0,=str_PendSV
|
|
MOVS r1,#1
|
|
B assert_failed
|
|
str_PendSV
|
|
DCB "PendSV"
|
|
ALIGNROM 2
|
|
;.............................................................................
|
|
PUBWEAK SysTick_Handler
|
|
SysTick_Handler
|
|
LDR r0,=str_SysTick
|
|
MOVS r1,#1
|
|
B assert_failed
|
|
str_SysTick
|
|
DCB "SysTick"
|
|
ALIGNROM 2
|
|
|
|
;******************************************************************************
|
|
;
|
|
; Weak IRQ handlers...
|
|
;
|
|
;.............................................................................
|
|
PUBWEAK WWDG_IRQHandler
|
|
PUBWEAK PVD_IRQHandler
|
|
PUBWEAK RTC_IRQHandler
|
|
PUBWEAK FLASH_IRQHandler
|
|
PUBWEAK RCC_CRS_IRQHandler
|
|
PUBWEAK EXTI0_1_IRQHandler
|
|
PUBWEAK EXTI2_3_IRQHandler
|
|
PUBWEAK EXTI4_15_IRQHandler
|
|
PUBWEAK TSC_IRQHandler
|
|
PUBWEAK DMA1_Channel1_IRQHandler
|
|
PUBWEAK DMA1_Channel2_3_IRQHandler
|
|
PUBWEAK DMA1_Channel4_5_6_7_IRQHandler
|
|
PUBWEAK ADC1_COMP_IRQHandler
|
|
PUBWEAK LPTIM1_IRQHandler
|
|
PUBWEAK TIM2_IRQHandler
|
|
PUBWEAK TIM6_DAC_IRQHandler
|
|
PUBWEAK TIM21_IRQHandler
|
|
PUBWEAK TIM22_IRQHandler
|
|
PUBWEAK I2C1_IRQHandler
|
|
PUBWEAK I2C2_IRQHandler
|
|
PUBWEAK SPI1_IRQHandler
|
|
PUBWEAK SPI2_IRQHandler
|
|
PUBWEAK USART1_IRQHandler
|
|
PUBWEAK USART2_IRQHandler
|
|
PUBWEAK RNG_LPUART1_IRQHandler
|
|
PUBWEAK LCD_IRQHandler
|
|
PUBWEAK USB_IRQHandler
|
|
|
|
WWDG_IRQHandler
|
|
PVD_IRQHandler
|
|
RTC_IRQHandler
|
|
FLASH_IRQHandler
|
|
RCC_CRS_IRQHandler
|
|
EXTI0_1_IRQHandler
|
|
EXTI2_3_IRQHandler
|
|
EXTI4_15_IRQHandler
|
|
TSC_IRQHandler
|
|
DMA1_Channel1_IRQHandler
|
|
DMA1_Channel2_3_IRQHandler
|
|
DMA1_Channel4_5_6_7_IRQHandler
|
|
ADC1_COMP_IRQHandler
|
|
LPTIM1_IRQHandler
|
|
TIM2_IRQHandler
|
|
TIM6_DAC_IRQHandler
|
|
TIM21_IRQHandler
|
|
TIM22_IRQHandler
|
|
I2C1_IRQHandler
|
|
I2C2_IRQHandler
|
|
SPI1_IRQHandler
|
|
SPI2_IRQHandler
|
|
USART1_IRQHandler
|
|
USART2_IRQHandler
|
|
RNG_LPUART1_IRQHandler
|
|
LCD_IRQHandler
|
|
USB_IRQHandler
|
|
LDR r0,=str_Undefined
|
|
MOVS r1,#1
|
|
B assert_failed
|
|
str_Undefined
|
|
DCB "Undefined"
|
|
ALIGNROM 2
|
|
|
|
;*****************************************************************************
|
|
; The function assert_failed defines the error/assertion handling policy
|
|
; for the application. After making sure that the stack is OK, this function
|
|
; calls Q_onAssert, which should NOT return (typically reset the CPU).
|
|
;
|
|
; NOTE: the function Q_onAssert should NOT return.
|
|
;
|
|
; The C proptotype of the assert_failed() and Q_onAssert() functions are:
|
|
; void assert_failed(char const *file, int line);
|
|
; void Q_onAssert (char const *file, int line);
|
|
;*****************************************************************************
|
|
PUBLIC assert_failed
|
|
EXTERN Q_onAssert
|
|
assert_failed
|
|
LDR r2,=sfe(CSTACK) ; load the original top of stack
|
|
MOV sp,r2 ; re-set the SP in case of stack overflow
|
|
BL Q_onAssert ; call the application-specific handler
|
|
|
|
B . ; should not be reached, but just in case...
|
|
|
|
|
|
END ; end of module
|
|
|