Update ultra switches

Removed_REF_marker
erikkaashoek 5 years ago
parent 0f6c3c77a5
commit 27799c8bc3

@ -1009,7 +1009,7 @@ config_t config = {
.vbat_offset = 220, .vbat_offset = 220,
.frequency_IF1 = DEFAULT_IF, .frequency_IF1 = DEFAULT_IF,
.frequency_IF2 = 0, .frequency_IF2 = 0,
.ultra_threshold = 800000000, .ultra_threshold = 750000000,
.low_level_offset = 100.0, // Uncalibrated .low_level_offset = 100.0, // Uncalibrated
.high_level_offset = 100.0, // Uncalibrated .high_level_offset = 100.0, // Uncalibrated
.low_level_output_offset = 0.0, // Uncalibrated .low_level_output_offset = 0.0, // Uncalibrated
@ -1022,7 +1022,7 @@ config_t config = {
.cor_am = 0, .cor_am = 0,
.cor_wfm = 0, .cor_wfm = 0,
.cor_nfm = 0, .cor_nfm = 0,
.ultra = true, .ultra = false,
.high_out_adf4350 = true, .high_out_adf4350 = true,
.ext_zero_level = 174, .ext_zero_level = 174,
#endif #endif

@ -275,9 +275,10 @@ extern float level_max;
extern float level_range; extern float level_range;
extern float channel_power[3]; extern float channel_power[3];
extern float channel_power_watt[3]; extern float channel_power_watt[3];
extern const char * const unit_string[]; extern const char * const unit_string[];
#ifdef TINYSA4 #ifdef TINYSA4
extern freq_t ultra_threshold;
extern bool ultra;
extern float *drive_dBm; extern float *drive_dBm;
#else #else
extern const int8_t drive_dBm []; extern const int8_t drive_dBm [];

@ -49,6 +49,8 @@ static float old_a = -150; // cached value to reduce writes to level re
int spur_gate = 100; int spur_gate = 100;
#ifdef TINYSA4 #ifdef TINYSA4
freq_t ultra_threshold;
bool ultra;
int noise_level; int noise_level;
uint32_t old_CFGR; uint32_t old_CFGR;
uint32_t orig_CFGR; uint32_t orig_CFGR;
@ -130,7 +132,7 @@ void update_min_max_freq(void)
case M_LOW: case M_LOW:
minFreq = 0; minFreq = 0;
#ifdef TINYSA4 #ifdef TINYSA4
if (config.ultra) if (ultra)
maxFreq = 9900000000.0; // ULTRA_MAX_FREQ; // make use of harmonic mode above ULTRA_MAX_FREQ maxFreq = 9900000000.0; // ULTRA_MAX_FREQ; // make use of harmonic mode above ULTRA_MAX_FREQ
else else
maxFreq = LOW_MAX_FREQ; maxFreq = LOW_MAX_FREQ;
@ -172,6 +174,8 @@ void reset_settings(int m)
// strcpy((char *)spi_buffer, dummy); // strcpy((char *)spi_buffer, dummy);
setting.mode = m; setting.mode = m;
#ifdef TINYSA4 #ifdef TINYSA4
ultra_threshold = config.ultra_threshold;
ultra = config.ultra;
drive_dBm = (float *) (setting.mode == M_GENHIGH && config.high_out_adf4350 ? adf_drive_dBm : si_drive_dBm); drive_dBm = (float *) (setting.mode == M_GENHIGH && config.high_out_adf4350 ? adf_drive_dBm : si_drive_dBm);
#endif #endif
update_min_max_freq(); update_min_max_freq();
@ -256,7 +260,7 @@ void reset_settings(int m)
case M_LOW: case M_LOW:
set_sweep_frequency(ST_START, minFreq); set_sweep_frequency(ST_START, minFreq);
set_sweep_frequency(ST_STOP, maxFreq); set_sweep_frequency(ST_STOP, maxFreq);
// if (config.ultra) // if (ultra)
// set_sweep_frequency(ST_STOP, 2900000000); // TODO <----------------- temp ---------------------- // set_sweep_frequency(ST_STOP, 2900000000); // TODO <----------------- temp ----------------------
// else // else
#ifdef TINYSA4 #ifdef TINYSA4
@ -2553,12 +2557,11 @@ modulation_again:
} }
#ifdef TINYSA4 #ifdef TINYSA4
// -------------- set ultra --------------------------------- // -------------- set ultra ---------------------------------
if (setting.mode == M_LOW && config.ultra) { if (setting.mode == M_LOW && ultra && f > ultra_threshold) {
if ((S_IS_AUTO(setting.ultra)&& f > config.ultra_threshold) || S_STATE(setting.ultra) ) { enable_ultra(true);
enable_ultra(true);
} else
enable_ultra(false);
} }
else
enable_ultra(false);
#endif #endif
// -------------------------------- Acquisition loop for one requested frequency covering spur avoidance and vbwsteps ------------------------ // -------------------------------- Acquisition loop for one requested frequency covering spur avoidance and vbwsteps ------------------------
pureRSSI_t RSSI = float_TO_PURE_RSSI(-150); pureRSSI_t RSSI = float_TO_PURE_RSSI(-150);
@ -2624,8 +2627,8 @@ again: // Spur redu
#else #else
local_IF = DEFAULT_IF; local_IF = DEFAULT_IF;
#endif #endif
} }
if (setting.mode == M_LOW) { if (setting.mode == M_LOW) {
if (tracking) { // VERY SPECIAL CASE!!!!! Measure BPF if (tracking) { // VERY SPECIAL CASE!!!!! Measure BPF
#if 0 // Isolation test #if 0 // Isolation test
local_IF = lf; local_IF = lf;
@ -2635,17 +2638,9 @@ again: // Spur redu
lf = (setting.refer == -1 ? 0 : reffer_freq[setting.refer]); lf = (setting.refer == -1 ? 0 : reffer_freq[setting.refer]);
#endif #endif
} else { } else {
#ifdef TINYSA3
if(!in_selftest && avoid_spur(lf)) { // check if alternate IF is needed to avoid spur.
local_IF = spur_alternate_IF;
if (debug_avoid){ // For debugging the spur avoidance control
stored_t[i] = -60.0; // Display when to do spur shift in the stored trace
}
}
#endif
#ifdef __SI4468__ #ifdef __SI4468__
if (S_IS_AUTO(setting.spur_removal)) { if (S_IS_AUTO(setting.spur_removal)) {
if (lf >= config.ultra_threshold) { if (ultra && lf >= ultra_threshold) {
setting.spur_removal= S_AUTO_ON; setting.spur_removal= S_AUTO_ON;
} else { } else {
setting.spur_removal= S_AUTO_OFF; setting.spur_removal= S_AUTO_OFF;
@ -2689,8 +2684,16 @@ again: // Spur redu
} }
} }
} }
#ifdef TINYSA3
else if(!in_selftest && avoid_spur(lf)) { // check if alternate IF is needed to avoid spur.
local_IF = spur_alternate_IF;
if (debug_avoid){ // For debugging the spur avoidance control
stored_t[i] = -60.0; // Display when to do spur shift in the stored trace
}
}
#endif
#ifdef TINYSA4 #ifdef TINYSA4
else if(!in_selftest && avoid_spur(lf) && S_IS_AUTO(setting.spur_removal)) { // check if alternate IF is needed to avoid spur. else if(!in_selftest && avoid_spur(lf)) { // check if alternate IF is needed to avoid spur.
if (S_IS_AUTO(setting.below_IF) && lf < local_IF/2 - 1000000) { if (S_IS_AUTO(setting.below_IF) && lf < local_IF/2 - 1000000) {
setting.below_IF = S_AUTO_ON; setting.below_IF = S_AUTO_ON;
// local_IF = local_IF + DEFAULT_SPUR_OFFSET/2; // No spure removal and no spur, center in IF // local_IF = local_IF + DEFAULT_SPUR_OFFSET/2; // No spure removal and no spur, center in IF
@ -2704,11 +2707,11 @@ again: // Spur redu
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
else else
{ {
local_IF = local_IF; // + DEFAULT_SPUR_OFFSET/2; // No spure removal and no spur, center in IF local_IF = local_IF; // + DEFAULT_SPUR_OFFSET/2; // No spure removal and no spur, center in IF
} }
#endif
} }
} else { // Output mode } else { // Output mode
if (setting.modulation == MO_EXTERNAL) // VERY SPECIAL CASE !!!!!! LO input via high port if (setting.modulation == MO_EXTERNAL) // VERY SPECIAL CASE !!!!!! LO input via high port
@ -4389,8 +4392,8 @@ void test_prepare(int i)
setting.atten_step = false; setting.atten_step = false;
#ifdef TINYSA4 #ifdef TINYSA4
setting.frequency_IF = config.frequency_IF1; // Default frequency setting.frequency_IF = config.frequency_IF1; // Default frequency
config.ultra = true; ultra = true;
config.ultra_threshold = 2000000000; ultra_threshold = 2000000000;
setting.extra_lna = false; setting.extra_lna = false;
#else #else
setting.frequency_IF = DEFAULT_IF; // Default frequency setting.frequency_IF = DEFAULT_IF; // Default frequency
@ -4479,7 +4482,7 @@ common_silent:
switch(test_case[i].setup) { // Prepare test conditions switch(test_case[i].setup) { // Prepare test conditions
#ifdef TINYSA4 #ifdef TINYSA4
case TP_30MHZ_ULTRA: case TP_30MHZ_ULTRA:
config.ultra_threshold = 0; ultra_threshold = 0;
break; break;
case TP_30MHZ_LNA: case TP_30MHZ_LNA:
setting.extra_lna = true; setting.extra_lna = true;
@ -4523,8 +4526,6 @@ int add_spur(int f)
//static bool test_wait = false; //static bool test_wait = false;
static int test_step = 0; static int test_step = 0;
freq_t old_ultra_threshold;
bool old_ultra;
void self_test(int test) void self_test(int test)
{ {
@ -4537,10 +4538,6 @@ void self_test(int test)
else else
goto resume; goto resume;
} }
#ifdef TINYSA4
old_ultra_threshold = config.ultra_threshold;
old_ultra = config.ultra;
#endif
// Disable waterfall on selftest // Disable waterfall on selftest
if (setting.waterfall) if (setting.waterfall)
disable_waterfall(); disable_waterfall();
@ -4597,9 +4594,6 @@ void self_test(int test)
ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN); ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN);
ili9341_drawstring_7x13("Self test complete", 50, 200); ili9341_drawstring_7x13("Self test complete", 50, 200);
ili9341_drawstring_7x13("Touch screen to continue", 50, 215); ili9341_drawstring_7x13("Touch screen to continue", 50, 215);
#ifdef TINYSA4
config.ultra_threshold = 700000000; // just in case the restore fails. Should not be needed
#endif
resume2: resume2:
test_wait = true; test_wait = true;
if (!check_touched()) if (!check_touched())
@ -4613,10 +4607,6 @@ quit:
config.cor_am = 0; config.cor_am = 0;
config.cor_nfm = 0; config.cor_nfm = 0;
config.cor_wfm = 0; config.cor_wfm = 0;
#endif
#ifdef TINYSA4
config.ultra_threshold = old_ultra_threshold;
config.ultra = old_ultra;
#endif #endif
reset_settings(M_LOW); reset_settings(M_LOW);
set_refer_output(-1); set_refer_output(-1);
@ -4965,7 +4955,6 @@ void calibrate(void)
int old_sweep_points = setting._sweep_points; int old_sweep_points = setting._sweep_points;
in_selftest = true; in_selftest = true;
#ifdef TINYSA4 #ifdef TINYSA4
freq_t old_ultra_threshold = config.ultra_threshold;
setting.test_argument = -7; setting.test_argument = -7;
self_test(0); self_test(0);
int if_error = peakFreq - 30000000; int if_error = peakFreq - 30000000;
@ -5053,9 +5042,6 @@ quit:
wait_user(); wait_user();
ili9341_clear_screen(); ili9341_clear_screen();
set_sweep_points(old_sweep_points); set_sweep_points(old_sweep_points);
#ifdef TINYSA4
config.ultra_threshold = old_ultra_threshold;
#endif
in_selftest = false; in_selftest = false;
sweep_mode = SWEEP_ENABLE; sweep_mode = SWEEP_ENABLE;
set_refer_output(-1); set_refer_output(-1);

@ -894,12 +894,10 @@ static UI_FUNCTION_ADV_CALLBACK(menu_ultra_acb)
ui_mode_keypad(KM_CENTER); ui_mode_keypad(KM_CENTER);
if (uistat.value != 4321) if (uistat.value != 4321)
return; return;
set_sweep_frequency(ST_START, 0);
set_sweep_frequency(ST_STOP, 3000000000ULL);
} }
config.ultra = !config.ultra; config.ultra = !config.ultra;
update_min_max_freq(); config_save();
reset_settings(M_LOW);
if (config.ultra){ if (config.ultra){
set_sweep_frequency(ST_START, 0); set_sweep_frequency(ST_START, 0);
set_sweep_frequency(ST_STOP, 3000000000ULL); set_sweep_frequency(ST_STOP, 3000000000ULL);
@ -1497,7 +1495,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_settings_below_if_acb){
toggle_below_IF(); toggle_below_IF();
} }
#ifdef TINYSA4 #if 0
static UI_FUNCTION_ADV_CALLBACK(menu_settings_ultra_acb){ static UI_FUNCTION_ADV_CALLBACK(menu_settings_ultra_acb){
(void)item; (void)item;
(void)data; (void)data;
@ -2003,7 +2001,7 @@ static const menuitem_t menu_settings3[] =
{ MT_KEYPAD, KM_R, "R", "Set R"}, { MT_KEYPAD, KM_R, "R", "Set R"},
{ MT_KEYPAD, KM_MOD, "MODULO", "Set MODULO"}, { MT_KEYPAD, KM_MOD, "MODULO", "Set MODULO"},
{ MT_KEYPAD, KM_CP, "CP", "Set CP"}, { MT_KEYPAD, KM_CP, "CP", "Set CP"},
{ MT_ADV_CALLBACK | MT_LOW, 0, "ULTRA\nMODE", menu_settings_ultra_acb}, // { MT_ADV_CALLBACK | MT_LOW, 0, "ULTRA\nMODE", menu_settings_ultra_acb},
#ifdef __HAM_BAND__ #ifdef __HAM_BAND__
{ MT_ADV_CALLBACK, 0, "HAM\nBANDS", menu_settings_ham_bands}, { MT_ADV_CALLBACK, 0, "HAM\nBANDS", menu_settings_ham_bands},
#endif #endif
@ -2582,6 +2580,7 @@ set_numeric_value(void)
case KM_LPF: case KM_LPF:
config.ultra_threshold = uistat.value; config.ultra_threshold = uistat.value;
config_save(); config_save();
ultra_threshold = config.ultra_threshold;
break; break;
#endif #endif
#ifdef __LIMITS__ #ifdef __LIMITS__

Loading…
Cancel
Save

Powered by TurnKey Linux.