mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-13 09:07:27 -05:00
Converted frequency to long primitive type (from integer) in anticipation of HackRF support which requires frequencies greater than 2.147 GHz, which is the max hertz value that can be represented by an integer primitive.
This commit is contained in:
@@ -119,7 +119,7 @@ public class RTL2832Tuner extends Tuner
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFrequency() throws SourceException
|
||||
public long getFrequency() throws SourceException
|
||||
{
|
||||
return mController.getFrequency();
|
||||
}
|
||||
|
||||
@@ -166,8 +166,8 @@ public abstract class RTL2832TunerController extends TunerController
|
||||
* tuner controller class for that tuner type.
|
||||
*/
|
||||
public RTL2832TunerController( USBTunerDevice tunerDevice,
|
||||
int minTunableFrequency,
|
||||
int maxTunableFrequency ) throws SourceException
|
||||
long minTunableFrequency,
|
||||
long maxTunableFrequency ) throws SourceException
|
||||
{
|
||||
super( minTunableFrequency, maxTunableFrequency );
|
||||
|
||||
|
||||
@@ -36,10 +36,10 @@ public class E4KTunerController extends RTL2832TunerController
|
||||
*
|
||||
* TODO: change frequency to a long primitive type
|
||||
*/
|
||||
public static final int sMIN_FREQUENCY = 52000000;
|
||||
public static final int sMIN_FREQUENCY_EXTENDED = 52000000;
|
||||
public static final int sMAX_FREQUENCY = 2147000000;
|
||||
public static final int sMAX_FREQUENCY_EXTENDED = 2147000000;
|
||||
public static final long sMIN_FREQUENCY = 52000000;
|
||||
public static final long sMIN_FREQUENCY_EXTENDED = 52000000;
|
||||
public static final long sMAX_FREQUENCY = 2200000000l;
|
||||
public static final long sMAX_FREQUENCY_EXTENDED = 2200000000l;
|
||||
public static final long sMIN_VCO = 2600000000l; //2.6 GHz
|
||||
public static final long sMAX_VCO = 3900000000l; //3.9 GHz
|
||||
|
||||
@@ -236,7 +236,7 @@ public class E4KTunerController extends RTL2832TunerController
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTunedFrequency() throws SourceException
|
||||
public long getTunedFrequency() throws SourceException
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -276,7 +276,7 @@ public class E4KTunerController extends RTL2832TunerController
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTunedFrequency( int frequency ) throws SourceException
|
||||
public void setTunedFrequency( long frequency ) throws SourceException
|
||||
{
|
||||
/* Get the phase locked loop setting */
|
||||
PLL pll = PLL.fromFrequency( frequency );
|
||||
@@ -288,13 +288,13 @@ public class E4KTunerController extends RTL2832TunerController
|
||||
/* remainder is just as it describes. It is what is left over after we
|
||||
* carve out scaled oscillator frequency increments (z) from the desired
|
||||
* frequency. */
|
||||
int remainder = frequency - ( ( z & 0xFF ) * pll.getScaledOscillator() );
|
||||
int remainder = (int)( frequency - ( ( z & 0xFF ) * pll.getScaledOscillator() ) );
|
||||
|
||||
/* X is a 16-bit representation of the remainder */
|
||||
int x = (int)( (double)remainder / (double)pll.getScaledOscillator() * sE4K_PLL_Y );
|
||||
|
||||
/* Calculate the exact (tunable) frequency and apply that to the tuner */
|
||||
int actualFrequency = calculateActualFrequency( pll, z, x );
|
||||
long actualFrequency = calculateActualFrequency( pll, z, x );
|
||||
|
||||
/**
|
||||
* Hack: if we're trying to set the minimum frequency for the E4K, due
|
||||
@@ -353,9 +353,9 @@ public class E4KTunerController extends RTL2832TunerController
|
||||
}
|
||||
}
|
||||
|
||||
private int calculateActualFrequency( PLL pll, byte z, int x )
|
||||
private long calculateActualFrequency( PLL pll, byte z, int x )
|
||||
{
|
||||
int whole = (int)( pll.getScaledOscillator() * ( z & 0xFF ) );
|
||||
long whole = pll.getScaledOscillator() * ( z & 0xFF );
|
||||
|
||||
int fractional = (int)( pll.getScaledOscillator() *
|
||||
( (double)x / (double)sE4K_PLL_Y ) );
|
||||
@@ -880,7 +880,7 @@ public class E4KTunerController extends RTL2832TunerController
|
||||
}
|
||||
}
|
||||
|
||||
public void setBand( int frequency,
|
||||
public void setBand( long frequency,
|
||||
boolean controlI2CRepeater ) throws UsbException
|
||||
{
|
||||
if( controlI2CRepeater )
|
||||
@@ -918,7 +918,7 @@ public class E4KTunerController extends RTL2832TunerController
|
||||
}
|
||||
}
|
||||
|
||||
private void setRFFilter( int frequency,
|
||||
private void setRFFilter( long frequency,
|
||||
boolean controlI2CRepeater ) throws UsbException
|
||||
{
|
||||
RFFilter filter = RFFilter.fromFrequency( frequency );
|
||||
@@ -1057,7 +1057,7 @@ public class E4KTunerController extends RTL2832TunerController
|
||||
return toString();
|
||||
}
|
||||
|
||||
public static Band fromFrequency( int frequency )
|
||||
public static Band fromFrequency( long frequency )
|
||||
{
|
||||
if( frequency < 140000000 ) //140 MHz
|
||||
{
|
||||
@@ -1092,14 +1092,14 @@ public class E4KTunerController extends RTL2832TunerController
|
||||
PLL_1200M0( 0x01, 1200000000, 4, 7200000, false, "1200.0 MHz" );
|
||||
|
||||
private int mValue;
|
||||
private int mFrequency;
|
||||
private long mFrequency;
|
||||
private int mMultiplier;
|
||||
private int mScaledOscillator;
|
||||
private boolean mRequires3PhaseMixing;
|
||||
private String mLabel;
|
||||
|
||||
private PLL( int value,
|
||||
int frequency,
|
||||
long frequency,
|
||||
int multiplier,
|
||||
int scaledOscillator,
|
||||
boolean requires3Phase,
|
||||
@@ -1119,7 +1119,7 @@ public class E4KTunerController extends RTL2832TunerController
|
||||
return (byte)mValue;
|
||||
}
|
||||
|
||||
public int getFrequency()
|
||||
public long getFrequency()
|
||||
{
|
||||
return mFrequency;
|
||||
}
|
||||
@@ -1151,7 +1151,7 @@ public class E4KTunerController extends RTL2832TunerController
|
||||
|
||||
/* Returns the PLL setting with the closest frequency that is greater
|
||||
* than the frequency argument */
|
||||
public static PLL fromFrequency( int frequency )
|
||||
public static PLL fromFrequency( long frequency )
|
||||
{
|
||||
for( PLL pll: values() )
|
||||
{
|
||||
@@ -1235,10 +1235,10 @@ public class E4KTunerController extends RTL2832TunerController
|
||||
M1750( 15, 1735000000, 2147000000 );
|
||||
|
||||
private int mValue;
|
||||
private int mMinFrequency;
|
||||
private int mMaxFrequency;
|
||||
private long mMinFrequency;
|
||||
private long mMaxFrequency;
|
||||
|
||||
private RFFilter( int value, int minFrequency, int maxFrequency )
|
||||
private RFFilter( int value, long minFrequency, long maxFrequency )
|
||||
{
|
||||
mValue = value;
|
||||
mMinFrequency = minFrequency;
|
||||
@@ -1263,7 +1263,7 @@ public class E4KTunerController extends RTL2832TunerController
|
||||
/**
|
||||
* Minimum frequency for this filter.
|
||||
*/
|
||||
public int getMinimumFrequency()
|
||||
public long getMinimumFrequency()
|
||||
{
|
||||
return mMinFrequency;
|
||||
}
|
||||
@@ -1272,7 +1272,7 @@ public class E4KTunerController extends RTL2832TunerController
|
||||
* Maximum frequency for this filter is less than this value, but does
|
||||
* not include this value.
|
||||
*/
|
||||
public int getMaximumFrequency()
|
||||
public long getMaximumFrequency()
|
||||
{
|
||||
return mMaxFrequency;
|
||||
}
|
||||
@@ -1285,7 +1285,7 @@ public class E4KTunerController extends RTL2832TunerController
|
||||
* @throws IllegalArgumentException if the frequency is outside the
|
||||
* max value (2200 MHz)
|
||||
*/
|
||||
public static RFFilter fromFrequency( int frequency )
|
||||
public static RFFilter fromFrequency( long frequency )
|
||||
{
|
||||
if( frequency < 350000000 )
|
||||
{
|
||||
|
||||
@@ -22,18 +22,17 @@ import gui.control.JFrequencyControl;
|
||||
import java.awt.Color;
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import com.jidesoft.swing.JideTabbedPane;
|
||||
|
||||
import log.Log;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import source.SourceComponentEditor;
|
||||
import source.SourceException;
|
||||
import source.tuner.FrequencyChangeListener;
|
||||
import source.tuner.rtl.RTL2832InfoPanel;
|
||||
|
||||
import com.jidesoft.swing.JideTabbedPane;
|
||||
|
||||
import controller.ResourceManager;
|
||||
|
||||
public class E4KTunerEditorPanel extends JPanel implements FrequencyChangeListener
|
||||
@@ -89,7 +88,7 @@ public class E4KTunerEditorPanel extends JPanel implements FrequencyChangeListen
|
||||
* apply end-user requested frequency changes against the tuner
|
||||
*/
|
||||
@Override
|
||||
public void frequencyChanged( final int frequency, int bandwidth )
|
||||
public void frequencyChanged( final long frequency, int bandwidth )
|
||||
{
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
|
||||
@@ -35,8 +35,8 @@ import controller.ResourceManager;
|
||||
|
||||
public class R820TTunerController extends RTL2832TunerController
|
||||
{
|
||||
public static final int MIN_FREQUENCY = 24000000;
|
||||
public static final int MAX_FREQUENCY = 1766000000;
|
||||
public static final long MIN_FREQUENCY = 24000000;
|
||||
public static final long MAX_FREQUENCY = 1766000000;
|
||||
public static final int R820T_IF_FREQUENCY = 3570000;
|
||||
public static final byte VERSION = (byte)49;
|
||||
|
||||
@@ -136,7 +136,7 @@ public class R820TTunerController extends RTL2832TunerController
|
||||
* Not implemented.
|
||||
*/
|
||||
@Override
|
||||
public int getTunedFrequency() throws SourceException
|
||||
public long getTunedFrequency() throws SourceException
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public class R820TTunerController extends RTL2832TunerController
|
||||
* of setting the multiplexer and then setting the Oscillator (PLL).
|
||||
*/
|
||||
@Override
|
||||
public void setTunedFrequency( int frequency ) throws SourceException
|
||||
public void setTunedFrequency( long frequency ) throws SourceException
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -154,7 +154,7 @@ public class R820TTunerController extends RTL2832TunerController
|
||||
|
||||
boolean controlI2C = false;
|
||||
|
||||
int offsetFrequency = frequency + R820T_IF_FREQUENCY;
|
||||
long offsetFrequency = frequency + R820T_IF_FREQUENCY;
|
||||
|
||||
setMux( offsetFrequency, controlI2C );
|
||||
|
||||
@@ -205,7 +205,7 @@ public class R820TTunerController extends RTL2832TunerController
|
||||
/**
|
||||
* Sets the multiplexer for the desired center frequency.
|
||||
*/
|
||||
private void setMux( int frequency, boolean controlI2C ) throws UsbException
|
||||
private void setMux( long frequency, boolean controlI2C ) throws UsbException
|
||||
{
|
||||
FrequencyRange range = FrequencyRange.getRangeForFrequency( frequency );
|
||||
|
||||
@@ -401,7 +401,7 @@ public class R820TTunerController extends RTL2832TunerController
|
||||
/**
|
||||
* Sets the system IF frequency
|
||||
*/
|
||||
private void systemFrequencySelect( int frequency, boolean controlI2C )
|
||||
private void systemFrequencySelect( long frequency, boolean controlI2C )
|
||||
throws UsbException
|
||||
{
|
||||
/* LNA top? */
|
||||
@@ -472,7 +472,7 @@ public class R820TTunerController extends RTL2832TunerController
|
||||
* @param controlI2C - control the I2C repeater locally
|
||||
* @throws UsbException - if unable to set any of the R820T registers
|
||||
*/
|
||||
private void setPLL( int frequency, boolean controlI2C ) throws UsbException
|
||||
private void setPLL( long frequency, boolean controlI2C ) throws UsbException
|
||||
{
|
||||
/* Set reference divider to 0 */
|
||||
writeR820TRegister( Register.REFERENCE_DIVIDER_2, (byte)0x00, controlI2C );
|
||||
@@ -970,16 +970,16 @@ public class R820TTunerController extends RTL2832TunerController
|
||||
RANGE_650( 650000000, 1766000000, 0x00, 0x40, 0x00, 0x00, 0x00 ),
|
||||
RANGE_UNK( 0, 0, 0, 0, 0, 0, 0 );
|
||||
|
||||
private int mMinFrequency;
|
||||
private int mMaxFrequency;
|
||||
private long mMinFrequency;
|
||||
private long mMaxFrequency;
|
||||
private int mOpenDrain;
|
||||
private int mRFMux_PolyMux;
|
||||
private int mTF_c;
|
||||
private int mXtalCap20p;
|
||||
private int mXtalCap10p;
|
||||
|
||||
private FrequencyRange( int minFrequency,
|
||||
int maxFrequency,
|
||||
private FrequencyRange( long minFrequency,
|
||||
long maxFrequency,
|
||||
int openDrain,
|
||||
int rfMuxPloy,
|
||||
int tf_c,
|
||||
@@ -995,12 +995,12 @@ public class R820TTunerController extends RTL2832TunerController
|
||||
mXtalCap10p = xtalCap10p;
|
||||
}
|
||||
|
||||
public boolean contains( int frequency )
|
||||
public boolean contains( long frequency )
|
||||
{
|
||||
return mMinFrequency <= frequency && frequency <= mMaxFrequency;
|
||||
}
|
||||
|
||||
public static FrequencyRange getRangeForFrequency( int frequency )
|
||||
public static FrequencyRange getRangeForFrequency( long frequency )
|
||||
{
|
||||
for( FrequencyRange range: values() )
|
||||
{
|
||||
@@ -1013,12 +1013,12 @@ public class R820TTunerController extends RTL2832TunerController
|
||||
return RANGE_UNK;
|
||||
}
|
||||
|
||||
public int getMinFrequency()
|
||||
public long getMinFrequency()
|
||||
{
|
||||
return mMinFrequency;
|
||||
}
|
||||
|
||||
public int getMaxFrequency()
|
||||
public long getMaxFrequency()
|
||||
{
|
||||
return mMaxFrequency;
|
||||
}
|
||||
@@ -1100,16 +1100,16 @@ public class R820TTunerController extends RTL2832TunerController
|
||||
|
||||
private int mDividerNumber;
|
||||
private int mMixerDivider;
|
||||
private int mMinimumFrequency;
|
||||
private int mMaximumFrequency;
|
||||
private long mMinimumFrequency;
|
||||
private long mMaximumFrequency;
|
||||
private int mRegisterSetting;
|
||||
private int mIntegralValue;
|
||||
private static final int mVCOPowerReference = 2;
|
||||
|
||||
private FrequencyDivider( int dividerNumber,
|
||||
int mixerDivider,
|
||||
int minimumFrequency,
|
||||
int maximumFrequency,
|
||||
long minimumFrequency,
|
||||
long maximumFrequency,
|
||||
int registerSetting,
|
||||
int integralValue )
|
||||
{
|
||||
@@ -1144,12 +1144,12 @@ public class R820TTunerController extends RTL2832TunerController
|
||||
return mMixerDivider;
|
||||
}
|
||||
|
||||
public int getMinimumFrequency()
|
||||
public long getMinimumFrequency()
|
||||
{
|
||||
return mMinimumFrequency;
|
||||
}
|
||||
|
||||
public int getMaximumFrequency()
|
||||
public long getMaximumFrequency()
|
||||
{
|
||||
return mMaximumFrequency;
|
||||
}
|
||||
@@ -1159,7 +1159,7 @@ public class R820TTunerController extends RTL2832TunerController
|
||||
return (byte)mRegisterSetting;
|
||||
}
|
||||
|
||||
public boolean contains( int frequency )
|
||||
public boolean contains( long frequency )
|
||||
{
|
||||
return mMinimumFrequency <= frequency &&
|
||||
frequency <= mMaximumFrequency;
|
||||
@@ -1172,7 +1172,7 @@ public class R820TTunerController extends RTL2832TunerController
|
||||
* @param frequency - desired frequency
|
||||
* @return - FrequencyDivider to use for the specified frequency
|
||||
*/
|
||||
public static FrequencyDivider fromFrequency( int frequency )
|
||||
public static FrequencyDivider fromFrequency( long frequency )
|
||||
{
|
||||
for( FrequencyDivider divider: FrequencyDivider.values() )
|
||||
{
|
||||
@@ -1188,11 +1188,11 @@ public class R820TTunerController extends RTL2832TunerController
|
||||
/**
|
||||
* Returns the integral to use for this frequency
|
||||
*/
|
||||
public Integral getIntegral( int frequency )
|
||||
public Integral getIntegral( long frequency )
|
||||
{
|
||||
if( contains( frequency ) )
|
||||
{
|
||||
int delta = frequency - mMinimumFrequency;
|
||||
int delta = (int)( frequency - mMinimumFrequency );
|
||||
|
||||
int integral = (int)Math.round( (double)delta /
|
||||
(double)mIntegralValue );
|
||||
@@ -1212,11 +1212,11 @@ public class R820TTunerController extends RTL2832TunerController
|
||||
* by the integral value to derive a 16-bit fractional value, returned
|
||||
* as an integer
|
||||
*/
|
||||
public int getSDM( Integral integral, int frequency )
|
||||
public int getSDM( Integral integral, long frequency )
|
||||
{
|
||||
if( contains( frequency ) )
|
||||
{
|
||||
int delta = frequency - ( integral.getNumber() * mIntegralValue );
|
||||
int delta = (int)( frequency - ( integral.getNumber() * mIntegralValue ) );
|
||||
|
||||
double fractional = (double)delta / (double)mIntegralValue;
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ public class R820TTunerEditorPanel extends JPanel implements FrequencyChangeList
|
||||
* apply end-user requested frequency changes against the tuner
|
||||
*/
|
||||
@Override
|
||||
public void frequencyChanged( final int frequency, int bandwidth )
|
||||
public void frequencyChanged( final long frequency, int bandwidth )
|
||||
{
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user