标题: LPC1767走马灯 [打印本页]

作者: 978265211    时间: 2016-3-21 08:56
标题: LPC1767走马灯
#include"lpc17xx.h"
#include"cmsis_os.h"
#include"GPIO_LPC17xx.h"
#include"core_cm3.h"
/************ delay function************/


void YIWEI(uint32_t rout)
{
uint32_t i,rout_1;
rout_1=rout;
for(i=0;i<6;i++)
{
  GPIO_PortWrite(2,0x000000ff,rout_1);
  osDelay(1000);
  
  rout_1=~((~rout_1)<<1);
}
}
/*******function body thread_1********/
void Thread_1(void const *arg)
{
uint32_t rout;   //p2 low input
LPC_GPIO2->FIODIR=0x00000fff;     //p2.0~p2.11 out mode

while(1)
{
  /*******************u5***************/
GPIO_PortWrite(2,0x00000fff,0x00000fff);     //init u5,u6,u7,all of the LED are OFF
GPIO_PortWrite(2,0x00000fff,0x000008ff);   //shut u6,u7,and choose u5   
rout=0x000008fb;
YIWEI(rout);   //led_on one by one

/**********************u6******************/
GPIO_PortWrite(2,0x00000fff,0x00000fff);   //init u5,u6,u7,all of the LED are OFF   
rout=0x000004fb;   
GPIO_PortWrite(2,0x00000fff,0x000004ff);   //shut u5,u7,and choose u6
YIWEI(rout);

/******************************************/


/**********************u7******************/
GPIO_PortWrite(2,0x00000fff,0x00000fff);
rout=0x000001fb;
GPIO_PortWrite(2,0x00000fff,0x000001ff);
YIWEI(rout);
}
}
/*******function body thread_2********/
void Thread_2(void const *arg)
{
while(1)
{
  osDelay(500);
}


}
osThreadDef (Thread_1, osPriorityNormal, 1, 0);
osThreadDef (Thread_2, osPriorityNormal, 1, 0);

/*******creat thread function******/


int main(void)
{
SystemInit();//system init function
osThreadCreate (osThread (Thread_1), NULL);
osThreadCreate (osThread (Thread_2), NULL);
while(1)
{

}

}






欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1