点对点通信_spp.c.docx

  1. 1、本文档共14页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
点对点通信_spp.c

/******************************************************************************Filename:???? spp.cTarget:?????? cc2430Revised:????? 16/12-2005Revision:???? 1.0******************************************************************************/#include string.h#include cul.h#include stdio.h// protosvoid rxCallBack(void); /*接收回调函数*/void ackTimeout(void); /*应答超时函数*/BOOL ackReceived(BYTE sourceAddress); /*应答接收函数*/void sendAck(SPP_RX_STRUCT* receivedPacket); /*应答发送函数*/void waitForAck(void); /*等待应答函数*/static DMA_DESC* dmaTx;// pointer to the DMA descriptor for transmit.static DMA_DESC* dmaRx; // pointer to the DMA descriptor for receive.static BYTE dmaNumberTx = 0; // number indicating which DMA channel is used for transmit.static BYTE dmaNumberRx = 0; // number indicating which DMA channel is used for receive.static BYTE myAddress;volatile BYTE sppRxStatus = 0;? //spp接收状态volatile BYTE? sppTxStatus = 0; //spp发送状态static BYTE pAckBuffer[7];static SPP_TX_STRUCT* pAckData;static volatile UINT8 retransmissionCounter; //重发的次数static UINT8 ackTimerNumber;static FUNCTION* rxCallBackFunction;//-----------------------------------------------------------------------------// See cul.h for a description of this function./*?This function is used to set a user-specified call-back function?to be run when a correct packet addressed for me is received.*///-----------------------------------------------------------------------------//设置用户指定的回调函数,在接收到一个正确的数据包时运行//通过这个函数可以用程序来改变正确接收数据包后的动作。//callBackFunction 用户指定的函数//rxCallBackFunction 指向 FUNCTION 的全局变量指针变量void sppSetRxCallBackFunction(FUNCTION* callBackFunction){ rxCallBackFunction = callBackFunction;} // Ends sppSetRxCallBackFunction()//发送应答//SPP_RX_STRUCT 定义在 cul.h//SFR(? RFD?????? ,? 0xD9? )?? // RFD: RF Data 定义在ioCC2430.h// myAddress 全局变量// ACK cul.h 中宏定义// ISTXON hal.h 中宏定义// srcAddress 源地址void sendAck(SPP_RX_STRUCT* receivedPacket) //发送应答函数{ RFD = SPP_HEADER_AND_FOOTER_LENGTH + SPP_ACK_LENGTH; RFD = receivedPacket-srcAddress;? //源地址 RFD = my

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档