Example #1
0
unsigned char nRF24L01_debug(void)
{
#ifdef nRF24L01_RX_Debug
    unsigned char RxBuf[RX_PLOAD_WIDTH]={0};
    SetRX_Mode();
    while(1){
        SetRX_Mode();
        if(nRF24L01_RxPacket(RxBuf)){ 
            //add your code
            return 1;
        }
    } 
#endif
    
#ifdef nRF24L01_TX_Debug   
    unsigned char sta=0; 
    unsigned char TxBuf[TX_PLOAD_WIDTH]={0};
    nRF24L01_TxPacket(TxBuf);
    while(1){ 
        nRF24L01_TxPacket(TxBuf);
        sta = SPI_Read(STATUS);
        if(sta == 0x2e){
            //add your code
            return 1;
        }
        SPI_RW_Reg(WRITE_REG+STATUS, 0xff);
        xSysCtlDelay(10000);
    }
#endif
}
Example #2
0
void receive()
{
       SetRX_Mode();
	   nRF24L01_RxPacket(RxBuf);
	   IN1=RxBuf[1];
	   IN2=RxBuf[2];
	   IN3=RxBuf[3];
	   IN4=RxBuf[4];	 
	   Delay_a(10);
}
Example #3
0
//************************************主函数************************************************************
void main(void)
{		 
	uchar RxBuf[20]={0};	
	init_1602();
    init_NRF24L01() ;
	while(1)
	{	   
//***********************************************************************************************
//		SetRX_Mode();
		nRF24L01_RxPacket(RxBuf);	
		RxBuf[1] = 0x00;
		RxBuf[2] = 0x00;
	}
	
}
Example #4
0
//int CheckAsk(){
//	int Asking = 0;	
//	TxBuf[1] = 0x00;
//	TxBuf[2] = 0x00;
//	nRF24L01_TxPacket(TxBuf);  
//	TxBuf[1] = 0x00;
//	TxBuf[2] = 0x00;
//	Delay(1000);
//	SetRX_Mode();
//	nRF24L01_RxPacket(RxBuf);
//   	if(RxBuf[1]){					
//		if(	RxBuf[1]==0x01){
//			Asking = 1;
//		}
//		Delay(1000);
//	}
//	RxBuf[1] = 0x00;
//	RxBuf[2] = 0x00;
//	if(Asking) return 1;
//	else return 0;
//}
//void AskRec(){
//	TxBuf[1] = 0x02 ;
//	nRF24L01_TxPacket(TxBuf);	
//	TxBuf[1] = 0x00;
//	TxBuf[2] = 0x00;
//	Delay(1000);
//	SetRX_Mode();
//	nRF24L01_RxPacket(RxBuf);
//	RxBuf[1] = 0x00;
//	RxBuf[2] = 0x00;
//}
//************************************主函数************************************************************
void main(void)
{
	int Asking,Quizing,QzFn,i;
	unsigned char tf =0;
	char Ans[NUM];
	Asking = Quizing = QzFn = 0;
    init_NRF24L01() ;
	led0=0;led1=0;led2=0;led3=0;
	P0 = seg[2];
	while(1)
	{
	    
	    if (tf==1){	
			nRF24L01_TxPacket(TxBuf);	
			TxBuf[1] = 0x00;
			tf = 0;
			Delay(1000);
	    }
		SetRX_Mode();
		nRF24L01_RxPacket(RxBuf);
   		if(RxBuf[1]){	
			QzFn = 1;
			if(RxBuf[1]>=0x40 && RxBuf[1]<=0x6f){
				Ans[RxBuf[1]-0x41] = 'a';
			}
			else if(RxBuf[1]>=0x70 && RxBuf[1]<=0x9f){
				Ans[RxBuf[1]-0x71] = 'b';
			}
			else if(RxBuf[1]>=0xa0 && RxBuf[1]<=0xcf){
				Ans[RxBuf[1]-0xa1] = 'c';
			}
			else if(RxBuf[1]>=0xd0 && RxBuf[1]<=0xff){
				Ans[RxBuf[1]-0xd1] = 'd';
			} 
			for(i = 0;i<NUM;i++){
				if(Ans[i] == 0)
					QzFn = 0;	
			}
			if(QzFn){
				P0 = 0xBF;
			}	
			
			Delay(1000);
		}
		RxBuf[1] = 0x00;
	}
}
//************************************主函数************************************************************
void main(void)
{
	uchar i;	
    init_NRF24L01();
	StartUART();
	delay();
	while(1)
	{
/*		if(temp<4)
		{
		switch(temp)
		{
		case 	1:	
		P0=	0xFE;
			break;	
		case 	2:	 
 	   
			P0=	0xBF;
				break;	
		case 	3:
			P0=	0xf7;

		  	break;	
		default:  break;
		}
		}
	if(temp==3)
		{
		temp=0;
		}
*/
//		SetRX_Mode();
   		if(nRF24L01_RxPacket(RxBuf))
		{
//			temp++;
			R_S_Byte(0x73);
			for(i=0;i<32;i++)
			{
				R_S_Byte(RxBuf[i]);
				delay();
			}	
		}
	
	}
	
}
Example #6
0
//************************************主函数************************************************************
void main(void)
{		 
	uchar RxBuf[20]={0};	
	init_1602();
    init_NRF24L01() ;
	led0=1;led1=1;
		BELL=0;
		Delay(100);
		BELL=1;
	while(1)
	{	   
//***********************************************************************************************
//		SetRX_Mode();
		nRF24L01_RxPacket(RxBuf);	
		RxBuf[1] = 0x00;
		RxBuf[2] = 0x00;
	}
	
}
//************************************主函式************************************************************
void main(void)
{
	unsigned char tf =0;
	unsigned char TxBuf[20]={0};	  
	unsigned char RxBuf[20]={0};	
    init_NRF24L01() ;
	TxBuf[1] = 1 ;
	TxBuf[2] = 1 ;
	nRF24L01_TxPacket(TxBuf);	// Transmit Tx buffer data
	Delay(6000);
	while(1)
	{
    	if(KEY1 ==0 ) 
	  	{
		    TxBuf[1] = 1 ;
		    tf = 1 ; LED=0;
	    }
	   if (tf==1)
       {	
			nRF24L01_TxPacket(TxBuf);	// Transmit Tx buffer data
			TxBuf[1] = 0x00;
			TxBuf[2] = 0x00;
			tf=0;
			Delay(1000);LED=1;
	   }
//***********************************************************************************************
		SetRX_Mode();
		nRF24L01_RxPacket(RxBuf);					
			if(	RxBuf[1]==1)
			{	 	
				LED=0;
			}
			Delay(1000);LED=1;
			RxBuf[1] = 0x00;
			RxBuf[2] = 0x00;
	}
	
}
Example #8
0
unsigned char readposition()
{
	unsigned char  i=0;
	unsigned flagstatus=0;
	
	if(nRF24L01_RxPacket(RxBuf)==1)         // Neu nhan duoc du lieu
	{
		for( i=0;i<28;i++)
		{
			*(uint8_t *) ((uint8_t *)&rb + i)=RxBuf[i];
		}
		
		idRobot = fmod(rb.id,10); // doc id
		cmdCtrlRobot = (int)rb.id/10; // doc ma lenh
	}
	  if(idRobot==ROBOT_ID)
	  {
		 // LEDL=!LEDL;
		  cmdCtrlRobot = (int)rb.id/10; // doc ma lenh
		  flagstatus=1;
		  robotctrl=rb;
	  }
	return flagstatus;
}