@ -534,11 +553,11 @@ void set_level(float v) // Set the output level in dB in high/low output
{
if(setting.mode==M_GENHIGH){
intd=0;
while (drive_dBm[d] < v - 1 && d < 16)
d++;
if (d == 8 && v < -12) // Round towards closest level
d = 7;
set_rx_drive(d);
// while (drive_dBm[d] < v - 1 && d < 16)
// d++;
// if (d == 8 && v < -12) // Round towards closest level
// d = 7;
set_lo_drive(v);
}else{
setting.level=v;
set_attenuation((int)v);
@ -550,15 +569,15 @@ void set_attenuation(float a) // Is used both in low output mode and high/
{
if(setting.mode==M_GENLOW){
a=a+POWER_OFFSET;
if(a>6){// +9dB
if(a>2*SI_DRIVE_STEP){// +9dB
setting.rx_drive=11;// Maximum save drive for SAW filters.
a=a-9;
}elseif(a>3){// +6dB
a=a-3*SI_DRIVE_STEP;
}elseif(a>SI_DRIVE_STEP){// +6dB
setting.rx_drive=10;
a=a-6;
a=a-2*SI_DRIVE_STEP;
}elseif(a>0){// +3dB
setting.rx_drive=9;
a=a-3;
a=a-SI_DRIVE_STEP;
}else
setting.rx_drive=8;// defined as 0dB level
if(a>0)
@ -1373,8 +1392,7 @@ void set_freq(int V, unsigned long freq) // translate the requested frequency
#else
{
#endif
SI4463_set_freq(target_f);// Also sets offset to zero
real_old_freq[V]=target_f;
real_old_freq[V]=SI4463_set_freq(target_f);// Also sets offset to zero
}
#else
SI4432_Set_Frequency(freq);// Impossible to use offset so set SI4432 to new frequency
@ -1384,8 +1402,7 @@ void set_freq(int V, unsigned long freq) // translate the requested frequency
#endif
}
}else{
SI4463_set_freq(freq);// Not in fast mode
real_old_freq[V]=freq;
real_old_freq[V]=SI4463_set_freq(freq);// Not in fast mode
}
}
old_freq[V]=freq;
@ -1437,10 +1454,18 @@ case M_ULTRA:
#endif
#ifdef __SI4463__
SI4463_init_rx();// Must be before ADF4351_setup!!!!
if(setting.atten_step){// use switch as attenuator
enable_rx_output(true);
}else{
enable_rx_output(false);
}
#endif
set_AGC_LNA();
ADF4351_enable(true);
ADF4351_drive(setting.lo_drive);
if(setting.tracking_output)
ADF4351_enable_aux_out(true);
else
ADF4351_enable_aux_out(false);
ADF4351_enable_out(true);
@ -1482,12 +1507,14 @@ mute:
ADF4351_enable_aux_out(false);
ADF4351_enable_out(false);
ADF4351_enable(false);
if(setting.atten_step){// use switch as attenuator
enable_rx_output(true);
}else{
enable_rx_output(false);
}
enable_high(true);
enable_extra_lna(false);
enable_ultra(false);
break;
caseM_GENLOW:// Mixed output from 0
if(setting.mute)
@ -1545,9 +1572,10 @@ case M_GENHIGH: // Direct output from 1
SI4432_Transmit(setting.lo_drive);
#endif
#ifdef __HIGH_OUT_ADF4351__
if(high_out_adf4350){
#ifdef __SI4468__
SI4463_init_rx();
enable_rx_output(true);// to protext the SI
#endif
ADF4351_enable(true);
#ifndef TINYSA4_PROTO
@ -1558,14 +1586,21 @@ case M_GENHIGH: // Direct output from 1
ADF4351_enable_out(true);// Must be enabled to have aux output
#endif
ADF4351_aux_drive(setting.lo_drive);
#else
}else{
ADF4351_enable_aux_out(false);
ADF4351_enable_out(false);
#ifdef __SI4468__
// SI4463_set_output_level(setting.rx_drive);
SI4463_init_tx();
#endif
#endif
if(setting.lo_drive<32){
enable_rx_output(false);// use switch as attenuator
}else{
enable_rx_output(true);
}
SI4463_set_output_level(setting.lo_drive&0x01F);
#endif
}
enable_high(true);
enable_extra_lna(false);
enable_ultra(false);
@ -1576,8 +1611,8 @@ case M_GENHIGH: // Direct output from 1
voidupdate_rbw(void)// calculate the actual_rbw and the vbwSteps (# steps in between needed if frequency step is largen than maximum rbw)
{
vbwSteps=1;// starting number for all modes
if(!MODE_INPUT(setting.mode)){
vbwSteps=1;
actual_rbw_x10=1;// To force substepping of the SI4463
return;
}
@ -1625,15 +1660,15 @@ void update_rbw(void) // calculate the actual_rbw and the vbwSteps (#
// actual_rbw_x10 = 3000; // if spur suppression reduce max rbw to fit within BPF
#endif
actual_rbw_x10=set_rbw(actual_rbw_x10);// see what rbw the SI4432 can realize
if(setting.vbw_x10>actual_rbw_x10&&setting.frequency_step>0&&MODE_INPUT(setting.mode)){// When doing frequency scanning in input mode
vbwSteps=(setting.vbw_x10/actual_rbw_x10)+1;//((int)(2 * (setting.vbw_x10 + (actual_rbw_x10/8)) / actual_rbw_x10)); // calculate # steps in between each frequency step due to rbw being less than frequency step
if(setting.frequency_step>0&&MODE_INPUT(setting.mode)){// When doing frequency scanning in input mode
if(setting.vbw_x10>actual_rbw_x10)
vbwSteps=1+(setting.vbw_x10/actual_rbw_x10);//((int)(2 * (setting.vbw_x10 + (actual_rbw_x10/8)) / actual_rbw_x10)); // calculate # steps in between each frequency step due to rbw being less than frequency step
if(vbwSteps<1)// at least one step, should never happen
vbwSteps=1;
if(setting.step_delay_mode==SD_PRECISE)// if in Precise scanning
vbwSteps*=2;// use twice as many steps
if(vbwSteps<1)// at least one step
vbwSteps=1;
}else{// in all other modes
setting.vbw_x10=actual_rbw_x10;
vbwSteps=1;// only one vbwSteps
}
}
@ -1742,14 +1777,15 @@ search_maximum(int m, int center, int span)
}
//static int spur_old_stepdelay = 0;
staticconstunsignedintspur_IF=DEFAULT_IF;// The IF frequency for which the spur table is value
staticconstunsignedintspur_alternate_IF=DEFAULT_SPUR_IF;// if the frequency is found in the spur table use this IF frequency
staticconst int spur_table[]=// Frequencies to avoid
//static const unsigned int spur_IF = DEFAULT_IF; // The IF frequency for which the spur table is value
//static const unsigned int spur_alternate_IF = DEFAULT_SPUR_IF; // if the frequency is found in the spur table use this IF frequency
staticconstuint32_t spur_table[]=// Frequencies to avoid
{
117716000,
243781200,
243775000,
244250000,
325666667,
324875000,
325190000,
487541650,// This is linked to the MODULO of the ADF4350
// 487993000,
// 488020700,
@ -1759,8 +1795,7 @@ static const int spur_table[] = // Frequencies t
650700000,
651333333,
732750000,
746083000,
977000000
746083000
/*
*144.3
*159
@ -1808,12 +1843,12 @@ static const int spur_table[] = // Frequencies t