找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2363|回复: 0
打印 上一主题 下一主题
收起左侧

LPC1767走马灯

[复制链接]
跳转到指定楼层
楼主
ID:109915 发表于 2016-3-21 08:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#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)
{

}

}

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表