找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 3115|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

LPC1767走馬燈

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:109915 發(fā)表于 2016-3-21 08:56 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
#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)
{

}

}

評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表