基于mini2440流水灯(裸机代码)

#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++);
 
}

你可能感兴趣的:(嵌入式,arm,我的学习笔记,C语言)