欢迎来到天天文库
浏览记录
ID:38807526
大小:62.66 KB
页数:6页
时间:2019-06-19
《点对点通信_radio.c》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、/******************************************************************************Filename: radio.cTarget: cc2430Revised: 16/12-2005Revision: 1.0******************************************************************************/#include"cul.h
2、"externvolatileBYTEsppRxStatus;externvolatileBYTEsppTxStatus;__no_initSPP_RX_STRUCTrxData@"PM0_XDATA"; //rxData__no_initSPP_TX_STRUCTtxData@"PM0_XDATA"; //txData/*typedefstruct{ BYTEpayloadLength; BYTEdestAddress; BYTEflags; BYTE*payload;}SPP
3、_TX_STRUCT;typedefstruct{ BYTEpayloadLength; BYTEdestAddress; BYTEsrcAddress; BYTEflags; BYTEpayload[SPP_MAX_PAYLOAD_LENGTH+SPP_FOOTER_LENGTH];}SPP_RX_STRUCT;*///-----------------------------------------------------------------------------/
4、/Seecul.hforadescriptionofthisfunction./*ThisfunctioninitializestheradiobycallingsppInit.Thefrequencyofoperationissetandthisnodesaddressisstored.Theradioissetupforhandlingnon-IEEE802.15.4packets.这个函数初始化radio(运行SPP模式时):设置频率及节点地址。*///------------------
5、-----------------------------------------------------------voidradioInit(UINT32frequency,BYTElocalAddress){ sppInit(frequency,localAddress); return;}//-----------------------------------------------------------------------------//Seecul.hforadescri
6、ptionofthisfunction./*Thisfunctionsendsdataofagivenlengtheithertoaspecifiedrecipient(maybebroadcast)usingtheradio.IfthenumberofbytestobetransferredislargerthanthesizeoftheTXFIFO,thedataissplitoveranadequatenumberofpackets.ThefunctionusestheSPPlibrary
7、.Iftheradioisbusy,orthepacketissentbutnotACK'ed,thetransmissionisretried.Iftheretiresfails,thefunctionreturnsFALSE.IfthepacketisACK'edcorrectlybythereceiver,thefunctionreturnsTRUE.transmitData:指向将被传送的数据。dataLenght:被传送数据的长度。remoteAddress:接收数据包的节点地址。do
8、Ack:设置是否需要应答。*///-----------------------------------------------------------------------------/*contionuousMode()调用的radioSend():res=radioSend(sendBuffer,sizeof(sendBuffer),remoteAddr,DO_NOT_ACK);其中sendBuffer[]="Hello";即为所要发送的数据,transmitData指向sendBuff
此文档下载收益归作者所有