- /******************** (c) 凯发app官方网站 copyright 2008 stmicroelectronics ********************
- * file name : stm32f10x_vector.c
- * author : mcd application team
- * version : v2.0.3
- * date : 09/22/2008
- * description : stm32f10x vector table for ewarm5.x toolchain.
- * this module performs:
- * - set the initial sp
- * - set the initial pc == __iar_program_start,
- * - set the vector table entries with the exceptions isr address,
- * - configure external sram mounted on stm3210e-eval board
- * to be used as data memory (optional, to be enabled by user)
- * after reset the cortex-m3 processor is in thread mode,
- * priority is privileged, and the stack is set to main.
- ********************************************************************************
- * 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, stmicroelectronics 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 connection with their products.
- *******************************************************************************/
- /* includes ------------------------------------------------------------------*/
- #include "stm32f10x_lib.h"
- #include "stm32f10x_it.h"
- /* private typedef -----------------------------------------------------------*/
- typedef void( *intfunc )( void );
- typedef union { intfunc __fun; void * __ptr; } intvec_elem;
- /* private define ------------------------------------------------------------*/
- /* uncomment the following line if you need to use external sram mounted on
- stm3210e-eval board as data memory */
- /* #define data_in_extsram */
- /* private macro -------------------------------------------------------------*/
- /* private variables ---------------------------------------------------------*/
- /* private function prototypes -----------------------------------------------*/
- /* private functions ---------------------------------------------------------*/
- #pragma language=extended
- #pragma segment="cstack"
- void __iar_program_start( void );
- #pragma location = ".intvec"
- /* stm32f10x vector table entries */
- const intvec_elem __vector_table[] =
- {
- { .__ptr = __sfe( "cstack" ) },
- __iar_program_start,
- nmiexception,
- hardfaultexception,
- memmanageexception,
- busfaultexception,
- usagefaultexception,
- 0, 0, 0, 0, /* reserved */
- svchandler,
- debugmonitor,
- 0, /* reserved */
- pendsvc,
- systickhandler,
- wwdg_irqhandler,
- pvd_irqhandler,
- tamper_irqhandler,
- rtc_irqhandler,
- flash_irqhandler,
- rcc_irqhandler,
- exti0_irqhandler,
- exti1_irqhandler,
- exti2_irqhandler,
- exti3_irqhandler,
- exti4_irqhandler,
- dma1_channel1_irqhandler,
- dma1_channel2_irqhandler,
- dma1_channel3_irqhandler,
- dma1_channel4_irqhandler,
- dma1_channel5_irqhandler,
- dma1_channel6_irqhandler,
- dma1_channel7_irqhandler,
- adc1_2_irqhandler,
- usb_hp_can_tx_irqhandler,
- usb_lp_can_rx0_irqhandler,
- can_rx1_irqhandler,
- can_sce_irqhandler,
- exti9_5_irqhandler,
- tim1_brk_irqhandler,
- tim1_up_irqhandler,
- tim1_trg_com_irqhandler,
- tim1_cc_irqhandler,
- tim2_irqhandler,
- tim3_irqhandler,
- tim4_irqhandler,
- i2c1_ev_irqhandler,
- i2c1_er_irqhandler,
- i2c2_ev_irqhandler,
- i2c2_er_irqhandler,
- spi1_irqhandler,
- spi2_irqhandler,
- usart1_irqhandler,
- usart2_irqhandler,
- usart3_irqhandler,
- exti15_10_irqhandler,
- rtcalarm_irqhandler,
- usbwakeup_irqhandler,
- tim8_brk_irqhandler,
- tim8_up_irqhandler,
- tim8_trg_com_irqhandler,
- tim8_cc_irqhandler,
- adc3_irqhandler,
- fsmc_irqhandler,
- sdio_irqhandler,
- tim5_irqhandler,
- spi3_irqhandler,
- uart4_irqhandler,
- uart5_irqhandler,
- tim6_irqhandler,
- tim7_irqhandler,
- dma2_channel1_irqhandler,
- dma2_channel2_irqhandler,
- dma2_channel3_irqhandler,
- dma2_channel4_5_irqhandler,
- };
- #ifdef data_in_extsram
- #pragma language=extended
- __interwork int __low_level_init(void);
- #pragma location="icode"
- __interwork int __low_level_init(void)
- {
- /* fsmc bank1 nor/sram3 is used for the stm3210e-eval, if another bank is
- required, then adjust the register addresses*/
- /* enable fsmc clock */
- *(vu32 *)0x40021014 = 0x00000114;
- /* enable gpiod, gpioe, gpiof and gpiog clocks */
- *(vu32 *)0x40021018 = 0x000001e0;
- /* --------------- sram data lines, noe and nwe configuration ---------------*/
- /*---------------- sram address lines configuration -------------------------*/
- /*---------------- noe and nwe configuration --------------------------------*/
- /*---------------- ne3 configuration ----------------------------------------*/
- /*---------------- nbl0, nbl1 configuration ---------------------------------*/
- *(vu32 *)0x40011400 = 0x44bb44bb;
- *(vu32 *)0x40011404 = 0xbbbbbbbb;
- *(vu32 *)0x40011800 = 0xb44444bb;
- *(vu32 *)0x40011804 = 0xbbbbbbbb;
- *(vu32 *)0x40011c00 = 0x44bbbbbb;
- *(vu32 *)0x40011c04 = 0xbbbb4444;
- *(vu32 *)0x40012000 = 0x44bbbbbb;
- *(vu32 *)0x40012004 = 0x44444b44;
- /*---------------- fsmc configuration ---------------------------------------*/
- /*---------------- enable fsmc bank1_sram bank ------------------------------*/
- *(vu32 *)0xa0000010 = 0x00001011;
- *(vu32 *)0xa0000014 = 0x00000200;
- return (1);
- }
- #endif /*data_in_extsram*/
- /******************* (c) 凯发app官方网站 copyright 2008 stmicroelectronics *****end of file****/
typedef void( *intfunc )( void );
定义一个新类型,这个类型是一个函数指针,指针指向的函数类型是void (void)型,
符合标准c
typedef union { intfunc __fun; void * __ptr; } intvec_elem;
定义一个新类型,这个类型是一个联合体,联合体有两个元素,一个元素类型是intfunc,一个元素类型是void *
符合标准c
#pragma language=extended
#pragma segment="cstack"
void __iar_program_start( void );
申明外部函数,extern可以用,也可以不用
符合标准c
#pragma location = ".intvec" // 下面的变量存放在段 .intvec
//iar扩展
/* stm32f10x vector table entries */
const intvec_elem __vector_table[] =
{
{ .__ptr = __sfe( "cstack" ) },
// { .__ptr = 常量 },
// 数组元素是联合体,联合体有两个元素,对联合体元素__ptr赋初值
//符合标准c
//__sfe( "cstack" ) 是段cstack的尾地址,更准确是段cstack下一个段的首地址(记忆中应该是这样)。
//iar扩展
__iar_program_start,
//数组元素是联合体,联合体有两个元素,对联合体第一个元素__fun赋初值
//完整的写法是 { .__fun= __iar_program_start },
//这里简写成__iar_program_start,是否符合标准c,有待考证
.....
}
}
补充:
对联合体第一个元素赋初值,可以简写。
{ .__fun= __iar_program_start },
//__fun是联合体第一个元素,可直接简写成__iar_program_start.
//符合标准c
__sfe是iar的“段操作符”segment operator。表示取某个段的后一个字节的地址。
比如"cstack"定义为0x20001000~0x20001fff。那__sfe( "cstack" ) 就得到0x20002000这个值,刚好用来初始化msp堆栈指针。
注意使用segment operator前,需要先定义段名如下:
#pragma segment="cstack"
阅读(5119) | 评论(0) | 转发(0) |