main.c
来自「利用zigbee进行定位的程序」· C语言 代码 · 共 111 行
C
111 行
//----------------------------------------------------//
//-------Institute Of Computing Technology-----------//
//------------Chinese Academic Science---------------//
//-----中国科学院计算技术研究所先进测试技术实验室-----//
//----------------------------------------------------//
/**
* www.wsn.net.cn
* @copyright:nbicc_lpp
* @data:2005.11.22
* @version:0.0.1
* @updata:$
*
*/
#include "top.h"
#include "generic.h"
//--------------------------------------------------------
//--------------------------------------------------------
//---------------------------------------------------------------
inline uint8_t hardwareInit(void)
{ OS_SET_PIN_DIRECTIONS();
return SUCCESS;}
//---------------------------------------------------------
int main(void)
{
hardwareInit();
Leds_greenOn();
Leds_redOn();
Leds_yellowOn();
IoInit();
OS_sched_init();
cc2420_init();
os_atomic_enable_interrupt();
//-------------------------------------------------
//init rssi and payload var
//-------------------------------------------------
isready=0;
tend=0;
payload=0;
pagenum=0;
testnum=0;
for (int i=0;i<1003;i++)
{
rssi[i]=0;
}
prssi=rssi;
//-------------------------------------------------
//some test for extflash
//-------------------------------------------------
extflash_ini();
for (int i=0;i<264;i++)
{
test[i]=0;
}
Main_Memory_PageRead(0, 0x0000, test, 264);//read the content of a page
while(!(Status_Register_Get()&0x80));
//-----------------
if ((test[0]!=0xff)&&1)
{
printf("\nflash is not empty!test[0]is %02x\n",test[0]);
}
else
{
for (int i=0;i<1024;i++)
{
PageErase(i);
while(!(Status_Register_Get()&0x80));
}
printf("\nflash is empty!");
}
Timer3_set_flag=100;
Timer3_sethalfsymbol(2000);
demopacket=malloc(sizeof(demo_datapacket));
demopacket->length=0x0f;
demopacket->fcf=0x8841;
demopacket->dsn=0x01;
demopacket->address.destination_pan=0x0004;
demopacket->address.destination_address=0x0004;
demopacket->address.source_pan=0x0002;//change 0x0001 to 0x0002
demopacket->address.source_address=0x0002;
cc2420_setchnl(1);
cc2420_setrxmode();
cc2420_enableAddrDecode();
cc2420_setpanid(0x0002);
cc2420_setshortaddress(0x0002);
cc2420_enablefifop();
Leds_greenOn();
Leds_redOff();
Leds_yellowOn();
while(1) {
OS_run_task();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?