基于51的CC1101接收程序 下载本文

的数据

*length = packetLength; //把接收数据长度的修改为当前数据的长度

// Read the 2 appended status bytes (status[0] = RSSI, status[1] = LQI) halSpiReadBurstReg(CCxxx0_RXFIFO, status, 2); //读出CRC校验位 halSpiStrobe(CCxxx0_SFRX); //清洗接收缓冲区 return (status[1] & CRC_OK); //如果校验成功返回接收成功 } else {

*length = packetLength;

halSpiStrobe(CCxxx0_SFRX); //清洗接收缓冲区 return 0; } } else return 0; } /*

void Delay(unsigned int s) { unsigned int i; for(i=0; i

void main(void) {

INT8U leng =0; INT8U PaTabel[8] = {0x60 ,0x60 ,0x60 ,0x60 ,0x60 ,0x60 ,0x60 ,0x60}; INT8U RxBuf[8]={0}; CpuInit(); POWER_UP_RESET_CC1100(); halRfWriteRfSettings(); halSpiWriteBurstReg(CCxxx0_PATABLE, PaTabel, 8); while(1) {

leng =8; // 预计接受10 bytes if(halRfReceivePacket(RxBuf,&leng)) { if(RxBuf[0]==0xff) {

}

} }

led0=0; led1=0; led2=0; }

if(RxBuf[0]==0xaa) {

led0=1; led1=1; led2=1; }