資源簡介
CC2530 測試不同的信道以及信號強度值,可以自己通過按鍵修改信道,無線發射不經過協議棧,代碼量比較小,容易看到,有按鍵中斷串口的配置

代碼片段和文件信息
#include?“ioCC2530.h“
#include?“key.h“
#include?“RF.h“
/****************************
延時函數
*****************************/
void?Delayms(uint?xms)???//i=xms?即延時i毫秒
{
?uint?ij;
?for(i=xms;i>0;i--)
???for(j=587;j>0;j--);
}
/****************************
?????按鍵初始化函數
*****************************/
void?InitKey()
{
??P0SEL?&=?~0X01;????//設置P00為普通IO口??
??P0DIR?&=?~0X01;????//按鍵在P00?口,設置為輸入模式?
??P0INP?&=?~0x01;????//打開P00上拉電阻不影響
?//?P0INP?|=?0X01;????//打開下拉?
}
void?InitLed()
{
????P1DIR?|=??0x07?;????????????????//?P1.2?輸出
????LED1?=?0;
????LED2?=?0;
????LED3?=?0;
}
/****************************
?????按鍵檢測函數
*****************************/
uchar?KeyScan(void)
{
??if(KEY1==0)
??{
????Delayms(20);
??????if(KEY1==0)
??????{
???????//?while(!KEY1);??//松手檢測
????????return?1;??????//有按鍵按下
??????}
??}
??return?0;???????????//無按鍵按下
}
/*延時函數
*****************************/
void?wait(int?xms)???//i=xms?即延時i毫秒
{
?int?ij;
?for(i=xms;i>0;i--)
???for(j=587;j>0;j--);
}
/****************************************************************
???串口初始化函數
****************************************************************/
void?InitUART(void)
{?
????PERCFG?=?0x00; ??????//位置1?P0口
????P0SEL?=?0x0c; ??????//P0_2P0_3用作串口(外部設備功能)
????P0DIR?&=?~0XC0;???????????????????//P0優先作為UART0
????U0CSR?|=?0x80; ??????//設置為UART方式
????U0GCR?|=?11; ???????
????U0BAUD?|=?216; ??????//波特率設為115200
????UTX0IF?=?0;???????????????????????//UART0?TX中斷標志初始置位0
}
/****************************************************************
串口發送字符串函數
****************************************************************/
void?UartSend_String(char?*Dataint?len)
{
??int?j;
??for(j=0;j ??{
????U0DBUF?=?*Data++;
????while(UTX0IF?==?0);
????UTX0IF?=?0;
??}
}
void?Flash_LED(int?RS)
{
??int?S=-RS;
??int?n;
??if(S<10)??n=1;
??else?if(S<20)?n=2;
??else?if(S<30)?n=3;
??else?if(S<40)?n=4;
??else?if(S<50)?n=5;
??else?if(S<60)?n=6;
??else??n=7;
??????
??switch(n)
??{
????case?1:?Flash_Count1=0;Flash_C=1;break;?//100Hz
????case?2:?Flash_Count1=0;Flash_C=2;break;//50Hz
????case?3:?Flash_Count1=0;Flash_C=4;break;//25Kz
????case?4:?Flash_Count1=0;Flash_C=5;break;//20Hz
????case?5:?Flash_Count1=0;Flash_C=10;break;//10Hz
????case?6:?Flash_Count1=0;Flash_C=20;break;//5Hz
????case?7:?Flash_Count1=0;Flash_C=50;break;//2Hz
??}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????57??2013-07-28?11:09??RF_TRX-測信號強度\.hg\00changelog.i
?????文件??????????8??2014-03-27?08:57??RF_TRX-測信號強度\.hg\branch
?????文件?????????92??2013-08-10?09:03??RF_TRX-測信號強度\.hg\cache\branchheads
?????文件?????????92??2013-07-31?21:45??RF_TRX-測信號強度\.hg\cache\branchheads-served
?????文件?????????44??2014-03-27?08:59??RF_TRX-測信號強度\.hg\cache\tags
?????文件??????????0??2014-03-27?08:59??RF_TRX-測信號強度\.hg\cur-message.txt
?????文件????????190??2014-03-27?08:59??RF_TRX-測信號強度\.hg\dirstate
?????文件?????????24??2014-03-27?08:59??RF_TRX-測信號強度\.hg\last-message.txt
?????文件?????????33??2013-07-28?11:09??RF_TRX-測信號強度\.hg\requires
?????文件???????1190??2014-03-27?08:59??RF_TRX-測信號強度\.hg\store\00changelog.i
?????文件????????783??2014-03-27?08:59??RF_TRX-測信號強度\.hg\store\00manifest.i
?????文件???????8425??2014-03-27?08:59??RF_TRX-測信號強度\.hg\store\data\main.c.i
?????文件???????2097??2013-07-28?11:10??RF_TRX-測信號強度\.hg\store\data\_t_r_x.ewd.i
?????文件???????3563??2013-07-28?11:11??RF_TRX-測信號強度\.hg\store\data\_t_r_x.ewp.i
?????文件????????193??2013-07-28?11:11??RF_TRX-測信號強度\.hg\store\data\_t_r_x.eww.i
?????文件?????????64??2013-07-28?11:10??RF_TRX-測信號強度\.hg\store\data\~2ehgignore.i
?????文件????????265??2013-07-28?11:11??RF_TRX-測信號強度\.hg\store\data\~c7~e5~b3~fd~b9~a4~b3~cc.bat.i
?????文件?????????96??2013-07-28?11:11??RF_TRX-測信號強度\.hg\store\fncache
?????文件?????????43??2013-07-28?11:11??RF_TRX-測信號強度\.hg\store\phaseroots
?????文件?????????58??2014-03-27?08:59??RF_TRX-測信號強度\.hg\store\undo
?????文件?????????43??2013-07-31?21:45??RF_TRX-測信號強度\.hg\store\undo.phaseroots
?????文件??????????0??2014-03-27?08:59??RF_TRX-測信號強度\.hg\thgstatus
?????文件??????????0??2013-07-31?21:45??RF_TRX-測信號強度\.hg\undo.bookmarks
?????文件??????????7??2014-03-27?08:59??RF_TRX-測信號強度\.hg\undo.branch
?????文件??????????9??2014-03-27?08:59??RF_TRX-測信號強度\.hg\undo.desc
?????文件????????190??2014-03-27?08:59??RF_TRX-測信號強度\.hg\undo.dirstate
?????文件??????????0??2013-07-28?11:09??RF_TRX-測信號強度\.hgignore
?????文件??????34309??2013-07-27?23:11??RF_TRX-測信號強度\Backup?of?TRX.ewd
?????文件??????56229??2013-07-27?23:11??RF_TRX-測信號強度\Backup?of?TRX.ewp
?????文件??????18864??2017-03-13?16:36??RF_TRX-測信號強度\Debug\Exe\TRX.d51
............此處省略41個文件信息
評論
共有 條評論