Esempio n. 1
0
//##############################################################################################################
void SX1278TASK_PROCESS(void const * argument)
{
  uint32_t  Last;
  BoardInit( );    
  Radio = RadioDriverInit( );    
  Radio->Init( );
  Radio_UserInit();
  Radio->StartRx( );  
  Last=HAL_GetTick();
  while(1)
  {
    switch( Radio->Process( ))
    {
      case RF_CHANNEL_ACTIVITY_DETECTED:
        __NOP();
      break;
      case RF_CHANNEL_EMPTY:
        __NOP();__NOP();
      break;
      case RF_LEN_ERROR:
        __NOP();__NOP();__NOP();
      break;
      case RF_IDLE:
          __NOP();__NOP();__NOP();__NOP();        
      break;
      case RF_BUSY:
        __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();
      break;
      
      case RF_RX_TIMEOUT:
        Radio_RxTimeout();
        break;
      case RF_RX_DONE:
        Radio->GetRxPacket( RadioBuffer, ( uint16_t* )&RadioLength );
        if( RadioLength > 0 )
        {
          Radio_RxDone(RadioBuffer,RadioLength);
        }        
        break;
      case RF_TX_DONE:    
        __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();
        Radio->StartRx( );
        break;
      case RF_TX_TIMEOUT:
        
      break;
      default:
        break;
    }    
    osDelay(1);
    if(HAL_GetTick()-Last < 100)
    {
      Last = HAL_GetTick();
      Radio_Misc_Per100ms();
    }
  }
  
}
Esempio n. 2
0
void RadioStart()
{
	bool bTX = false;
  BoardInit( );

  GreenLedBlink();
	RedLedBlink();


  Radio = RadioDriverInit();
  Radio->Init();

  Radio->StartRx( );

	while(1)
	{
	  switch(Radio->Process())
    {
    case RF_RX_DONE:
				Radio->GetRxPacket( Buffer, ( uint16_t* )&BufferSize );
				if( BufferSize > 0 )
        {
					if (bDeviceState == CONFIGURED)
					{
						if (packet_sent == 1)
						{
							CDC_Send_DATA ((unsigned char*)Buffer,BufferSize);
						}
					}
				}

				GreenLedBlink();
				Radio->StartRx( );

				break;
    case RF_TX_DONE:
				RedLedBlink();
        Radio->StartRx( );
				bTX = false;
        break;
    default:
			if (bDeviceState == CONFIGURED)
			{
				if(bTX) break;
				if (Receive_length  != 0)
				{
					Radio->SetTxPacket( (unsigned char*)Receive_Buffer,Receive_length );
					CDC_Receive_DATA();
					Receive_length = 0;
					bTX = true;
				}
			}
			break;
    }
	}
}
Esempio n. 3
0
int main(void)
{				
	
	MCU_Init();
	LEDG_OFF();
	LEDR1_OFF();
	LEDR2_OFF();
	memset( TxBuf, 0, ( size_t )TxBufSize);
  //GetChipId();    //获取芯片ID
	
	//Flash_Read((uint32_t)0x0800FFF0,gateway_mac,6);
	//Flash_Read((uint32_t)0x0800FFE0,net_id,2);
	
	//Print_Array(gateway_mac,6,s1);
	//Print_Array(net_id,2,s2);
	
	//初始化Radio驱动
	Radio = RadioDriverInit( ); 
  Radio->Init( );
	Radio->StartRx( );
	//printf("The radio have been init!!\r\n");
	
	while(1)
	{	
			OnSlave();
			if(receive_flag==true)
			{
				receive_flag=false;
				Config_Handler(ReceiveBuff);
				
			}
       
//			IWDG_ReloadCounter();  
	
	
// SignalBw [0: 7.8kHz, 1: 10.4 kHz, 2: 15.6 kHz, 3: 20.8 kHz, 4: 31.2 kHz,5: 41.6 kHz, 6: 62.5 kHz, 7: 125 kHz, 8: 250 kHz, 9: 500 kHz, other: Reserved]
	//SX1276LoRaSetSignalBandwidth(8);
//SpreadingFactor [6: 64, 7: 128, 8: 256, 9: 512, 10: 1024, 11: 2048, 12: 4096  chips]
//			SX1276LoRaSetSpreadingFactor( uint8_t factor );
// ErrorCoding [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
//			SX1276LoRaSetErrorCoding( uint8_t value );

	
////	  DMA_Cmd(DMA1_Channel4,ENABLE);
////		USART_DMACmd(USART1, USART_DMAReq_Tx, ENABLE);	

	}

}
Esempio n. 4
0
/*
 * Main application entry point.
 */
int main( void )
{
    
    
    Radio = RadioDriverInit( );
    
    Radio->Init( );

    Radio->StartRx( );
    
    while( 1 )
    {
        if( EnableMaster == true )
        {
            OnMaster( );
        }
        else
        {
            OnSlave( );
        }    
#if( PLATFORM == SX12xxEiger ) && ( USE_UART == 1 )

        UartProcess( );
        
        {
            uint8_t data = 0;
            if( UartGetChar( &data ) == UART_OK )
            {
                UartPutChar( data );
            }
        }
#endif        
    }
#ifdef __GNUC__
    return 0;
#endif
}