|
|
|
@ -143,7 +143,11 @@ void reset_settings(int m)
|
|
|
|
// setting.refer = -1; // do not reset reffer when switching modes
|
|
|
|
// setting.refer = -1; // do not reset reffer when switching modes
|
|
|
|
setting.mute = true;
|
|
|
|
setting.mute = true;
|
|
|
|
#ifdef __SPUR__
|
|
|
|
#ifdef __SPUR__
|
|
|
|
setting.spur_removal = 0;
|
|
|
|
#ifdef TINYSA4
|
|
|
|
|
|
|
|
setting.spur_removal = S_AUTO_OFF;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
setting.spur_removal = S_OFF;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
setting.mirror_masking = 0;
|
|
|
|
setting.mirror_masking = 0;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
switch(m) {
|
|
|
|
switch(m) {
|
|
|
|
@ -208,10 +212,10 @@ uint32_t calc_min_sweep_time_us(void) // Estimate minimum sweep time in
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
if (FREQ_IS_CW()) {
|
|
|
|
if (FREQ_IS_CW()) {
|
|
|
|
bare_sweep_time = MINIMUM_SWEEP_TIME; // minimum sweep time in fast CW mode
|
|
|
|
bare_sweep_time = MINIMUM_SWEEP_TIME; // minimum sweep time in fast CW mode
|
|
|
|
if (setting.repeat != 1 || setting.sweep_time_us >= 100*ONE_MS_TIME || setting.spur_removal != 0) // if no fast CW sweep possible
|
|
|
|
if (setting.repeat != 1 || setting.sweep_time_us >= 100*ONE_MS_TIME || S_STATE(setting.spur_removal)) // if no fast CW sweep possible
|
|
|
|
bare_sweep_time = 15000; // minimum CW sweep time when not in fast CW mode
|
|
|
|
bare_sweep_time = 15000; // minimum CW sweep time when not in fast CW mode
|
|
|
|
}
|
|
|
|
}
|
|
|
|
t = vbwSteps * (setting.spur_removal ? 2 : 1) * bare_sweep_time ; // factor in vbwSteps and spur impact
|
|
|
|
t = vbwSteps * (S_STATE(setting.spur_removal) ? 2 : 1) * bare_sweep_time ; // factor in vbwSteps and spur impact
|
|
|
|
t += (setting.repeat - 1)* REPEAT_TIME * (sweep_points); // Add time required for repeats
|
|
|
|
t += (setting.repeat - 1)* REPEAT_TIME * (sweep_points); // Add time required for repeats
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return t;
|
|
|
|
return t;
|
|
|
|
@ -645,6 +649,26 @@ void set_spur(int v)
|
|
|
|
// set_RBW(300);
|
|
|
|
// set_RBW(300);
|
|
|
|
dirty = true;
|
|
|
|
dirty = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void toggle_spur(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (setting.mode!=M_LOW)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
#ifdef TINYSA4
|
|
|
|
|
|
|
|
if (S_IS_AUTO(setting.spur_removal ))
|
|
|
|
|
|
|
|
setting.spur_removal = false;
|
|
|
|
|
|
|
|
else if (setting.spur_removal)
|
|
|
|
|
|
|
|
setting.spur_removal = S_AUTO_OFF;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
setting.spur_removal = true;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
if (S_STATE(setting.spur_removal ))
|
|
|
|
|
|
|
|
setting.spur_removal = S_OFF;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
setting.spur_removal = S_ON;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
dirty = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __ULTRA__
|
|
|
|
#ifdef __ULTRA__
|
|
|
|
@ -1335,7 +1359,7 @@ void update_rbw(void) // calculate the actual_rbw and the vbwSteps (#
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
actual_rbw_x10 = temp_actual_rbw_x10; // Now it fits in 16 bit
|
|
|
|
actual_rbw_x10 = temp_actual_rbw_x10; // Now it fits in 16 bit
|
|
|
|
#ifdef __SI4432__
|
|
|
|
#ifdef __SI4432__
|
|
|
|
if (setting.spur_removal && actual_rbw_x10 > 3000)
|
|
|
|
if (S_STATE(setting.spur_removal) && actual_rbw_x10 > 3000)
|
|
|
|
actual_rbw_x10 = 2500; // if spur suppression reduce max rbw to fit within BPF
|
|
|
|
actual_rbw_x10 = 2500; // if spur suppression reduce max rbw to fit within BPF
|
|
|
|
SI4432_Sel = MODE_SELECT(setting.mode);
|
|
|
|
SI4432_Sel = MODE_SELECT(setting.mode);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
@ -1574,13 +1598,13 @@ pureRSSI_t perform(bool break_on_operation, int i, uint32_t f, int tracking)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int modulation_delay = 0;
|
|
|
|
int modulation_delay = 0;
|
|
|
|
int modulation_index = 0;
|
|
|
|
int modulation_index = 0;
|
|
|
|
|
|
|
|
int spur_second_pass = false;
|
|
|
|
if (i == 0 && dirty ) { // if first point in scan and dirty
|
|
|
|
if (i == 0 && dirty ) { // if first point in scan and dirty
|
|
|
|
calculate_correction(); // pre-calculate correction factor dividers to avoid float division
|
|
|
|
calculate_correction(); // pre-calculate correction factor dividers to avoid float division
|
|
|
|
apply_settings(); // Initialize HW
|
|
|
|
apply_settings(); // Initialize HW
|
|
|
|
scandirty = true; // This is the first pass with new settings
|
|
|
|
scandirty = true; // This is the first pass with new settings
|
|
|
|
dirty = false;
|
|
|
|
dirty = false;
|
|
|
|
sweep_elapsed = chVTGetSystemTimeX(); // for measuring accumulated time
|
|
|
|
sweep_elapsed = chVTGetSystemTimeX(); // for measuring accumulated time
|
|
|
|
if (setting.spur_removal == -1) setting.spur_removal = 1; // ensure spur processing starts in right phase
|
|
|
|
|
|
|
|
// Set for actual time pre calculated value (update after sweep)
|
|
|
|
// Set for actual time pre calculated value (update after sweep)
|
|
|
|
setting.actual_sweep_time_us = calc_min_sweep_time_us();
|
|
|
|
setting.actual_sweep_time_us = calc_min_sweep_time_us();
|
|
|
|
// Change actual sweep time as user input if it greater minimum
|
|
|
|
// Change actual sweep time as user input if it greater minimum
|
|
|
|
@ -1749,8 +1773,8 @@ modulation_again:
|
|
|
|
goto skip_LO_setting; // No more LO changes required, save some time and jump over the code
|
|
|
|
goto skip_LO_setting; // No more LO changes required, save some time and jump over the code
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t local_IF;
|
|
|
|
uint32_t local_IF;
|
|
|
|
|
|
|
|
spur_second_pass = false;
|
|
|
|
again: // Spur reduction jumps to here for second measurement
|
|
|
|
again: // Spur reduction jumps to here for second measurement
|
|
|
|
|
|
|
|
|
|
|
|
local_IF=0; // to get rid of warning
|
|
|
|
local_IF=0; // to get rid of warning
|
|
|
|
if (MODE_HIGH(setting.mode)) {
|
|
|
|
if (MODE_HIGH(setting.mode)) {
|
|
|
|
@ -1771,17 +1795,17 @@ modulation_again:
|
|
|
|
stored_t[i] = -60.0; // Display when to do spur shift in the stored trace
|
|
|
|
stored_t[i] = -60.0; // Display when to do spur shift in the stored trace
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (setting.spur_removal){ // If in low input mode and spur reduction is on
|
|
|
|
if (S_STATE(setting.spur_removal)){ // If in low input mode and spur reduction is on
|
|
|
|
if (S_IS_AUTO(setting.below_IF) && (lf < local_IF / 2 || lf > local_IF) ) // if below 150MHz and auto_below_IF <-------------------TODO ---------------------
|
|
|
|
if (S_IS_AUTO(setting.below_IF) && (lf < local_IF / 2 || lf > local_IF) ) // if below 150MHz and auto_below_IF <-------------------TODO ---------------------
|
|
|
|
{ // else low/above IF
|
|
|
|
{ // else low/above IF
|
|
|
|
if (setting.spur_removal == 1)
|
|
|
|
if (spur_second_pass)
|
|
|
|
setting.below_IF = S_AUTO_ON; // use below IF in first pass
|
|
|
|
setting.below_IF = S_AUTO_ON; // use below IF in second pass
|
|
|
|
else
|
|
|
|
else
|
|
|
|
setting.below_IF = S_AUTO_OFF; // and above IF in second pass
|
|
|
|
setting.below_IF = S_AUTO_OFF; // and above IF in first pass
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (setting.spur_removal == -1) // If second spur pass
|
|
|
|
if (spur_second_pass) // If second spur pass
|
|
|
|
#ifdef __SI4432__
|
|
|
|
#ifdef __SI4432__
|
|
|
|
local_IF = local_IF + 500000; // apply IF spur shift
|
|
|
|
local_IF = local_IF + 500000; // apply IF spur shift
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
@ -1796,11 +1820,11 @@ modulation_again:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef __ULTRA__
|
|
|
|
#ifdef __ULTRA__
|
|
|
|
} else if (setting.mode == M_ULTRA) { // No above/below IF mode in Ultra
|
|
|
|
} else if (setting.mode == M_ULTRA) { // No above/below IF mode in Ultra
|
|
|
|
local_IF = setting.frequency_IF + (int)(actual_rbw < 350.0 ? setting.spur_removal*300000 : 0 );
|
|
|
|
local_IF = setting.frequency_IF + (int)(actual_rbw < 350.0 ? S_STATE(setting.spur_removal)*300000 : 0 );
|
|
|
|
#ifdef __SI4432__
|
|
|
|
#ifdef __SI4432__
|
|
|
|
set_freq (SI4432_RX , local_IF);
|
|
|
|
set_freq (SI4432_RX , local_IF);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
// local_IF = setting.frequency_IF + (int)(actual_rbw < 300.0?setting.spur_removal * 1000 * actual_rbw:0);
|
|
|
|
// local_IF = setting.frequency_IF + (int)(actual_rbw < 300.0?S_STATE(setting.spur_removal) * 1000 * actual_rbw:0);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1811,7 +1835,7 @@ modulation_again:
|
|
|
|
// if (lf > 3406000000 )
|
|
|
|
// if (lf > 3406000000 )
|
|
|
|
// setFreq (1, local_IF/5 + lf/5);
|
|
|
|
// setFreq (1, local_IF/5 + lf/5);
|
|
|
|
// else
|
|
|
|
// else
|
|
|
|
if (setting.spur_removal != 1) { // Left of tables
|
|
|
|
if (S_STATE(setting.spur_removal) != 1) { // Left of tables
|
|
|
|
if (lf > 3250000000 )
|
|
|
|
if (lf > 3250000000 )
|
|
|
|
set_freq (SI4432_LO , lf/5 - local_IF/5);
|
|
|
|
set_freq (SI4432_LO , lf/5 - local_IF/5);
|
|
|
|
if (lf > 1250000000 )
|
|
|
|
if (lf > 1250000000 )
|
|
|
|
@ -1875,7 +1899,7 @@ modulation_again:
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __SI4432__
|
|
|
|
#ifdef __SI4432__
|
|
|
|
#ifdef __FAST_SWEEP__
|
|
|
|
#ifdef __FAST_SWEEP__
|
|
|
|
if (i == 0 && setting.frequency_step == 0 && setting.trigger == T_AUTO && setting.spur_removal == 0 && SI4432_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < 100*ONE_MS_TIME) {
|
|
|
|
if (i == 0 && setting.frequency_step == 0 && setting.trigger == T_AUTO && S_STATE(setting.spur_removal) == 0 && SI4432_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < 100*ONE_MS_TIME) {
|
|
|
|
// if ultra fast scanning is needed prefill the SI4432 RSSI read buffer
|
|
|
|
// if ultra fast scanning is needed prefill the SI4432 RSSI read buffer
|
|
|
|
SI4432_Fill(MODE_SELECT(setting.mode), 0);
|
|
|
|
SI4432_Fill(MODE_SELECT(setting.mode), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1929,7 +1953,7 @@ modulation_again:
|
|
|
|
}while(1);
|
|
|
|
}while(1);
|
|
|
|
#ifdef __FAST_SWEEP__
|
|
|
|
#ifdef __FAST_SWEEP__
|
|
|
|
#ifdef __SI4432__
|
|
|
|
#ifdef __SI4432__
|
|
|
|
if (setting.spur_removal == 0 && SI4432_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < 100*ONE_MS_TIME) {
|
|
|
|
if (S_STATE(setting.spur_removal) == 0 && SI4432_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < 100*ONE_MS_TIME) {
|
|
|
|
SI4432_Fill(MODE_SELECT(setting.mode), 1); // fast mode possible to pre-fill RSSI buffer
|
|
|
|
SI4432_Fill(MODE_SELECT(setting.mode), 1); // fast mode possible to pre-fill RSSI buffer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
@ -1946,13 +1970,16 @@ modulation_again:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef __SPUR__
|
|
|
|
#ifdef __SPUR__
|
|
|
|
static pureRSSI_t spur_RSSI = -1; // Initialization only to avoid warning.
|
|
|
|
static pureRSSI_t spur_RSSI = -1; // Initialization only to avoid warning.
|
|
|
|
if (setting.spur_removal == 1) { // If first spur pass
|
|
|
|
if (S_STATE(setting.spur_removal)) {
|
|
|
|
spur_RSSI = pureRSSI; // remember measure RSSI
|
|
|
|
if (!spur_second_pass) { // If first spur pass
|
|
|
|
setting.spur_removal = -1;
|
|
|
|
spur_RSSI = pureRSSI; // remember measure RSSI
|
|
|
|
goto again; // Skip all other processing
|
|
|
|
spur_second_pass = true;
|
|
|
|
} else if (setting.spur_removal == -1) { // If second spur pass
|
|
|
|
goto again; // Skip all other processing
|
|
|
|
pureRSSI = ( pureRSSI < spur_RSSI ? pureRSSI : spur_RSSI); // Take minimum of two
|
|
|
|
} else { // If second spur pass
|
|
|
|
setting.spur_removal = 1; // and prepare for next call of perform.
|
|
|
|
pureRSSI = ( pureRSSI < spur_RSSI ? pureRSSI : spur_RSSI); // Take minimum of two
|
|
|
|
|
|
|
|
if (S_IS_AUTO(setting.below_IF))
|
|
|
|
|
|
|
|
setting.below_IF = S_AUTO_OFF; // make sure it is off for next pass
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
@ -3076,7 +3103,11 @@ common_silent:
|
|
|
|
setting.step_delay_mode = SD_PRECISE;
|
|
|
|
setting.step_delay_mode = SD_PRECISE;
|
|
|
|
// set_step_delay(1); // Precise scanning speed
|
|
|
|
// set_step_delay(1); // Precise scanning speed
|
|
|
|
#ifdef __SPUR__
|
|
|
|
#ifdef __SPUR__
|
|
|
|
setting.spur_removal = 1;
|
|
|
|
#ifdef TINYSA4
|
|
|
|
|
|
|
|
setting.spur_removal = S_AUTO_OFF;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
setting.spur_removal = S_OFF;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
common:
|
|
|
|
common:
|
|
|
|
|
|
|
|
|
|
|
|
@ -3094,7 +3125,7 @@ common_silent:
|
|
|
|
dirty = true;
|
|
|
|
dirty = true;
|
|
|
|
// set_step_delay(1); // Do not set !!!!!
|
|
|
|
// set_step_delay(1); // Do not set !!!!!
|
|
|
|
#ifdef __SPUR__
|
|
|
|
#ifdef __SPUR__
|
|
|
|
setting.spur_removal = 1;
|
|
|
|
setting.spur_removal = S_ON;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
goto common;
|
|
|
|
goto common;
|
|
|
|
@ -3282,7 +3313,7 @@ void self_test(int test)
|
|
|
|
j = setting.test_argument;
|
|
|
|
j = setting.test_argument;
|
|
|
|
// do_again:
|
|
|
|
// do_again:
|
|
|
|
test_prepare(TEST_RBW);
|
|
|
|
test_prepare(TEST_RBW);
|
|
|
|
setting.spur_removal = 0;
|
|
|
|
setting.spur_removal = S_OFF;
|
|
|
|
#if 1 // Disable for offset baseline scanning
|
|
|
|
#if 1 // Disable for offset baseline scanning
|
|
|
|
setting.step_delay_mode = SD_NORMAL;
|
|
|
|
setting.step_delay_mode = SD_NORMAL;
|
|
|
|
setting.repeat = 1;
|
|
|
|
setting.repeat = 1;
|
|
|
|
@ -3319,7 +3350,7 @@ void self_test(int test)
|
|
|
|
#if 1 // Enable for step delay tuning
|
|
|
|
#if 1 // Enable for step delay tuning
|
|
|
|
while (setting.step_delay > 10 && test_value != 0 && test_value > saved_peakLevel - 0.5) {
|
|
|
|
while (setting.step_delay > 10 && test_value != 0 && test_value > saved_peakLevel - 0.5) {
|
|
|
|
test_prepare(TEST_RBW);
|
|
|
|
test_prepare(TEST_RBW);
|
|
|
|
setting.spur_removal = 0;
|
|
|
|
setting.spur_removal = S_OFF;
|
|
|
|
setting.step_delay_mode = SD_NORMAL;
|
|
|
|
setting.step_delay_mode = SD_NORMAL;
|
|
|
|
setting.step_delay = setting.step_delay * 4 / 5;
|
|
|
|
setting.step_delay = setting.step_delay * 4 / 5;
|
|
|
|
if (setting.rbw_x10 < 1000)
|
|
|
|
if (setting.rbw_x10 < 1000)
|
|
|
|
@ -3346,7 +3377,7 @@ void self_test(int test)
|
|
|
|
test_prepare(TEST_RBW);
|
|
|
|
test_prepare(TEST_RBW);
|
|
|
|
setting.step_delay_mode = SD_FAST;
|
|
|
|
setting.step_delay_mode = SD_FAST;
|
|
|
|
setting.offset_delay /= 2;
|
|
|
|
setting.offset_delay /= 2;
|
|
|
|
setting.spur_removal = 0;
|
|
|
|
setting.spur_removal = S_OFF;
|
|
|
|
if (setting.rbw_x10 < 1000)
|
|
|
|
if (setting.rbw_x10 < 1000)
|
|
|
|
set_sweep_frequency(ST_SPAN, (uint32_t)(setting.rbw_x10 * 5000)); // 50 times RBW
|
|
|
|
set_sweep_frequency(ST_SPAN, (uint32_t)(setting.rbw_x10 * 5000)); // 50 times RBW
|
|
|
|
else
|
|
|
|
else
|
|
|
|
|