Repair CSV load bug

pull/96/head
erikkaashoek 1 year ago committed by Bohdan Kmit
parent cdff76c399
commit f7a52259af

@ -156,7 +156,7 @@ typedef uint32_t freq_t;
typedef uint64_t freq_t; typedef uint64_t freq_t;
#define FREQ_MULTIPLIER 100 // Multiplier of the 30MHz reference to get accurate frequency correction #define FREQ_MULTIPLIER 100 // Multiplier of the 30MHz reference to get accurate frequency correction
#define VARIANT(X,Y) (Y) #define VARIANT(X,Y) (Y)
#define DEFAULT_IF ((freq_t)977900000) #define DEFAULT_IF ((freq_t)977400000)
#define DEFAULT_IF_PLUS ((freq_t)1070100000) #define DEFAULT_IF_PLUS ((freq_t)1070100000)
extern uint16_t hw_if; extern uint16_t hw_if;
#define DEFAULT_SPUR_OFFSET ((freq_t)(actual_rbw_x10 > 3000 ? 1500000 : 1000000)) #define DEFAULT_SPUR_OFFSET ((freq_t)(actual_rbw_x10 > 3000 ? 1500000 : 1000000))
@ -1493,8 +1493,8 @@ typedef struct properties {
//sizeof(properties_t) == 0x1200 //sizeof(properties_t) == 0x1200
#define CONFIG_MAGIC 0x434f4e6a #define CONFIG_MAGIC 0x434f4e6b
#define SETTING_MAGIC 0x434f4e6a #define SETTING_MAGIC 0x434f4e6b
extern int16_t lastsaveid; extern int16_t lastsaveid;
//extern properties_t *active_props; //extern properties_t *active_props;

@ -387,7 +387,7 @@ void set_output_path(freq_t f, float level)
SI4463_init_tx(); SI4463_init_tx();
break; break;
} }
setting.spur_removal &= 0xFE;
} }
static void calculate_static_correction(void); static void calculate_static_correction(void);
@ -412,14 +412,15 @@ void set_input_path(freq_t f)
else if(config.ultra && ((config.ultra_start == ULTRA_AUTO && f > ultra_start) || (config.ultra_start != ULTRA_AUTO && f >config.ultra_start))) { else if(config.ultra && ((config.ultra_start == ULTRA_AUTO && f > ultra_start) || (config.ultra_start != ULTRA_AUTO && f >config.ultra_start))) {
LO_harmonic = (f > (config.harmonic_start?config.harmonic_start:ULTRA_MAX_FREQ)); LO_harmonic = (f > (config.harmonic_start?config.harmonic_start:ULTRA_MAX_FREQ));
signal_path = PATH_ULTRA; signal_path = PATH_ULTRA;
} else } else {
signal_path = PATH_LOW; signal_path = PATH_LOW;
}
if (signal_path == PATH_HIGH) { if (signal_path == PATH_HIGH) {
return; // TODO setup high input path return; // TODO setup high input path
} }
enable_rx_output(setting.atten_step); enable_rx_output(setting.atten_step);
bool mirrors = false;
switch(signal_path) { switch(signal_path) {
case PATH_LOW: case PATH_LOW:
enable_ultra(false); enable_ultra(false);
@ -441,6 +442,7 @@ void set_input_path(freq_t f)
goto common2; goto common2;
case PATH_ULTRA: case PATH_ULTRA:
mirrors = true;
enable_ultra(true); enable_ultra(true);
enable_high(false); enable_high(false);
enable_direct(false); enable_direct(false);
@ -454,6 +456,12 @@ void set_input_path(freq_t f)
} }
if (force_signal_path) if (force_signal_path)
calculate_static_correction(); calculate_static_correction();
if (S_IS_AUTO(setting.spur_removal)) {
if (mirrors)
setting.spur_removal |= 0x01;
else
setting.spur_removal &= 0xFE;
}
} }
#endif #endif
@ -3139,6 +3147,7 @@ static const freq_t static_spur_table_plus[] = // Valid for IF=977.4MHz
#define MAX_DYNAMIC_SPUR_TABLE_SIZE 100 #define MAX_DYNAMIC_SPUR_TABLE_SIZE 100
static freq_t dynamic_spur_table[MAX_DYNAMIC_SPUR_TABLE_SIZE]; // Frequencies to be calculated static freq_t dynamic_spur_table[MAX_DYNAMIC_SPUR_TABLE_SIZE]; // Frequencies to be calculated
static int dynamic_spur_table_size = 0; static int dynamic_spur_table_size = 0;
freq_t dynamic_spur_IF = 0;
static int always_use_dynamic_table = false; static int always_use_dynamic_table = false;
static freq_t *spur_table = (freq_t *)static_spur_table; static freq_t *spur_table = (freq_t *)static_spur_table;
@ -3230,7 +3239,7 @@ void fill_spur_table(void)
{ {
freq_t corr_IF; freq_t corr_IF;
if (always_use_dynamic_table) { if (always_use_dynamic_table) { // Only after doing selftest 1
spur_table = dynamic_spur_table; spur_table = dynamic_spur_table;
spur_table_size = dynamic_spur_table_size; spur_table_size = dynamic_spur_table_size;
return; return;
@ -3250,11 +3259,10 @@ void fill_spur_table(void)
} }
return; return;
} }
if (!setting.auto_IF)
corr_IF = setting.frequency_IF; corr_IF = setting.frequency_IF;
else { if (dynamic_spur_IF == corr_IF)
corr_IF = (hw_if? config.frequency_IF1 + 250000 : config.frequency_IF1); return;
} dynamic_spur_IF = corr_IF;
dynamic_spur_table_size = 0; dynamic_spur_table_size = 0;
// dynamic_spur_table[dynamic_spur_table_size++] = 132000000; // dynamic_spur_table[dynamic_spur_table_size++] = 132000000;
// dynamic_spur_table[dynamic_spur_table_size++] = 153000000; // dynamic_spur_table[dynamic_spur_table_size++] = 153000000;
@ -3362,7 +3370,7 @@ int avoid_spur(freq_t f) // find if this frequency should be a
#ifdef TINYSA4 #ifdef TINYSA4
#if 1 #if 1
if (!setting.auto_IF && setting.frequency_IF-2000000 < f && f < setting.frequency_IF -200000) if (!setting.auto_IF && setting.frequency_IF-2000000 < f && f < setting.frequency_IF -200000)
return true; return F_AT_SPUR;
if(config.frequency_IF1+200000 > f && config.frequency_IF1 < f+200000) if(config.frequency_IF1+200000 > f && config.frequency_IF1 < f+200000)
return F_AT_SPUR; return F_AT_SPUR;
#endif #endif
@ -4090,7 +4098,7 @@ again: // Spur redu
#ifdef __ULTRA__ #ifdef __ULTRA__
// LO_harmonic = false; // LO_harmonic = false;
#endif #endif
if (MODE_LOW(setting.mode)){ // All low mode if (MODE_LOW(setting.mode) && !direct){ // All low input/output mode except direct that require setting of IF
if (!setting.auto_IF) if (!setting.auto_IF)
local_IF = setting.frequency_IF; local_IF = setting.frequency_IF;
else else
@ -4098,13 +4106,15 @@ again: // Spur redu
#ifdef TINYSA4 #ifdef TINYSA4
if (!hw_if && actual_rbw_x10 < RBW_FOR_STATIC_TABLE && setting.mode == M_LOW && lf > static_spur_table[0] - RBW_FOR_STATIC_TABLE * 100) if (!hw_if && actual_rbw_x10 < RBW_FOR_STATIC_TABLE && setting.mode == M_LOW && lf > static_spur_table[0] - RBW_FOR_STATIC_TABLE * 100)
local_IF = spur_IF; // static spur table IF local_IF = spur_IF; // static spur table IF
else else {
local_IF = (hw_if? config.frequency_IF1 + 250000 : config.frequency_IF1); local_IF = (hw_if? config.frequency_IF1 - 500000 : config.frequency_IF1 - 500000);
setting.frequency_IF = local_IF;
}
#else #else
local_IF = DEFAULT_IF; local_IF = DEFAULT_IF;
#endif #endif
} }
if (setting.mode == M_LOW && !direct) { if (setting.mode == M_LOW) { // Low input mode
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;
@ -4122,9 +4132,6 @@ again: // Spur redu
setting.spur_removal= S_AUTO_OFF; setting.spur_removal= S_AUTO_OFF;
} }
} }
#endif
#ifdef __ULTRA__
if (S_IS_AUTO(setting.below_IF)) { if (S_IS_AUTO(setting.below_IF)) {
if ((freq_t)lf > MAX_ABOVE_IF_FREQ && lf <= ULTRA_MAX_FREQ && !LO_harmonic) if ((freq_t)lf > MAX_ABOVE_IF_FREQ && lf <= ULTRA_MAX_FREQ && !LO_harmonic)
setting.below_IF = S_AUTO_ON; // Only way to reach this range. Use below IF in harmonic mode setting.below_IF = S_AUTO_ON; // Only way to reach this range. Use below IF in harmonic mode
@ -4153,16 +4160,13 @@ again: // Spur redu
setting.below_IF = S_AUTO_OFF; // use below IF in second pass setting.below_IF = S_AUTO_OFF; // use below IF in second pass
} }
} }
else // if (setting.auto_IF) else // if (setting.auto_IF) // spur reduction is on and can not do above/below IF
{ {
if ((debug_avoid && debug_avoid_second) || spur_second_pass) { if ((debug_avoid && debug_avoid_second) || spur_second_pass) {
#ifdef TINYSA4 #ifdef TINYSA4
local_IF = local_IF + DEFAULT_SPUR_OFFSET-(actual_rbw_x10 > 1000 ? 200000 : 0); // apply IF spur shift local_IF = local_IF + DEFAULT_SPUR_OFFSET-(actual_rbw_x10 > 1000 ? 200000 : 0); // apply IF spur shift
LO_spur_shifted = true; LO_spur_shifted = true;
#ifdef TINYSA4
LO_shifting = true; LO_shifting = true;
#endif
} else { } else {
local_IF = local_IF; // - (actual_rbw_x10 > 5000 ? 200000 : 0);// - DEFAULT_SPUR_OFFSET/2; // apply IF spur shift local_IF = local_IF; // - (actual_rbw_x10 > 5000 ? 200000 : 0);// - DEFAULT_SPUR_OFFSET/2; // apply IF spur shift
} }
@ -4171,7 +4175,7 @@ again: // Spur redu
} }
#endif #endif
} }
} else { } else { // No spur removal
int spur_flag = avoid_spur(lf); int spur_flag = avoid_spur(lf);
#ifdef TINYSA4 #ifdef TINYSA4
if(spur_flag) { // check if alternate IF is needed to avoid spur. if(spur_flag) { // check if alternate IF is needed to avoid spur.
@ -4242,7 +4246,7 @@ again: // Spur redu
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
local_IF += lf; local_IF += lf;
} }
} // --------------- END IF calculation ------------------------ } // --------------- END IF calculation ------------------------ all low input/output modes with IF setting
TRACE(2); TRACE(2);
// ------------- Set LO --------------------------- // ------------- Set LO ---------------------------
@ -6778,7 +6782,7 @@ common_silent:
setting.tracking = true; //Sweep BPF setting.tracking = true; //Sweep BPF
setting.auto_IF = false; setting.auto_IF = false;
#ifdef TINYSA4 #ifdef TINYSA4
setting.frequency_IF = config.frequency_IF1 + STATIC_DEFAULT_SPUR_OFFSET/3; // This is the place where the inverted offset from the middle of the IF pass band is defined for normal mode. setting.frequency_IF = config.frequency_IF1; // Center on SAW filter
set_refer_output(0); set_refer_output(0);
#else #else
setting.frequency_IF = DEFAULT_IF + 210000; // Center on SAW filters setting.frequency_IF = DEFAULT_IF + 210000; // Center on SAW filters

@ -204,6 +204,7 @@ finish3:
while (f_read(fs_file, buf_8, buffer_size, &size) == FR_OK && size > 0) { while (f_read(fs_file, buf_8, buffer_size, &size) == FR_OK && size > 0) {
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
uint8_t c = buf_8[i]; uint8_t c = buf_8[i];
if (c == ',') c = ' ';
if (c == '\r') { // New line (Enter) if (c == '\r') { // New line (Enter)
line[j] = 0; j = 0; line[j] = 0; j = 0;
char *args[16]; char *args[16];

Loading…
Cancel
Save

Powered by TurnKey Linux.