#include "system.h" //包含基本的硬件描述信息
#include "altera_avalon_pio_regs.h" //包含基本的IO寄存器信息
#include "alt_types.h" //Altera定义的数据类型
#include "unistd.h" //延时函数
#define led *(volatile unsigned char *) LED_BASE //定义端口
int main(void)
{
led = 0x02;
alt_u8 dir = 0;
while(1)
{
if(led & 0x81)
{
dir = (dir ^ 0x1);
}
if(dir)
{
led = led >> 1;
}
else
{
led = led << 1;
}
usleep(50000); //延时50000us
}
return 0;
}
用户222124 2009-9-14 08:07
用户188034 2009-9-13 22:04