Ejemplo n.º 1
0
void SX1276LoRaInit( void )
{
   
    SX1276LoRaSetOpMode( RFLR_OPMODE_SLEEP );	
	SX1276LoRaSetDefaults( );
		
	SX1276ReadBuffer( 0x1,&SX1276LR, 0x70 - 1 );
      
	SX1276Read( REG_LR_VERSION, &SX1276LR.RegVersion );
	 
    // set the RF settings 
    SX1276LoRaSetRFFrequency( LoRaSettings.RFFrequency,&SX1276LR );
    SX1276LoRaSetRFPower_2( LoRaSettings.Power,&SX1276LR );
    SX1276LoRaSetSpreadingFactor( LoRaSettings.SpreadingFactor,&SX1276LR ); // SF6 only operates in implicit header mode.
    SX1276LoRaSetErrorCoding( LoRaSettings.ErrorCoding,&SX1276LR );
    SX1276LoRaSetPacketCrcOn( LoRaSettings.CrcOn,&SX1276LR );
    SX1276LoRaSetSignalBandwidth( LoRaSettings.SignalBw,&SX1276LR );
    
    SX1276LoRaSetImplicitHeaderOn( LoRaSettings.ImplicitHeaderOn,&SX1276LR );
    SX1276LoRaSetSymbTimeout( 0x3FF,&SX1276LR );	//Maximum - casove okno pro hledani preamble v single rezimu
    SX1276LoRaSetPayloadLength( LoRaSettings.PayloadLength,&SX1276LR );	//
   // SX1276LoRaSetLowDatarateOptimize( true,&SX1276LR );	//dela problemy - u delsiho paketu je rozsypany caj
    
	/*AGC AUTO*/
 	SX1276Read( REG_LR_MODEMCONFIG3,&SX1276LR.RegModemConfig3 );
 	SX1276LR.RegModemConfig3|=0x4;
 	SX1276Write( REG_LR_MODEMCONFIG3,SX1276LR.RegModemConfig3 );
	SX1276LoRaSetOpMode( RFLR_OPMODE_STANDBY );
}
Ejemplo n.º 2
0
void SX1276LoRaInit( void )
{
	  
    RFLRState = RFLR_STATE_IDLE;

    SX1276LoRaSetDefaults( );				// 读取XS1276的版本号到SX1276LR->RegVersion
    
    SX1276ReadBuffer( REG_LR_OPMODE, SX1276Regs + 1, 0x70 - 1 );		// 从REG_LR_OPMODE地址开始连续读出0x6F个寄存器的值到SX1276Regs[1...0x6F]
    
    SX1276LR->RegLna = RFLR_LNA_GAIN_G1;

    SX1276WriteBuffer( REG_LR_OPMODE, SX1276Regs + 1, 0x70 - 1 );

    // set the RF settings 
    SX1276LoRaSetRFFrequency( LoRaSettings.RFFrequency );
    SX1276LoRaSetSpreadingFactor( LoRaSettings.SpreadingFactor ); // SF6 only operates in implicit header mode.
    SX1276LoRaSetErrorCoding( LoRaSettings.ErrorCoding );
    SX1276LoRaSetPacketCrcOn( LoRaSettings.CrcOn );
    SX1276LoRaSetSignalBandwidth( LoRaSettings.SignalBw );

    SX1276LoRaSetImplicitHeaderOn( LoRaSettings.ImplicitHeaderOn );
    SX1276LoRaSetSymbTimeout( 0x3FF );
    SX1276LoRaSetPayloadLength( LoRaSettings.PayloadLength );
    SX1276LoRaSetLowDatarateOptimize( FALSE );

#if( ( MODULE_SX1276RF1IAS == 1 ) || ( MODULE_SX1276RF1KAS == 1 ) )
    if( LoRaSettings.RFFrequency > 860000000 )
    {
        SX1276LoRaSetPAOutput( RFLR_PACONFIG_PASELECT_RFO );
        SX1276LoRaSetPa20dBm( FALSE );
        LoRaSettings.Power = 14;
        SX1276LoRaSetRFPower( LoRaSettings.Power );
    }
    else
    {
        SX1276LoRaSetPAOutput( RFLR_PACONFIG_PASELECT_PABOOST );
        SX1276LoRaSetPa20dBm( TRUE );
        LoRaSettings.Power = 20;
        SX1276LoRaSetRFPower( LoRaSettings.Power );		
    } 
#elif( MODULE_SX1276RF1JAS == 1 )
    if( LoRaSettings.RFFrequency > 860000000 )
    {
        SX1276LoRaSetPAOutput( RFLR_PACONFIG_PASELECT_PABOOST );
        SX1276LoRaSetPa20dBm( TRUE );
        LoRaSettings.Power = 20;
        SX1276LoRaSetRFPower( LoRaSettings.Power );
    }
    else
    {
        SX1276LoRaSetPAOutput( RFLR_PACONFIG_PASELECT_RFO );
        SX1276LoRaSetPa20dBm( FALSE );
        LoRaSettings.Power = 14;
        SX1276LoRaSetRFPower( LoRaSettings.Power );
    } 
#endif
	
    SX1276LoRaSetOpMode( RFLR_OPMODE_STANDBY );
}