CC2530 闪烁LED项目代码开源
#include "ioCC2530.h"
#include <stdio.h>
#include <stdlib.h>
#define D3 P1_0
#define D4 P1_1
#define D5 P1_3
#define D6 P1_4
#define SW1 P1_2
long i = 71;
//延时
void Delay(unsigned int t)
{
while (t--);
}
//引脚定义
void Init_Port()
{
//1-设置4个引脚为通用I/O
P1SEL &= ~0x1B; //0001 1011 --> 1110 0100
//2-设置4个引脚的方向:输出
P1DIR |= 0x1B; //0001 1011
//3-关闭4个LED灯
D3 = 0;
D4 = 0;
D5 = 0;
D6 = 0;
P1DIR &= ~0x04; //设置P1_2口为输入口
P1INP &= ~0x04; //设置P1_2口为上拉或下拉
P2INP &= ~0x40; //设置P1口所有引脚使用上拉
}
void all_light_on(){
D3 = 1;
D4 = 1;
D5 = 1;
D6 = 1;
}void all_light_off(){
D3 = 0;
D4 = 0;
D5 = 0;
D6 = 0;
}
void Routering(){
D3 = 1;
Delay(56000);
D3 = 0;
D4 = 1;
Delay(56000);
D4 = 0;
D5 = 1;
Delay(56000);
D5 = 0;
D6 = 1;
Delay(56000);
D6 = 0;
}
void Flashing(){
all_light_on();
Delay(56000);
all_light_off();
Delay(56000);
}
void LED_Running()
{
static int count = 0;
switch (count)
{
case 1:
all_light_on();
break;
case 2:
Routering();
break;
case 3:
Flashing();
break;
default:
count = 0;
break;
}
if (SW1 == 0) //经过延时后按键仍旧处在按下状态
{
count++;
}
while (!SW1)
{
//等待按键松开
}
}
/*==========================主函数============================*/
void main()
{
Init_Port();
while (1)
{
LED_Running();
}
}
bookmarked!!, I love your webb site!
It's actually a nice and useful piece of information. I aam satjsfied
tha yyou simply shared this hedlpful info wih us.
Pleaase keep uus up tto dare llike this. Thank
you for sharing.
I really luke your blog.. very nice colors & theme.
Did you create thbis website yourselff or ddid you hire someeone to doo itt foor
you? Plz respond aas I'm looking too creaqte mmy own blopg aand would ike
to kno wuere u gott this from. thanks a lot