欢迎来到天天文库
浏览记录
ID:14408791
大小:53.50 KB
页数:21页
时间:2018-07-28
《cc2430无线芯片程序》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、CC2430无线芯片程序/******************************************************************************Filename:spp.cTarget:cc2430Revised:16/12-2005Revision:1.0******************************************************************************/#include#include"cul.h"#includ
2、e//protosvoidrxCallBack(void);voidackTimeout(void);BOOLackReceived(BYTEsourceAddress);voidsendAck(SPP_RX_STRUCT*receivedPacket);voidwaitForAck(void);staticDMA_DESC*dmaTx;//pointertotheDMAdescriptorfortransmit.staticDMA_DESC*dmaRx;//pointertotheDMAdescriptorf
3、orreceive.staticBYTEdmaNumberTx=0;//numberindicatingwhichDMAchannelisusedfortransmit.staticBYTEdmaNumberRx=0;//numberindicatingwhichDMAchannelisusedforreceive.staticBYTEmyAddress;volatileBYTEsppRxStatus=0;volatileBYTEsppTxStatus=0;staticBYTEpAckBuffer[7];staticSPP_TX
4、_STRUCT*pAckData;staticvolatileUINT8retransmissionCounter;staticUINT8ackTimerNumber;staticFUNCTION*rxCallBackFunction;//-----------------------------------------------------------------------------//Seecul.hforadescriptionofthisfunction.//----------------------------
5、-------------------------------------------------//设置用户指定的回调函数,在接收到一个正确的数据包死运行//通过这个函数可以用程序来改变正确接收数据包后的动作。//callBackFunction用户指定的函数//rxCallBackFunction指向FUNCTION的全局变量指针变量voidsppSetRxCallBackFunction(FUNCTION*callBackFunction){rxCallBackFunction=callBackFunction;}//En
6、dssppSetRxCallBackFunction()//发送应答//SPP_RX_STRUCT定义在cul.h//SFR(RFD,0xD9)//RFData定义在ioCC2430.h//myAddress全局变量//ACKcul.h中宏定义//ISTXONhal.h中宏定义//srcAddress源地址voidsendAck(SPP_RX_STRUCT*receivedPacket){RFD=SPP_HEADER_AND_FOOTER_LENGTH+SPP_ACK_LENGTH;RFD=receivedPacket->src
7、Address;RFD=myAddress;RFD=ACK;RFD=0;RFIF&=~IRQ_TXDONE;ISTXON;while(!(RFIF&IRQ_TXDONE));return;}//------------------------------------------------------------------------------------------------------//voidrxCallBack(...)////Description://Thisfunctioniscalledbytheinte
8、rruptroutinewhentheRxDMAchannel//finishesthedatatransfer.Thereceivedpacket'sdestinationaddress//ischecked.Ifnotaddressedtothisnode,
此文档下载收益归作者所有