資源簡介
基于Zigbee的物聯網遠程控制LED源代碼,CC2530

代碼片段和文件信息
#include?
#include?“./uart/hal_uart.h“
#define?uint?unsigned?int
#define?uchar?unsigned?char
//定義控制燈的端口
#define?LED1?P1_0
#define?LED2?P1_1
/********global?val**********/
char?int_counter?=?0;
/****************************/
void?Delay(uint?n)
{
????uint?it;
????for(i?=?0;i<5;i++)
????for(t?=?0;t }
void?LedInit(void)
{
????P1DIR?|=?0x03;?//設置LED
????LED1?=?1;
????LED2?=?1;
}
/*****************************************
//IO?P1_2中斷模式初始化
*****************************************/
void?InitIrda(void)
{
????//?P1_2?interrupt?io?initialized.
????P1DIR?&=?~(0x01<<2);//P1_2?input?mode
????P1INP?&=?~(0x01<<2);//P1_2?Pull?up
????P1IEN?|=(0x01<<2);//P1_2?int?enable
????PICTL?&=?~(0x01<<1);//P1_2?rasing?edge
????//PICTL?|=?(0x01<<1);?//falling?edge
????IEN0?|=0x80;???//全局允許中斷
????IEN2?|=(0x01<<4);???//P1端口中斷允許
????P1IFG?&=~(0x01<<2);?//?P1_2中斷標志清0
}
/****************************************************************
*函數功能?:主函數
*入口參數?:無
*返?回?值?:無
*說????明?:無
****************************************************************/
void?main(void)
{
????LedInit();
????InitUart();
????InitIrda();
????prints(“http://www.up-tech.com\r\n“);
????while(1)
????{
????????LED2?=?!LED2;
????????Delay(50000);
????????Delay(50000);
????}
}
/*********************************************************************
//中斷服務程序(P1_2端口)
*********************************************************************/
#pragma?vector?=?P1INT_VECTOR
__interrupt?void?P1_ISR(void)
{
????prints(“IRDA?interrupt!\r\n“);
????if((P1IFG&0X04)?>?0)?????????//中斷
????{
??????P1IFG?&=?~(0x04);
??????LED1?=?(int_counter++)%2;
??????Delay(1000);
????}
????P1IF?=?0;??????????//清中斷標志
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄??????????0??2013-11-06?16:53??Exp1
?????目錄??????????0??2013-11-06?16:53??Exp1\Debug
?????目錄??????????0??2013-11-19?15:01??Exp1\Debug\Exe
?????文件??????14887??2013-11-19?15:01??Exp1\Debug\Exe\Exp1.d51
?????目錄??????????0??2013-11-06?16:53??Exp1\Debug\List
?????目錄??????????0??2013-11-19?15:02??Exp1\Debug\Obj
?????文件????????238??2013-11-19?15:01??Exp1\Debug\Obj\Exp1.pbd
?????文件???????9545??2013-11-19?15:01??Exp1\Debug\Obj\hal_uart.r51
?????文件??????10027??2013-11-19?15:01??Exp1\Debug\Obj\main.r51
?????文件???????3141??2013-11-19?15:02??Exp1\Exp1.dep
?????文件??????26857??2011-12-22?11:20??Exp1\Exp1.ewd
?????文件??????53130??2011-12-22?11:21??Exp1\Exp1.ewp
?????文件????????158??2011-12-22?11:20??Exp1\Exp1.eww
?????文件???????1847??2011-12-22?11:24??Exp1\main.c
?????目錄??????????0??2013-11-06?16:53??Exp1\settings
?????文件???????2667??2013-11-19?15:01??Exp1\settings\Exp1.cspy.bat
?????文件???????3313??2013-11-19?15:02??Exp1\settings\Exp1.dbgdt
?????文件????????614??2013-11-19?15:02??Exp1\settings\Exp1.dni
?????文件???????2836??2013-11-19?15:02??Exp1\settings\Exp1.wsdt
?????目錄??????????0??2013-11-19?15:01??Exp1\uart
?????文件??????18833??2009-12-11?11:19??Exp1\uart\hal_board_cfg.h
?????文件???????4969??2008-10-07?14:47??Exp1\uart\hal_defs.h
?????文件???????8101??2009-12-24?10:11??Exp1\uart\hal_mcu.h
?????文件???????4109??2008-03-20?17:17??Exp1\uart\hal_types.h
?????文件???????1910??2011-12-05?13:31??Exp1\uart\hal_uart.c
?????文件???????4468??2011-12-05?13:31??Exp1\uart\hal_uart.h
?????文件???????1869??2010-03-04?22:59??Exp1\uart\wait.c
-----------?---------??----------?-----??----
???????????????173519????????????????????27
............此處省略0個文件信息
- 上一篇:北大青鳥--RSS訂閱系統源碼
- 下一篇:bitcoin_vs2017.zip
評論
共有 條評論