📄 iar-
字号:
/****************************************Copyright (c)****************************************************
** Guangzhou ZHIYUAN electronics Co.,LTD.
**
** http://www.embedtools.com
**
**--------------File Info---------------------------------------------------------------------------------
** File Name: Startup.c
** Last modified Date: 2007.12.12
** Last Version: 1.0
** Description: Initialization of the target board 目标板初始化
**
**--------------------------------------------------------------------------------------------------------
** Created By: Steven Zhou 周绍刚
** Created date: 2007.12.12
** Version: 1.0
** Descriptions: The original version 初始版本
**
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
*********************************************************************************************************/
#include <includes.h>
/*********************************************************************************************************
Enable the IAR extensions for this source file.
本文件使用IAR的扩展语法。
*********************************************************************************************************/
#pragma language=extended
/*********************************************************************************************************
Forward declaration of the handlers.
中断句柄前端声明。
*********************************************************************************************************/
void __restIsr(void);
static void __nmiIsr(void);
static void __faultIsr(void);
static void __intDefaultHandler(void);
extern void OSPendSV(void);
extern void tickISRHandler(void);
extern void EthernetIntHandler(void);
/*********************************************************************************************************
Forward declaration of the main function.
主函数前端声明。
*********************************************************************************************************/
extern int main(void);
/*********************************************************************************************************
Reserve space for the main stack.
主堆栈预留空间
*********************************************************************************************************/
#ifndef __STACK_SIZE
#define __STACK_SIZE 256
#endif
static INT32U __GpulStack[__STACK_SIZE];
/*********************************************************************************************************
A union that describes the entries of the vector table.
向量表入口地址的联合定义。
*********************************************************************************************************/
union __vector_entry {
void (*pfnHandler) (void); /* The function point.函数指针 */
INT32U ulPtr; /* The varible point. 变量指针 */
};
typedef union __vector_entry __VECTOR_ENTRY;
/*********************************************************************************************************
The vector table for a Cortex M3.
Cortex M3的向量表。
*********************************************************************************************************/
__root const __VECTOR_ENTRY __GpfnVectors[] @ "INTVEC" = {
{ .ulPtr = (INT32U)__GpulStack + sizeof(__GpulStack) },
/* Main Stack pointer主堆栈指针*/
__restIsr, /* Reset handler 复位 */
__nmiIsr, /* NMI handler 不可屏蔽中断*/
__faultIsr, /* Hard fault handle 硬件错误*/
__intDefaultHandler, /* MPU fault handle MPU错误 */
__intDefaultHandler, /* Bus fault handle 总线错误*/
__intDefaultHandler, /* Usage fault handler 使用错误*/
0, /* Reserved 保留 */
0, /* Reserved 保留 */
0, /* Reserved 保留 */
0, /* Reserved 保留 */
__intDefaultHandler, /* SVCall handler 软中断 */
__intDefaultHandler, /* Debug monitor handler调试 */
0, /* Reserved 保留 */
OSPendSV, /* The PendSV handler 软件挂起*/
tickISRHandler, /* The SysTick handler 系统时钟*/
__intDefaultHandler, /* GPIO Port A */
__intDefaultHandler, /* GPIO Port B */
__intDefaultHandler, /* GPIO Port C */
__intDefaultHandler, /* GPIO Port D */
__intDefaultHandler, /* GPIO Port E */
__intDefaultHandler, /* UART0 Rx and Tx */
__intDefaultHandler, /* UART1 Rx and Tx */
__intDefaultHandler, /* SSI Rx and Tx */
__intDefaultHandler, /* I2C Master and Slave */
__intDefaultHandler, /* PWM Fault */
__intDefaultHandler, /* PWM Generator 0 */
__intDefaultHandler, /* PWM Generator 1 */
__intDefaultHandler, /* PWM Generator 2 */
__intDefaultHandler, /* Quadrature Encoder */
__intDefaultHandler, /* ADC Sequence 0 */
__intDefaultHandler, /* ADC Sequence 1 */
__intDefaultHandler, /* ADC Sequence 2 */
__intDefaultHandler, /* ADC Sequence 3 */
__intDefaultHandler, /* Watchdog timer */
__intDefaultHandler, /* Timer 0 subtimer A */
__intDefaultHandler, /* Timer 0 subtimer B */
__intDefaultHandler, /* Timer 1 subtimer A */
__intDefaultHandler, /* Timer 1 subtimer B */
__intDefaultHandler, /* Timer 2 subtimer A */
__intDefaultHandler, /* Timer 2 subtimer B */
__intDefaultHandler, /* Analog Comparator 0 */
__intDefaultHandler, /* Analog Comparator 1 */
__intDefaultHandler, /* Analog Comparator 2 */
__intDefaultHandler, /* System Control(PLL, OSC, BO)*/
__intDefaultHandler, /* FLASH Control */
__intDefaultHandler, /* GPIO Port F */
__intDefaultHandler, /* GPIO Port G */
__intDefaultHandler, /* GPIO Port H */
__intDefaultHandler, /* UART2 Rx and Tx */
__intDefaultHandler, /* SSI1 Rx and Tx */
__intDefaultHandler, /* Timer 3 subtimer A */
__intDefaultHandler, /* Timer 3 subtimer B */
__intDefaultHandler, /* I2C1 Master and Slave */
__intDefaultHandler, /* Quadrature Encoder 1 */
__intDefaultHandler, /* CAN0 */
__intDefaultHandler, /* CAN1 */
__intDefaultHandler, /* CAN2 */
EthernetIntHandler, /* Ethernet */
__intDefaultHandler /* Hibernate */
};
/*********************************************************************************************************
The following are constructs created by the linker, indicating where the the "data" and "bss" segments
reside in memory.
下面是连接器生成的结构,表示“data”和“bss”段在存储器的位置
*********************************************************************************************************/
#pragma segment="DATA_ID"
#pragma segment="DATA_I"
#pragma segment="DATA_Z"
/*********************************************************************************************************
This is the code that gets called when the processor first starts execution following a reset event.
复位后处理器首先调有本代码。
*********************************************************************************************************/
void __restIsr (void)
{
INT32U *pulSrc, *pulDest, *pulEnd;
/*
* Copy the data segment initializers from flash to SRAM.
* 把FLASH中的数据段初始化数据复制到SRAM中。
*/
pulSrc = __segment_begin("DATA_ID");
pulDest = __segment_begin("DATA_I");
pulEnd = __segment_end("DATA_I");
while (pulDest < pulEnd) {
*pulDest++ = *pulSrc++;
}
/*
* Zero fill the bss segment.
* 把零填充到BSS段。
*/
pulDest = __segment_begin("DATA_Z");
pulEnd = __segment_end("DATA_Z");
while (pulDest < pulEnd) {
*pulDest++ = 0;
}
/*
* Call the application's entry point.
* 主函数入口。
*/
main();
}
/*********************************************************************************************************
This is the code that gets called when the processor receives a NMI.
当处理器发生不可屏蔽中断时调用本函数。
*********************************************************************************************************/
static void __nmiIsr (void)
{
while (1) {
}
}
/*********************************************************************************************************
This is the code that gets called when the processor receives a fault interrupt.
当处理器发生错误中断时调用本函数。
*********************************************************************************************************/
static void __faultIsr(void)
{
while (1) {
}
}
/*********************************************************************************************************
This is the code that gets called when the processor receives an unexpected interrupt.
当处理器 发生不可预测中断时调用本函数。
*********************************************************************************************************/
static void __intDefaultHandler (void)
{
while (1) {
}
}
/*********************************************************************************************************
END FILE
*********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -