cpu/stm32f0: optimization of startup code
- make use of common startup code - make use of common exception handlers - renamed startup.c to vectors.c
This commit is contained in:
parent
aa583f254d
commit
f30b7bf13d
@ -1,188 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser General
|
||||
* Public License v2.1. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup cpu_stm32f0
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Startup code and interrupt vector definition
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "panic.h"
|
||||
|
||||
/**
|
||||
* memory markers as defined in the linker script
|
||||
*/
|
||||
extern uint32_t _sfixed;
|
||||
extern uint32_t _efixed;
|
||||
extern uint32_t _etext;
|
||||
extern uint32_t _srelocate;
|
||||
extern uint32_t _erelocate;
|
||||
extern uint32_t _szero;
|
||||
extern uint32_t _ezero;
|
||||
extern uint32_t _sstack;
|
||||
extern uint32_t _estack;
|
||||
|
||||
/**
|
||||
* @brief functions for initializing the board, std-lib and kernel
|
||||
*/
|
||||
extern void board_init(void);
|
||||
extern void kernel_init(void);
|
||||
extern void __libc_init_array(void);
|
||||
|
||||
/**
|
||||
* @brief This function is the entry point after a system reset
|
||||
*
|
||||
* After a system reset, the following steps are necessary and carried out:
|
||||
* 1. load data section from flash to ram
|
||||
* 2. overwrite uninitialized data section (BSS) with zeros
|
||||
* 3. initialize the newlib
|
||||
* 4. initialize the board (sync clock, setup std-IO)
|
||||
* 5. initialize and start RIOTs kernel
|
||||
*/
|
||||
void reset_handler(void)
|
||||
{
|
||||
uint32_t *dst;
|
||||
uint32_t *src = &_etext;
|
||||
|
||||
/* load data section from flash to ram */
|
||||
for (dst = &_srelocate; dst < &_erelocate; ) {
|
||||
*(dst++) = *(src++);
|
||||
}
|
||||
|
||||
/* default bss section to zero */
|
||||
for (dst = &_szero; dst < &_ezero; ) {
|
||||
*(dst++) = 0;
|
||||
}
|
||||
|
||||
/* initialize the board and startup the kernel */
|
||||
board_init();
|
||||
/* initialize std-c library (this should be done after board_init) */
|
||||
__libc_init_array();
|
||||
/* startup the kernel */
|
||||
kernel_init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Default handler is called in case no interrupt handler was defined
|
||||
*/
|
||||
void dummy_handler(void)
|
||||
{
|
||||
core_panic(PANIC_DUMMY_HANDLER, "DUMMY HANDLER");
|
||||
}
|
||||
|
||||
void isr_nmi(void)
|
||||
{
|
||||
core_panic(PANIC_NMI_HANDLER, "NMI HANDLER");
|
||||
}
|
||||
|
||||
void isr_hard_fault(void)
|
||||
{
|
||||
core_panic(PANIC_HARD_FAULT, "HARD FAULT");
|
||||
}
|
||||
|
||||
/* Cortex-M specific interrupt vectors */
|
||||
void isr_svc(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_pendsv(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_systick(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
|
||||
/* STM32F051R8 specific interrupt vector */
|
||||
void isr_wwdg(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_pvd(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_rtc(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_flash(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_rcc(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_exti0_1(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_exti2_3(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_exti4_15(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_ts(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_dma1_ch1(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_dma1_ch2_3(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_dma1_ch4_5(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_adc1_comp(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_tim1_brk_up_trg_com(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_tim1_cc(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_tim2(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_tim3(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_tim6_dac(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_tim7(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_tim14(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_tim15(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_tim16(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_tim17(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_i2c1(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_i2c2(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_spi1(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_spi2(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_usart1(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_usart2(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_usart3_8(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
void isr_cec(void) __attribute__ ((weak, alias("dummy_handler")));
|
||||
|
||||
/* interrupt vector table */
|
||||
__attribute__ ((section(".vectors")))
|
||||
const void *interrupt_vector[] = {
|
||||
/* Stack pointer */
|
||||
(void*) (&_estack), /* pointer to the top of the empty stack */
|
||||
/* Cortex-M handlers */
|
||||
(void*) reset_handler, /* entry point of the program */
|
||||
(void*) isr_nmi, /* non maskable interrupt handler */
|
||||
(void*) isr_hard_fault, /* if you end up here its not good */
|
||||
(void*) (0UL), /* reserved */
|
||||
(void*) (0UL), /* reserved */
|
||||
(void*) (0UL), /* reserved */
|
||||
(void*) (0UL), /* reserved */
|
||||
(void*) (0UL), /* reserved */
|
||||
(void*) (0UL), /* reserved */
|
||||
(void*) (0UL), /* reserved */
|
||||
(void*) isr_svc, /* system call interrupt */
|
||||
(void*) (0UL), /* reserved */
|
||||
(void*) (0UL), /* reserved */
|
||||
(void*) isr_pendsv, /* pendSV interrupt, used for task switching in RIOT */
|
||||
(void*) isr_systick, /* SysTick interrupt, not used in RIOT */
|
||||
/* STM specific peripheral handlers */
|
||||
(void*) isr_wwdg, /* windowed watchdog */
|
||||
(void*) isr_pvd, /* power control */
|
||||
(void*) isr_rtc, /* real time clock */
|
||||
(void*) isr_flash, /* flash memory controller */
|
||||
(void*) isr_rcc, /* reset and clock control */
|
||||
(void*) isr_exti0_1, /* external interrupt lines 0 and 1 */
|
||||
(void*) isr_exti2_3, /* external interrupt lines 2 and 3 */
|
||||
(void*) isr_exti4_15, /* external interrupt lines 4 to 15 */
|
||||
(void*) isr_ts, /* touch sensing input*/
|
||||
(void*) isr_dma1_ch1, /* direct memory access controller 1, channel 1*/
|
||||
(void*) isr_dma1_ch2_3, /* direct memory access controller 1, channel 2 and 3*/
|
||||
(void*) isr_dma1_ch4_5, /* direct memory access controller 1, channel 4 and 5*/
|
||||
(void*) isr_adc1_comp, /* analog digital converter */
|
||||
(void*) isr_tim1_brk_up_trg_com, /* timer 1 break, update, trigger and communication */
|
||||
(void*) isr_tim1_cc, /* timer 1 capture compare */
|
||||
(void*) isr_tim2, /* timer 2 */
|
||||
(void*) isr_tim3, /* timer 3 */
|
||||
(void*) isr_tim6_dac, /* timer 6 and digital to analog converter */
|
||||
(void*) isr_tim7, /* timer 7 */
|
||||
(void*) isr_tim14, /* timer 14 */
|
||||
(void*) isr_tim15, /* timer 15 */
|
||||
(void*) isr_tim16, /* timer 16 */
|
||||
(void*) isr_tim17, /* timer 17 */
|
||||
(void*) isr_i2c1, /* I2C 1 */
|
||||
(void*) isr_i2c2, /* I2C 2 */
|
||||
(void*) isr_spi1, /* SPI 1 */
|
||||
(void*) isr_spi2, /* SPI 2 */
|
||||
(void*) isr_usart1, /* USART 1 */
|
||||
(void*) isr_usart2, /* USART 2 */
|
||||
(void*) isr_usart3_8, /* USART 3 to 8 */
|
||||
(void*) isr_cec, /* consumer electronics control */
|
||||
(void*) (0UL) /* reserved */
|
||||
};
|
||||
125
cpu/stm32f0/vectors.c
Normal file
125
cpu/stm32f0/vectors.c
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (C) 2014-2015 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser General
|
||||
* Public License v2.1. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup cpu_stm32f0
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Interrupt vector definitions
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "vectors_cortexm.h"
|
||||
|
||||
/* get the start of the ISR stack as defined in the linkerscript */
|
||||
extern uint32_t _estack;
|
||||
|
||||
/* define a local dummy handler as it needs to be in the same compilation unit
|
||||
* as the alias definition */
|
||||
void dummy_handler(void) {
|
||||
dummy_handler_default();
|
||||
}
|
||||
|
||||
/* Cortex-M common interrupt vectors */
|
||||
WEAK_DEFAULT void isr_svc(void);
|
||||
WEAK_DEFAULT void isr_pendsv(void);
|
||||
WEAK_DEFAULT void isr_systick(void);
|
||||
/* STM32F0 specific interrupt vectors */
|
||||
WEAK_DEFAULT void isr_wwdg(void);
|
||||
WEAK_DEFAULT void isr_pvd(void);
|
||||
WEAK_DEFAULT void isr_rtc(void);
|
||||
WEAK_DEFAULT void isr_flash(void);
|
||||
WEAK_DEFAULT void isr_rcc(void);
|
||||
WEAK_DEFAULT void isr_exti0_1(void);
|
||||
WEAK_DEFAULT void isr_exti2_3(void);
|
||||
WEAK_DEFAULT void isr_exti4_15(void);
|
||||
WEAK_DEFAULT void isr_ts(void);
|
||||
WEAK_DEFAULT void isr_dma1_ch1(void);
|
||||
WEAK_DEFAULT void isr_dma1_ch2_3(void);
|
||||
WEAK_DEFAULT void isr_dma1_ch4_5(void);
|
||||
WEAK_DEFAULT void isr_adc1_comp(void);
|
||||
WEAK_DEFAULT void isr_tim1_brk_up_trg_com(void);
|
||||
WEAK_DEFAULT void isr_tim1_cc(void);
|
||||
WEAK_DEFAULT void isr_tim2(void);
|
||||
WEAK_DEFAULT void isr_tim3(void);
|
||||
WEAK_DEFAULT void isr_tim6_dac(void);
|
||||
WEAK_DEFAULT void isr_tim7(void);
|
||||
WEAK_DEFAULT void isr_tim14(void);
|
||||
WEAK_DEFAULT void isr_tim15(void);
|
||||
WEAK_DEFAULT void isr_tim16(void);
|
||||
WEAK_DEFAULT void isr_tim17(void);
|
||||
WEAK_DEFAULT void isr_i2c1(void);
|
||||
WEAK_DEFAULT void isr_i2c2(void);
|
||||
WEAK_DEFAULT void isr_spi1(void);
|
||||
WEAK_DEFAULT void isr_spi2(void);
|
||||
WEAK_DEFAULT void isr_usart1(void);
|
||||
WEAK_DEFAULT void isr_usart2(void);
|
||||
WEAK_DEFAULT void isr_usart3_8(void);
|
||||
WEAK_DEFAULT void isr_cec(void);
|
||||
|
||||
/* interrupt vector table */
|
||||
ISR_VECTORS const void *interrupt_vector[] = {
|
||||
/* Exception stack pointer */
|
||||
(void*) (&_estack), /* pointer to the top of the stack */
|
||||
/* Cortex-M0 handlers */
|
||||
(void*) reset_handler_default, /* entry point of the program */
|
||||
(void*) nmi_default, /* non maskable interrupt handler */
|
||||
(void*) hard_fault_default, /* hard fault exception */
|
||||
(void*) (0UL), /* reserved */
|
||||
(void*) (0UL), /* reserved */
|
||||
(void*) (0UL), /* reserved */
|
||||
(void*) (0UL), /* reserved */
|
||||
(void*) (0UL), /* reserved */
|
||||
(void*) (0UL), /* reserved */
|
||||
(void*) (0UL), /* reserved */
|
||||
(void*) isr_svc, /* system call interrupt, in RIOT used for
|
||||
* switching into thread context on boot */
|
||||
(void*) (0UL), /* reserved */
|
||||
(void*) (0UL), /* reserved */
|
||||
(void*) isr_pendsv, /* pendSV interrupt, in RIOT the actual
|
||||
* context switching is happening here */
|
||||
(void*) isr_systick, /* SysTick interrupt, not used in RIOT */
|
||||
/* STM specific peripheral handlers */
|
||||
(void*) isr_wwdg, /* windowed watchdog */
|
||||
(void*) isr_pvd, /* power control */
|
||||
(void*) isr_rtc, /* real time clock */
|
||||
(void*) isr_flash, /* flash memory controller */
|
||||
(void*) isr_rcc, /* reset and clock control */
|
||||
(void*) isr_exti0_1, /* external interrupt lines 0 and 1 */
|
||||
(void*) isr_exti2_3, /* external interrupt lines 2 and 3 */
|
||||
(void*) isr_exti4_15, /* external interrupt lines 4 to 15 */
|
||||
(void*) isr_ts, /* touch sensing input*/
|
||||
(void*) isr_dma1_ch1, /* direct memory access controller 1, channel 1*/
|
||||
(void*) isr_dma1_ch2_3, /* direct memory access controller 1, channel 2 and 3*/
|
||||
(void*) isr_dma1_ch4_5, /* direct memory access controller 1, channel 4 and 5*/
|
||||
(void*) isr_adc1_comp, /* analog digital converter */
|
||||
(void*) isr_tim1_brk_up_trg_com, /* timer 1 break, update, trigger and communication */
|
||||
(void*) isr_tim1_cc, /* timer 1 capture compare */
|
||||
(void*) isr_tim2, /* timer 2 */
|
||||
(void*) isr_tim3, /* timer 3 */
|
||||
(void*) isr_tim6_dac, /* timer 6 and digital to analog converter */
|
||||
(void*) isr_tim7, /* timer 7 */
|
||||
(void*) isr_tim14, /* timer 14 */
|
||||
(void*) isr_tim15, /* timer 15 */
|
||||
(void*) isr_tim16, /* timer 16 */
|
||||
(void*) isr_tim17, /* timer 17 */
|
||||
(void*) isr_i2c1, /* I2C 1 */
|
||||
(void*) isr_i2c2, /* I2C 2 */
|
||||
(void*) isr_spi1, /* SPI 1 */
|
||||
(void*) isr_spi2, /* SPI 2 */
|
||||
(void*) isr_usart1, /* USART 1 */
|
||||
(void*) isr_usart2, /* USART 2 */
|
||||
(void*) isr_usart3_8, /* USART 3 to 8 */
|
||||
(void*) isr_cec, /* consumer electronics control */
|
||||
(void*) (0UL) /* reserved */
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user