#include "main.h"
//****************************************IO¶Ë¿Ú¶¨Òå***************************************
sbit SCK =P0^1;
sbit CE =P0^0;
sbit MISO =P0^2;
sbit CSN =P0^3;
sbit MOSI =P0^4;
//sbit IRQ =P1^5;
unsigned char bdata sta; //״̬±êÖ¾
sbit RX_DR =sta^6;
sbit TX_DS =sta^5;
sbit MAX_RT =sta^4;
unsigned char const TX_ADDRESS[TX_ADR_WIDTH]= {0x34,0x43,0x10,0x10,0x01}; //½ÓÊÕµØÖ·
unsigned char const RX_ADDRESS[RX_ADR_WIDTH]= {0x34,0x43,0x10,0x10,0x01}; //±¾µØµØÖ·
unsigned char Rcv_Count = 0;
//*****************************************³¤ÑÓʱ*****************************************
void Delay_n(unsigned int s)
{
unsigned int i;
for(i=0; i<s; i++);
for(i=0; i<s; i++);
}
/******************************************************************************************
/*ÑÓʱº¯Êý
/******************************************************************************************/
void inerDelay_us(unsigned int n)
{
for(;n>0;n--)
_nop_();
}
//****************************************************************************************
/*NRF24L01³õʼ»¯
//***************************************************************************************/
void init_NRF24L01(void)
{
inerDelay_us(10000);//Èç¹ûÉϵç¾ÍÖ´Ðд˳ÌÐò£¬ÔÚÉϵç֮ǰҪµÈ´ý100ms£¬µÈ´ý24L01½øÈëµôµçģʽ
CE=0; // CE ÎÞЧ
CSN=1; // Spi disable
SCK=0; // Spi clock line init high
SPI_RW_Reg(WRITE_REG + CONFIG, 0x0f); // ʹÄÜCRC£¬16λCRC£¬´ò¿ªµçÔ´,½ÓÊÜģʽ
/*
7 6 5 4 3 2 1 0
Reserved MASK_RX_DR MASK_TX_DS MASK_MAX_RT EN_CRC CRCO PWR_UP PRIM_RX
*/
// ÑÓʱһ»á£¬½øÈëStandby-1 ģʽ£¬¿ÉÒÔ²»ÓÃÑÓʱ£¬ÒòΪ¾ÍËãÔÚµôµçģʽÏÂÒ²¿ÉÒÔʹÓÃSPI²Ù×÷¼Ä´æÆ÷
// ¼ÌÐø²Ù×÷¼Ä´æÆ÷£¬24L01»á×Ô¶¯½øÈë Standby-1 ģʽ
//SPI_Write_Buf(WRITE_REG + TX_ADDR, TX_ADDRESS, TX_ADR_WIDTH); // д·¢ËÍ·½µØÖ·
SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, RX_ADDRESS, RX_ADR_WIDTH); // д·¢ËͶ˵ØÖ·
SPI_RW_Reg(WRITE_REG + EN_AA, 0x01); // ƵµÀ0×Ô¶¯ ACKÓ¦´ðÔÊÐí
SPI_RW_Reg(WRITE_REG + EN_RXADDR, 0x01); // ÔÊÐí½ÓÊÕµØÖ·Ö»ÓÐƵµÀ0£¬Èç¹ûÐèÒª¶àƵµÀ¿ÉÒԲο¼Page21
// ´ò¿ªÍ¨µÀ0
//SPI_RW_Reg(WRITE_REG + EN_AA, 0x00);//ʧÄÜͨµÀ0×Ô¶¯Ó¦´ð
//SPI_RW_Reg(WRITE_REG + EN_RXADDR, 0x01); //ʧÄܽÓÊÕͨµÀ0
SPI_RW_Reg(WRITE_REG + RF_CH, 30); // ÉèÖÃÐŵÀ¹¤×÷Ϊ2.4GHZ£¬ÊÕ·¢±ØÐëÒ»ÖÂ
SPI_RW_Reg(WRITE_REG + RX_PW_P0, RX_PLOAD_WIDTH); //ÉèÖýÓÊÕÊý¾Ý³¤¶È£¬±¾´ÎÉèÖÃΪ32×Ö½Ú
SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x07); //ÉèÖ÷¢ÉäËÙÂÊΪ2MHZ£¬·¢É书ÂÊΪ×î´óÖµ0dB
/*
7:5 4 3 2:1 0
Reserved PLL_LOCK RF_DR RF_PWR LNA_HCURR
*/
}
/****************************************************************************************************
/*º¯Êý£ºunsigned char SPI_RW(unsigned char unsigned char)
/*¹¦ÄÜ£ºNRF24L01µÄSPIдʱÐò
/****************************************************************************************************/
unsigned char SPI_RW(unsigned char word)
{
unsigned char bit_ctr;
for(bit_ctr=0;bit_ctr<8;bit_ctr++) // output 8-bit
{
MOSI = (word & 0x80); // ÏÈд×î¸ßλ
word = (word << 1); // ÓÒÒÆһλ
SCK = 1; // ʱÖÓÀ¸ß
word |= MISO; // µ±Ç°MISO¿ÚµÄÖµ¼Óµ½ucharÉÏ
SCK = 0; // ʱÖÓÀµÍ
}
return(word); // ·µ»Ø¶Áµ½µÄÒ»¸ö×Ö½Ú
}
/****************************************************************************************************
/*º¯Êý£ºuchar SPI_Read(uchar reg)
/*¹¦ÄÜ£ºNRF24L01µÄSPIʱÐò
/****************************************************************************************************/
unsigned char SPI_Read(unsigned char reg)
{
unsigned char reg_val;
CSN = 0; // CSN low, initialize SPI communication...
SPI_RW(reg); // Select register to read from..
reg_val = SPI_RW(0); // ..then read registervalue
CSN = 1; // CSN high, terminate SPI communication
return(reg_val); // return register value
}
/****************************************************************************************************/
/*¹¦ÄÜ£ºNRF24L01д¼Ä´æÆ÷º¯Êý
/****************************************************************************************************/
unsigned char SPI_RW_Reg(unsigned char reg, unsigned char value)
{
unsigned char status;
CSN = 0; // ʧÄÜоƬ
status = SPI_RW(reg); // д¼Ä´æÆ÷µØÖ·£¬·µ»ØÒ»¸ö״ֵ̬
SPI_RW(value); // Íù¼Ä´æÆ÷Àïдһ¸öÖµ
CSN = 1; // ʧÄÜоƬ
return(status);
}
/****************************************************************************************************/
/*º¯Êý£ºuchar SPI_Read_Buf(unsigned char reg, unsigned char *pBuf, unsigned char uchars)
/*¹¦ÄÜ: ÓÃÓÚ¶ÁÊý¾Ý£¬reg£ºÎª¼Ä´æÆ÷µØÖ·£¬pBuf£ºÎª´ý¶Á³öÊý¾ÝµØÖ·£¬uchars£º¶Á³öÊý¾ÝµÄ¸öÊý
°ÑFIFOÖнÓÊÕµ½µÄÊý¾Ý¶Áµ½×Ô¼º¶¨ÒåµÄÊý×éÖÐ
/****************************************************************************************************/
unsigned char SPI_Read_Buf(unsigned char reg, unsigned char *pBuf, unsigned char uchars)
{
unsigned char status,uchar_ctr;
CSN = 0;
status = SPI_RW(reg); //дÈëÒª¶Á¼Ä´æÆ÷µÄµØÖ·
for(uchar_ctr=0;uchar_ctr<uchars;uchar_ctr++)
{
pBuf[uchar_ctr] = SPI_RW(0); //дÈë0¾Í¿ªÊ¼¶Á
}
CSN = 1;
return(status);
}
/*********************************************************************************************************
/*º¯Êý£ºuchar SPI_Write_Buf(uchar reg, uchar *pBuf, uchar uchars)
/*¹¦ÄÜ: ÓÃÓÚдÊý¾Ý£ºÎª¼Ä´æÆ÷µØÖ·£¬pBuf£ºÎª´ýдÈëÊý¾ÝµØÖ·£¬uchars£ºÐ´ÈëÊý¾ÝµÄ¸öÊý
ÓÃÓÚ°ÑÒª·¢Ë͵ÄÊý¾Ýдµ½FIFOÖÐÈ¥
/*********************************************************************************************************/
unsigned char SPI_Write_Buf(unsigned char reg, unsigned char *pBuf, unsigned char uchars)
{
unsigned char status,uchar_ctr;
CSN = 0; //SPIʹÄÜ
status = SPI_RW(reg);
for(uchar_ctr=0; uchar_ctr<uchars; uchar_ctr++)
{
SPI_RW(*pBuf++);
}
CSN = 1; //¹Ø±ÕSPI
return(status);
}
/****************************************************************************************************/
/*º¯Êý£ºvoid SetRX_Mode(void)
/*¹¦ÄÜ£ºÊý¾Ý½ÓÊÕÅäÖÃ
/****************************************************************************************************/
void SetRX_Mode(void)
{
CE=0;
SPI_RW_Reg(WRITE_REG + CONFIG, 0x0f); // IRQÊÕ·¢Íê³ÉÖжÏÏìÓ¦£¬16λCRC £¬Ö÷½ÓÊÕ
CE = 1;
inerDelay_us(130);
}
/******************************************************************************************************/
/*º¯Êý£ºunsigned char nRF24L01_RxPacket(unsigned char* rx_buf)
/*¹¦ÄÜ£ºÊý¾Ý¶ÁÈ¡ºó·ÅÈçrx_buf½ÓÊÕ»º³åÇøÖÐ
/******************************************************************************************************/
unsigned char nRF24L01_RxPacket(unsigned char* rx_buf)
{
unsigned char revale=0;
sta=SPI_Read(STATUS); // ¶Áȡ״̬¼Ä´æÆäÀ´ÅжÏÊý¾Ý½ÓÊÕ×´¿ö
if(RX_DR) // ÅжÏÊÇ·ñ½ÓÊÕµ½Êý¾Ý
{
CE = 0; // Í˻ص½Standby-1״̬
SPI_Read_Buf(RD_RX_PLOAD,rx_buf,TX_PLOAD_WIDTH);// read receive payload from RX_FIFO buffer
revale =1; //¶ÁÈ¡Êý¾ÝÍê³É±êÖ¾
SPI_RW_Reg(WRITE_REG+STATUS,sta); //½ÓÊÕµ½Êý¾ÝºóRX_DR,TX_DS,MAX_PT¶¼ÖøßΪ1£¬Í¨¹ýд1À´Çå³þÖжϱêÖ¾
}
//SPI_RW_Reg(WRITE_REG+STATUS,sta); //½ÓÊÕµ½Êý¾ÝºóRX_DR,TX_DS,MAX_PT¶¼ÖøßΪ1£¬Í¨¹ýд1À´Çå³þÖжϱêÖ¾
return revale;
}
/***********************************************************************************************************
/*º¯Êý£ºvoid nRF24L01_TxPacket(unsigned char * tx_buf)
/*¹¦ÄÜ£º·¢ËÍ tx_bufÖÐÊý¾Ý
/**********************************************************************************************************/
//void nRF24L01_TxPacket(unsigned char * tx_buf)
//{
// CE=0; //StandBy Iģʽ
// SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, TX_ADDRESS, TX_ADR_WIDTH); // ×°ÔؽÓÊն˵ØÖ·
// SPI_Write_Buf(WR_TX_PLOAD, tx_buf, TX_PLOAD_WIDTH); // ×°ÔØÊý¾Ý
// SPI_RW_Reg(WRITE_REG + CONFIG, 0x0e); // IRQÊÕ·¢Íê³ÉÖжÏÏìÓ¦£¬16λCRC£¬Ö÷·¢ËÍ
// CE=1; //ÖøßCE£¬¼¤·¢Êý¾Ý·¢ËÍ
// inerDelay_us(10);
//}
//************************************Ö÷º¯Êý************************************************************
// void Task_NRF(void *ppdata) reentrant
void Task_NRF() reentrant
{
unsigned char RxBuf[32];
// ppdata = ppdata;
Delay_n(6000);
SetRX_Mode();
while(1)
{
SPI_Read(CONFIG);
SetRX_Mode();
if(nRF24L01_RxPacket(RxBuf))
{
if(RxBuf[0] == 1)
{
if(RxBuf[1] == 2)
{
if(RxBuf[2] == 3)
{
if(RxBuf[3] == 4)
{
Rcv_Count++;
}
}
}
}
Delay_n(6000);
SPI_RW_Reg(WRITE_REG+STATUS,0XFF);
SPI_RW(FLUSH_TX);
}
}
}
//****************************************IO¶Ë¿Ú¶¨Òå***************************************
sbit SCK =P0^1;
sbit CE =P0^0;
sbit MISO =P0^2;
sbit CSN =P0^3;
sbit MOSI =P0^4;
//sbit IRQ =P1^5;
unsigned char bdata sta; //״̬±êÖ¾
sbit RX_DR =sta^6;
sbit TX_DS =sta^5;
sbit MAX_RT =sta^4;
unsigned char const TX_ADDRESS[TX_ADR_WIDTH]= {0x34,0x43,0x10,0x10,0x01}; //½ÓÊÕµØÖ·
unsigned char const RX_ADDRESS[RX_ADR_WIDTH]= {0x34,0x43,0x10,0x10,0x01}; //±¾µØµØÖ·
unsigned char Rcv_Count = 0;
//*****************************************³¤ÑÓʱ*****************************************
void Delay_n(unsigned int s)
{
unsigned int i;
for(i=0; i<s; i++);
for(i=0; i<s; i++);
}
/******************************************************************************************
/*ÑÓʱº¯Êý
/******************************************************************************************/
void inerDelay_us(unsigned int n)
{
for(;n>0;n--)
_nop_();
}
//****************************************************************************************
/*NRF24L01³õʼ»¯
//***************************************************************************************/
void init_NRF24L01(void)
{
inerDelay_us(10000);//Èç¹ûÉϵç¾ÍÖ´Ðд˳ÌÐò£¬ÔÚÉϵç֮ǰҪµÈ´ý100ms£¬µÈ´ý24L01½øÈëµôµçģʽ
CE=0; // CE ÎÞЧ
CSN=1; // Spi disable
SCK=0; // Spi clock line init high
SPI_RW_Reg(WRITE_REG + CONFIG, 0x0f); // ʹÄÜCRC£¬16λCRC£¬´ò¿ªµçÔ´,½ÓÊÜģʽ
/*
7 6 5 4 3 2 1 0
Reserved MASK_RX_DR MASK_TX_DS MASK_MAX_RT EN_CRC CRCO PWR_UP PRIM_RX
*/
// ÑÓʱһ»á£¬½øÈëStandby-1 ģʽ£¬¿ÉÒÔ²»ÓÃÑÓʱ£¬ÒòΪ¾ÍËãÔÚµôµçģʽÏÂÒ²¿ÉÒÔʹÓÃSPI²Ù×÷¼Ä´æÆ÷
// ¼ÌÐø²Ù×÷¼Ä´æÆ÷£¬24L01»á×Ô¶¯½øÈë Standby-1 ģʽ
//SPI_Write_Buf(WRITE_REG + TX_ADDR, TX_ADDRESS, TX_ADR_WIDTH); // д·¢ËÍ·½µØÖ·
SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, RX_ADDRESS, RX_ADR_WIDTH); // д·¢ËͶ˵ØÖ·
SPI_RW_Reg(WRITE_REG + EN_AA, 0x01); // ƵµÀ0×Ô¶¯ ACKÓ¦´ðÔÊÐí
SPI_RW_Reg(WRITE_REG + EN_RXADDR, 0x01); // ÔÊÐí½ÓÊÕµØÖ·Ö»ÓÐƵµÀ0£¬Èç¹ûÐèÒª¶àƵµÀ¿ÉÒԲο¼Page21
// ´ò¿ªÍ¨µÀ0
//SPI_RW_Reg(WRITE_REG + EN_AA, 0x00);//ʧÄÜͨµÀ0×Ô¶¯Ó¦´ð
//SPI_RW_Reg(WRITE_REG + EN_RXADDR, 0x01); //ʧÄܽÓÊÕͨµÀ0
SPI_RW_Reg(WRITE_REG + RF_CH, 30); // ÉèÖÃÐŵÀ¹¤×÷Ϊ2.4GHZ£¬ÊÕ·¢±ØÐëÒ»ÖÂ
SPI_RW_Reg(WRITE_REG + RX_PW_P0, RX_PLOAD_WIDTH); //ÉèÖýÓÊÕÊý¾Ý³¤¶È£¬±¾´ÎÉèÖÃΪ32×Ö½Ú
SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x07); //ÉèÖ÷¢ÉäËÙÂÊΪ2MHZ£¬·¢É书ÂÊΪ×î´óÖµ0dB
/*
7:5 4 3 2:1 0
Reserved PLL_LOCK RF_DR RF_PWR LNA_HCURR
*/
}
/****************************************************************************************************
/*º¯Êý£ºunsigned char SPI_RW(unsigned char unsigned char)
/*¹¦ÄÜ£ºNRF24L01µÄSPIдʱÐò
/****************************************************************************************************/
unsigned char SPI_RW(unsigned char word)
{
unsigned char bit_ctr;
for(bit_ctr=0;bit_ctr<8;bit_ctr++) // output 8-bit
{
MOSI = (word & 0x80); // ÏÈд×î¸ßλ
word = (word << 1); // ÓÒÒÆһλ
SCK = 1; // ʱÖÓÀ¸ß
word |= MISO; // µ±Ç°MISO¿ÚµÄÖµ¼Óµ½ucharÉÏ
SCK = 0; // ʱÖÓÀµÍ
}
return(word); // ·µ»Ø¶Áµ½µÄÒ»¸ö×Ö½Ú
}
/****************************************************************************************************
/*º¯Êý£ºuchar SPI_Read(uchar reg)
/*¹¦ÄÜ£ºNRF24L01µÄSPIʱÐò
/****************************************************************************************************/
unsigned char SPI_Read(unsigned char reg)
{
unsigned char reg_val;
CSN = 0; // CSN low, initialize SPI communication...
SPI_RW(reg); // Select register to read from..
reg_val = SPI_RW(0); // ..then read registervalue
CSN = 1; // CSN high, terminate SPI communication
return(reg_val); // return register value
}
/****************************************************************************************************/
/*¹¦ÄÜ£ºNRF24L01д¼Ä´æÆ÷º¯Êý
/****************************************************************************************************/
unsigned char SPI_RW_Reg(unsigned char reg, unsigned char value)
{
unsigned char status;
CSN = 0; // ʧÄÜоƬ
status = SPI_RW(reg); // д¼Ä´æÆ÷µØÖ·£¬·µ»ØÒ»¸ö״ֵ̬
SPI_RW(value); // Íù¼Ä´æÆ÷Àïдһ¸öÖµ
CSN = 1; // ʧÄÜоƬ
return(status);
}
/****************************************************************************************************/
/*º¯Êý£ºuchar SPI_Read_Buf(unsigned char reg, unsigned char *pBuf, unsigned char uchars)
/*¹¦ÄÜ: ÓÃÓÚ¶ÁÊý¾Ý£¬reg£ºÎª¼Ä´æÆ÷µØÖ·£¬pBuf£ºÎª´ý¶Á³öÊý¾ÝµØÖ·£¬uchars£º¶Á³öÊý¾ÝµÄ¸öÊý
°ÑFIFOÖнÓÊÕµ½µÄÊý¾Ý¶Áµ½×Ô¼º¶¨ÒåµÄÊý×éÖÐ
/****************************************************************************************************/
unsigned char SPI_Read_Buf(unsigned char reg, unsigned char *pBuf, unsigned char uchars)
{
unsigned char status,uchar_ctr;
CSN = 0;
status = SPI_RW(reg); //дÈëÒª¶Á¼Ä´æÆ÷µÄµØÖ·
for(uchar_ctr=0;uchar_ctr<uchars;uchar_ctr++)
{
pBuf[uchar_ctr] = SPI_RW(0); //дÈë0¾Í¿ªÊ¼¶Á
}
CSN = 1;
return(status);
}
/*********************************************************************************************************
/*º¯Êý£ºuchar SPI_Write_Buf(uchar reg, uchar *pBuf, uchar uchars)
/*¹¦ÄÜ: ÓÃÓÚдÊý¾Ý£ºÎª¼Ä´æÆ÷µØÖ·£¬pBuf£ºÎª´ýдÈëÊý¾ÝµØÖ·£¬uchars£ºÐ´ÈëÊý¾ÝµÄ¸öÊý
ÓÃÓÚ°ÑÒª·¢Ë͵ÄÊý¾Ýдµ½FIFOÖÐÈ¥
/*********************************************************************************************************/
unsigned char SPI_Write_Buf(unsigned char reg, unsigned char *pBuf, unsigned char uchars)
{
unsigned char status,uchar_ctr;
CSN = 0; //SPIʹÄÜ
status = SPI_RW(reg);
for(uchar_ctr=0; uchar_ctr<uchars; uchar_ctr++)
{
SPI_RW(*pBuf++);
}
CSN = 1; //¹Ø±ÕSPI
return(status);
}
/****************************************************************************************************/
/*º¯Êý£ºvoid SetRX_Mode(void)
/*¹¦ÄÜ£ºÊý¾Ý½ÓÊÕÅäÖÃ
/****************************************************************************************************/
void SetRX_Mode(void)
{
CE=0;
SPI_RW_Reg(WRITE_REG + CONFIG, 0x0f); // IRQÊÕ·¢Íê³ÉÖжÏÏìÓ¦£¬16λCRC £¬Ö÷½ÓÊÕ
CE = 1;
inerDelay_us(130);
}
/******************************************************************************************************/
/*º¯Êý£ºunsigned char nRF24L01_RxPacket(unsigned char* rx_buf)
/*¹¦ÄÜ£ºÊý¾Ý¶ÁÈ¡ºó·ÅÈçrx_buf½ÓÊÕ»º³åÇøÖÐ
/******************************************************************************************************/
unsigned char nRF24L01_RxPacket(unsigned char* rx_buf)
{
unsigned char revale=0;
sta=SPI_Read(STATUS); // ¶Áȡ״̬¼Ä´æÆäÀ´ÅжÏÊý¾Ý½ÓÊÕ×´¿ö
if(RX_DR) // ÅжÏÊÇ·ñ½ÓÊÕµ½Êý¾Ý
{
CE = 0; // Í˻ص½Standby-1״̬
SPI_Read_Buf(RD_RX_PLOAD,rx_buf,TX_PLOAD_WIDTH);// read receive payload from RX_FIFO buffer
revale =1; //¶ÁÈ¡Êý¾ÝÍê³É±êÖ¾
SPI_RW_Reg(WRITE_REG+STATUS,sta); //½ÓÊÕµ½Êý¾ÝºóRX_DR,TX_DS,MAX_PT¶¼ÖøßΪ1£¬Í¨¹ýд1À´Çå³þÖжϱêÖ¾
}
//SPI_RW_Reg(WRITE_REG+STATUS,sta); //½ÓÊÕµ½Êý¾ÝºóRX_DR,TX_DS,MAX_PT¶¼ÖøßΪ1£¬Í¨¹ýд1À´Çå³þÖжϱêÖ¾
return revale;
}
/***********************************************************************************************************
/*º¯Êý£ºvoid nRF24L01_TxPacket(unsigned char * tx_buf)
/*¹¦ÄÜ£º·¢ËÍ tx_bufÖÐÊý¾Ý
/**********************************************************************************************************/
//void nRF24L01_TxPacket(unsigned char * tx_buf)
//{
// CE=0; //StandBy Iģʽ
// SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, TX_ADDRESS, TX_ADR_WIDTH); // ×°ÔؽÓÊն˵ØÖ·
// SPI_Write_Buf(WR_TX_PLOAD, tx_buf, TX_PLOAD_WIDTH); // ×°ÔØÊý¾Ý
// SPI_RW_Reg(WRITE_REG + CONFIG, 0x0e); // IRQÊÕ·¢Íê³ÉÖжÏÏìÓ¦£¬16λCRC£¬Ö÷·¢ËÍ
// CE=1; //ÖøßCE£¬¼¤·¢Êý¾Ý·¢ËÍ
// inerDelay_us(10);
//}
//************************************Ö÷º¯Êý************************************************************
// void Task_NRF(void *ppdata) reentrant
void Task_NRF() reentrant
{
unsigned char RxBuf[32];
// ppdata = ppdata;
Delay_n(6000);
SetRX_Mode();
while(1)
{
SPI_Read(CONFIG);
SetRX_Mode();
if(nRF24L01_RxPacket(RxBuf))
{
if(RxBuf[0] == 1)
{
if(RxBuf[1] == 2)
{
if(RxBuf[2] == 3)
{
if(RxBuf[3] == 4)
{
Rcv_Count++;
}
}
}
}
Delay_n(6000);
SPI_RW_Reg(WRITE_REG+STATUS,0XFF);
SPI_RW(FLUSH_TX);
}
}
}