rfreceivepacket.c
来自「zigbee通信系统中使用芯片cc2430实现点对点通信的源码」· C语言 代码 · 共 62 行
C
62 行
/******************************************************************************
Filename: rfReceivePacket.c
Target: cc2430
Revised: 16/12-2005
Revision: 1.0
******************************************************************************/
#include "hal.h"
BYTE volatile length;
//-----------------------------------------------------------------------------
// See hal.h for a description of this function.
//-----------------------------------------------------------------------------
BYTE halRfReceivePacket(BYTE* pData, BYTE* pRssi, BYTE* pLqi, BYTE timeOut){
BYTE i = 0x00;
ISFLUSHRX; // Making sure that the rX FIFO is empty.
ISFLUSHRX; // Issuing the command twice to reset the SFD.
RFIF &= ~IRQ_FIFOP;
// Turning on RX
ISRXON;
while(!(RFIF & IRQ_FIFOP))
{
if(timeOut)
{
halWait(1);
timeOut--;
}
else
{
return 0;
}
}
length = (RFD & 0x7F);
// Storing packet
for(i=0; i<(length-2); i++){
pData[i] = RFD;
}
*pRssi = RFD;
*pLqi = RFD;
// Last two bytes contain RSSI level and Correlation value in addition to CRC OK.
// Checking that the CRC value is OK
if(*pLqi & 0x80){
return i;
}
else {
return 0;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?