基于mini2440流水灯(裸机代码)
程序员文章站
2023-11-16 11:59:58
[cpp]
#include "def.h"
#include "option.h" ...
[cpp]
#include "def.h"
#include "option.h"
#include "2440addr.h"
#include "2440lib.h"
#include "2440slib.h"
int system_init(void);
void rdelay(unsigned int x );
int main() //主函数
{
system_init(); //初始化
while(1) //死循环
{
rgpbdat = ~(0xf<<5); //led1-4亮(gpb5-8)=0
rdelay(120);
rgpbdat = ~(0x1<<5); //led1亮 gpb5=0
rdelay(120);
rgpbdat = ~(0x1<<6); //led2亮 gpb6=0
rdelay(120);
rgpbdat = ~(0x1<<7); //led3亮 gpb7=0
rdelay(120);
rgpbdat = ~(0x1<<8); //led4亮 gpb8=0
rdelay(120);
}
return(0);
}
int system_init(void) //初始化函数
{
rgpbcon = 0xd57fc; // gpb5,gpb6,gpb7,gpb8设置为输出
rgpbdat |= ((1<<5)|(1<<6)|(1<<7)|(1<<8)); //使led全灭
}
void rdelay(unsigned int x )
{
unsigned int i,j,k;
for(i=0;i<=x;i++)
for(j=0;j<=0xff;j++)
for(k=0;k<=0xff;k++);
}
#include "def.h"
#include "option.h"
#include "2440addr.h"
#include "2440lib.h"
#include "2440slib.h"
int system_init(void);
void rdelay(unsigned int x );
int main() //主函数
{
system_init(); //初始化
while(1) //死循环
{
rgpbdat = ~(0xf<<5); //led1-4亮(gpb5-8)=0
rdelay(120);
rgpbdat = ~(0x1<<5); //led1亮 gpb5=0
rdelay(120);
rgpbdat = ~(0x1<<6); //led2亮 gpb6=0
rdelay(120);
rgpbdat = ~(0x1<<7); //led3亮 gpb7=0
rdelay(120);
rgpbdat = ~(0x1<<8); //led4亮 gpb8=0
rdelay(120);
}
return(0);
}
int system_init(void) //初始化函数
{
rgpbcon = 0xd57fc; // gpb5,gpb6,gpb7,gpb8设置为输出
rgpbdat |= ((1<<5)|(1<<6)|(1<<7)|(1<<8)); //使led全灭
}
void rdelay(unsigned int x )
{
unsigned int i,j,k;
for(i=0;i<=x;i++)
for(j=0;j<=0xff;j++)
for(k=0;k<=0xff;k++);
}