NIOSII编译出现很诡异的问题,求大侠帮帮忙
[复制链接]
最近在学NIOSII编程,参考别人的,写了一个很简单的程序定时器程序,编译老是出错。一直找不出原因,老是出现这个错误
multiple definition of `main'
快疯了。现把程序贴上,求高手指点。
#include"system.h" #include "altera_avalon_timer_regs.h" #include "alt_types.h" #include "sys/alt_irq.h" #define _LED
typedef struct { alt_u32 DATA; alt_u32 DIRECTION; alt_u32 INTERRUPT_MASK; alt_u32 EDGE_CAPTURE; }PIO_STR;
#ifdef _LED #define LED ((PIO_STR*)PIO_LED_BASE) #endif static void timer_init(void); //初始化中断
int main(void) { //初始化Timer timer_init(); while(1); return 0; }
static void ISR_timer1(void *context, alt_u32 id) { //控制流水灯闪烁,一共八个LED int i = 0; LED->DATA = ~(1<<i); i++; if(i == 8) i = 0; //清除Timer中断标志寄存器 IOWR_ALTERA_AVALON_TIMER_STATUS(TIMER1_BASE, 0x00); } void timer_init(void) //初始化中断 { //清除Timer1中断标志寄存器 IOWR_ALTERA_AVALON_TIMER_STATUS(TIMER1_BASE, 0x00); //设置Timer1周期,这里输入的是时钟周期数 IOWR_ALTERA_AVALON_TIMER_PERIODL(TIMER1_BASE,100000000); IOWR_ALTERA_AVALON_TIMER_PERIODH(TIMER1_BASE, 100000000 >> 16); //允许Timer1中断 IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER1_BASE, 0x07); //注册Timer1中断 alt_irq_register(TIMER1_IRQ, (void *)TIMER1_BASE, ISR_timer1); }
|