diff --git a/nanovna.h b/nanovna.h index c8ce30a..6f1d634 100644 --- a/nanovna.h +++ b/nanovna.h @@ -347,6 +347,7 @@ extern int test_output; extern int test_output_switch; extern int test_output_drive; extern int test_output_attenuate; +extern int test_path; extern bool level_error; #else extern const int8_t drive_dBm []; diff --git a/sa_cmd.c b/sa_cmd.c index be8f7cb..e9924e6 100644 --- a/sa_cmd.c +++ b/sa_cmd.c @@ -1149,28 +1149,31 @@ VNA_SHELL_FUNCTION(cmd_caloutput) #ifdef TINYSA4 VNA_SHELL_FUNCTION(cmd_q) { - static const char cmd[] = "s|d|a"; if (argc < 1) { usage: - usage_printf("q [s 0..1|d 0..18|a 0..63] %s\r\n", cmd); + usage_printf("q [s0..1|d0..18|a0..63|p0..4]\r\n"); test_output=false; + test_output_switch = false; + test_output_drive = 0; + test_output_attenuate = 0; + test_path = 0; return; } int i = 0; test_output=true; - test_output_switch = false; - test_output_drive = MAX_DRIVE; - test_output_attenuate = 0; - again: + dirty = true; +again: if (argc == 0) return; - int m = get_str_index(argv[i++], cmd); + char *a = argv[i++]; + char m = *a++; argc--; switch (m) { - case -1: goto usage; - case 0: test_output_switch = argv[i++][0] - '0'; argc--; break; - case 1: test_output_drive = atoi(argv[i++]); argc--; break; - case 2: test_output_attenuate = atoi(argv[i++]); argc--; break; + default: goto usage; + case 's': test_output_switch = *a - '0'; break; + case 'd': test_output_drive = atoi(a); break; + case 'a': test_output_attenuate = atoi(a); break; + case 'p': test_path = *a - '0'; break; } goto again; } diff --git a/sa_core.c b/sa_core.c index 88f892a..f51dbb7 100644 --- a/sa_core.c +++ b/sa_core.c @@ -102,21 +102,22 @@ static freq_t old_freq[4] = { 0, 0, 0, 0}; static freq_t real_old_freq[4] = { 0, 0, 0, 0}; #endif -#ifdef TINYSA4 -const float si_drive_dBm [] = {-44.1, -30, -21.6, -17, -14, -11.7, -9.9, -8.4, -7.1, -6, -5, -4.2, -3.4, -2.7 , -2.1, -1.5, -1, -0.47, 0}; -const float adf_drive_dBm[] = {-15,-12,-9,-6}; -const uint8_t drive_register[] = {0, 1, 2, 3, 4, 5, 6, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}; -float *drive_dBm = (float *) si_drive_dBm; -#else -const int8_t drive_dBm [16] = {-38, -32, -30, -27, -24, -19, -15, -12, -5, -2, 0, 3, 6, 9, 12, 16}; -#endif - #ifdef __ULTRA__ int old_drive = -1; int actual_drive = -1; #endif + +#define BELOW_MAX_DRIVE(X) (drive_dBm[X] - drive_dBm[MAX_DRIVE]) + #ifdef TINYSA4 +const float si_drive_dBm [] = {-44.1, -30, -21.6, -17, -14, -11.7, -9.9, -8.4, -7.1, -6, -5, -4.2, -3.4, -2.7 , -2.1, -1.5, -1, -0.47, 0}; +const float adf_drive_dBm[] = {-15,-12,-9,-6}; +const uint8_t drive_register[] = {0, 1, 2, 3, 4, 5, 6, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}; +float *drive_dBm = (float *) si_drive_dBm; +const int min_drive = 0; +int max_drive = 18; + #ifdef __NEW_SWITCHES__ #define SWITCH_ATTENUATION ((setting.mode == M_GENHIGH) ? 40 : 25.0 + config.out_switch_offset) #define MAX_DRIVE ((setting.mode == M_GENHIGH) ? 3 : 18) @@ -143,10 +144,190 @@ int actual_drive = -1; #else #define MAX_ATTENUATE 31.5 #endif + +// 0 1 2 3 4 +enum {PATH_OFF, PATH_LOW, PATH_DIRECT, PATH_ULTRA, PATH_LEAKAGE}; +int signal_path = PATH_OFF; + +void set_output_drive(int d) +{ + if (signal_path == PATH_LEAKAGE) + ADF4351_drive(d); + else { +#ifdef __SI4432__ + SI4432_Sel = SI4432_RX ; + SI4432_Drive(d); +#endif +#ifdef __SI4463__ + SI4463_set_output_level(d); +#endif + setting.rx_drive = d; + } +} + +void set_output_step_atten(int s) +{ + setting.atten_step = s; + if (signal_path == PATH_LEAKAGE) + enable_ultra(!s); + else { +#ifdef TINYSA3 + SI4432_Sel = SI4432_RX ; + if (s) + set_switch_receive(); + else + set_switch_transmit(); +#else + enable_rx_output(!s); +#endif + } +} +void set_output_path(freq_t f, float level) +{ + if (test_output) { + signal_path = test_path; + setting.mixer_output = (signal_path == PATH_ULTRA); + setting.atten_step = test_output_switch; + set_output_drive(test_output_drive); + PE4302_Write_Byte(test_output_attenuate); + goto set_path; + } + if (setting.mute) + signal_path = PATH_OFF; + else if (f < MINIMUM_DIRECT_FREQ || (config.ultra && config.ultra_start != ULTRA_AUTO && f < config.ultra_start)) + signal_path = PATH_LOW; + else if (f <= MAX_LOW_OUTPUT_FREQ && ( config.ultra_start == ULTRA_AUTO || f < config.ultra_start)) + signal_path = PATH_DIRECT; + else if (config.ultra && setting.mixer_output) + signal_path = PATH_ULTRA; + else + signal_path = PATH_LEAKAGE; + + switch (signal_path) { + case PATH_LEAKAGE: + drive_dBm = (float *)adf_drive_dBm; + max_drive = 2; + break; + default: + drive_dBm = (float *)si_drive_dBm; + max_drive = 18; + } + + if (signal_path != PATH_LEAKAGE) { + float dt = Si446x_get_temp() - CENTER_TEMPERATURE; + if (dt > 0) + level += dt * DB_PER_DEGREE_ABOVE; // Temperature correction + else + level += dt * DB_PER_DEGREE_BELOW; // Temperature correction + } + + level += 3.0; // Always 3dB in attenuator + + int very_low_flag = false; + float a = level - level_max(); // convert to all settings maximum power output equals a = zero + if (a < -SWITCH_ATTENUATION) { + a = a + SWITCH_ATTENUATION; + very_low_flag = true; + } + set_output_step_atten(very_low_flag); +#ifdef TINYSA4 +#define LOWEST_LEVEL (very_low_flag ? 0 : MIN_DRIVE) +#else +#define LOWEST_LEVEL MIN_DRIVE +#endif + + int d; +#ifdef TINYSA4 + if (signal_path == PATH_LEAKAGE) + d = 1; + else + d = MAX_DRIVE-8; // Start in the middle +#else + d = MAX_DRIVE-3; // Start in the middle +#endif + + float blw = BELOW_MAX_DRIVE(d); + while (a > blw && d < MAX_DRIVE) { // Increase if needed + d++; + blw = BELOW_MAX_DRIVE(d); + } + while (a + 28 < blw && d > LOWEST_LEVEL) { // reduce till it fits attenuator (31 - 3) + d--; + blw = BELOW_MAX_DRIVE(d); + } + a -= blw; + set_output_drive(d); + a -= 3.0; // Always at least 3dB attenuation + if (a > 0) { + a = 0; + if (!level_error) redraw_request |= REDRAW_CAL_STATUS; + level_error = true; + } else { + if (level_error) redraw_request |= REDRAW_CAL_STATUS; + level_error = false; + } + if (a < -31.5) + a = -31.5; + a = -a - 0.25; // Rounding + setting.attenuate_x2 = (int)(a * 2); + PE4302_Write_Byte(setting.attenuate_x2); +#if 0 + if (SDU1.config->usbp->state == USB_ACTIVE) + shell_printf ("level=%f, drive=%d, atten=%f, switch=%d\r\n", level, d, a, (very_low_flag ? 1 : 0)); +#endif + + enable_extra_lna(false); + set_path: + switch(signal_path) { + case PATH_OFF: + if (SI4463_is_in_tx_mode()) + SI4463_init_rx(); + enable_ADF_output(false,false); + + break; + case PATH_LEAKAGE: + if (SI4463_is_in_tx_mode()) + SI4463_init_rx(); + + enable_ADF_output(true, false); + + enable_direct(false); + enable_ultra(!setting.atten_step); + enable_high(false); + + break; + case PATH_LOW: + enable_ultra(false); + enable_high(false); + enable_direct(false); + goto common; + + case PATH_DIRECT: + enable_ADF_output(false, false); + enable_ultra(!setting.atten_step); + enable_direct(true); + enable_high(true); + goto common2; + case PATH_ULTRA: + enable_ultra(true); + enable_direct(false); + enable_high(false); + common: + enable_ADF_output(true, false); + common2: + if (!SI4463_is_in_tx_mode()) + SI4463_init_tx(); + break; + } + +} + + #else +const int8_t drive_dBm [16] = {-38, -32, -30, -27, -24, -19, -15, -12, -5, -2, 0, 3, 6, 9, 12, 16}; #define SWITCH_ATTENUATION (29 - config.switch_offset) #define RECEIVE_SWITCH_ATTENUATION (24 + config.receive_switch_offset) -#define POWER_OFFSET 15 +//#define POWER_OFFSET 15 #define MAX_DRIVE (setting.mode == M_GENHIGH ? 13 : 11) // The value of 13 is linked to the SL_GENHIGH_LEVEL_MAX of 9 #define MIN_DRIVE 8 #define SL_GENHIGH_LEVEL_MIN -38 @@ -156,7 +337,6 @@ int actual_drive = -1; #define MAX_ATTENUATE 31.5 #endif -#define BELOW_MAX_DRIVE(X) (drive_dBm[X] - drive_dBm[MAX_DRIVE]) //float level_min; @@ -862,7 +1042,7 @@ float level_range(void) #ifdef TINYSA4 -float low_out_offset() +float low_out_offset(void) { if (config.low_level_output_offset == 100) { @@ -874,7 +1054,7 @@ float low_out_offset() return config.low_level_output_offset; } -float high_out_offset() +float high_out_offset(void) { if (config.high_level_output_offset == 100) { @@ -1738,23 +1918,6 @@ void calculate_step_delay(void) } } -static void apply_settings(void) // Ensure all settings in the setting structure are translated to the right HW setup -{ - set_switches(setting.mode); -#ifdef __PE4302__ - if (setting.mode == M_HIGH) - PE4302_Write_Byte(40); // Ensure defined input impedance of low port when using high input mode (power calibration) - else - PE4302_Write_Byte((int)(setting.attenuate_x2)); -#endif - if (setting.mode == M_LOW) { - - } - set_calibration_freq(setting.refer); - update_rbw(); - calculate_step_delay(); -} - //------------------------------------------ #if 0 #define CORRECTION_POINTS 10 @@ -1871,7 +2034,7 @@ pureRSSI_t get_frequency_correction(freq_t f) // Frequency dependent RSSI c #ifdef TINYSA4 #if 0 // Not implemented int cf = (((f >> 28)+1)>>1) - 5; // Correction starts at 2,684,354,560Hz round to closest correction frequency - int ca = setting.attenuate_x2 >> 2; // One data point per 2dB step + int ca = setting.attenuate_x2 >> 2; // One data point m 2dB step if (cf >= 0 && cf < 16) cv -= scaled_atten_correction[cf][ca]<<2; // Shift is +5(pure RSSI) - 3 (scaled correction) = 2 #endif @@ -2094,10 +2257,7 @@ void set_freq(int V, freq_t freq) // translate the requested frequency into a else target_drive = 2; } - if (old_drive != target_drive) { - ADF4351_drive(target_drive); // Max drive - old_drive = target_drive; - } + ADF4351_drive(target_drive); // Max drive #endif real_old_freq[V] = ADF4351_set_frequency(V-ADF4351_LO,freq); } @@ -2185,9 +2345,7 @@ case M_LOW: // Mixed into 0 #endif set_AGC_LNA(); #ifdef TINYSA4 - ADF4351_enable(true); - ADF4351_enable_aux_out(setting.tracking_output); - ADF4351_enable_out(true); + enable_ADF_output(true, setting.tracking_output); #endif #ifdef __SI4432__ @@ -2229,9 +2387,7 @@ mute: #endif set_AGC_LNA(); #ifdef TINYSA4 - ADF4351_enable_aux_out(false); - ADF4351_enable_out(false); - ADF4351_enable(false); + enable_ADF_output(false, setting.tracking_output); if (setting.atten_step) {// use switch as attenuator enable_rx_output(true); } else { @@ -2268,13 +2424,12 @@ case M_GENLOW: // Mixed output from 0 SI4432_Transmit(12); // Fix LO drive a 10dBm } #endif +#if 0 #ifdef __SI4468__ SI4463_init_tx(); #endif #ifdef TINYSA4 - ADF4351_enable_out(true); - ADF4351_enable(true); - ADF4351_enable_aux_out(setting.tracking_output); + enable_ADF_output(true, setting.tracking_output); if (setting.atten_step) { // use switch as attenuator enable_rx_output(false); @@ -2290,6 +2445,7 @@ case M_GENLOW: // Mixed output from 0 #endif #ifdef __ULTRA__ enable_ultra(false); +#endif #endif break; case M_GENHIGH: // Direct output from 1 @@ -2316,40 +2472,14 @@ case M_GENHIGH: // Direct output from 1 SI4432_Transmit(setting.lo_drive); #endif #ifdef TINYSA4 -#ifndef __NEW_SWITCHES__ - if (config.high_out_adf4350) { -#endif #ifdef __SI4468__ SI4463_init_rx(); enable_rx_output(true); // to protect the SI #endif - ADF4351_enable(true); -#ifndef TINYSA4_PROTO - ADF4351_enable_aux_out(false); - ADF4351_enable_out(true); -#else - ADF4351_enable_aux_out(true); - ADF4351_enable_out(true); // Must be enabled to have aux output -#endif + enable_ADF_output(true, true); ADF4351_aux_drive(setting.lo_drive); enable_extra_lna(false); enable_ultra(true); // Open low output -#ifndef __NEW_SWITCHES__ - } else { - ADF4351_enable_aux_out(false); - ADF4351_enable_out(false); -#ifdef __SI4468__ - SI4463_set_output_level(setting.lo_drive); // Must be before init_tx - SI4463_init_tx(); -// if (setting.lo_drive < 32) { -// enable_rx_output(false); // use switch as attenuator -// } else { - enable_rx_output(true); -// } - -#endif - } -#endif #endif break; } @@ -3012,6 +3142,7 @@ void clock_at_48MHz(void) int test_output = false; int test_output_switch = false; int test_output_drive = 0; +int test_path = 0; int test_output_attenuate = 0; bool level_error = false; static float old_temp = 0.0; @@ -3041,7 +3172,16 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / #endif calculate_correction(); // pre-calculate correction factor dividers to avoid float division limits_update(); - apply_settings(); + set_switches(setting.mode); +#ifdef __PE4302__ + if (setting.mode == M_HIGH) + PE4302_Write_Byte(40); // Ensure defined input impedance of low port when using high input mode (power calibration) + else + PE4302_Write_Byte((int)(setting.attenuate_x2)); +#endif + set_calibration_freq(setting.refer); + update_rbw(); + calculate_step_delay(); old_a = -150; // clear cached level setting // Initialize HW scandirty = true; // This is the first pass with new settings @@ -3138,10 +3278,7 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / else target_drive = 3; } - if (old_drive != target_drive) { - ADF4351_drive(target_drive); // Max drive - old_drive = target_drive; - } + ADF4351_drive(target_drive); // Max drive #endif #endif #ifdef TINYSA3 @@ -3158,22 +3295,8 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / // ------------------------------------- START Set the output level ---------------------------------- - if (( setting.frequency_step != 0 || setting.level_sweep != 0.0 || i == 0)) { // Initialize or adapt output levels + if (( setting.frequency_step != 0 || setting.level_sweep != 0.0 || (i == 0 && scandirty))) { // Initialize or adapt output levels if (setting.mode == M_GENLOW) {// if in low output mode and level sweep or frequency weep is active or at start of sweep -#ifdef TINYSA4 - if (test_output) { - if (f < MAX_LOW_OUTPUT_FREQ || setting.mixer_output) - enable_rx_output(!test_output_switch); - else - enable_direct(!test_output_switch); - if (f > MAX_LOW_OUTPUT_FREQ && !setting.mixer_output) - ADF4351_drive(test_output_drive); - else - SI4463_set_output_level(test_output_drive); - PE4302_Write_Byte(test_output_attenuate); - } else -#endif - { float ls=setting.level_sweep; // calculate and set the output level if (ls > 0) ls += 0.5; @@ -3182,52 +3305,23 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / float a = ((int)((setting.level + ((float)i / sweep_points) * ls)*2.0)) / 2.0 /* + get_level_offset() */ ; correct_RSSI_freq = get_frequency_correction(f); a += PURE_TO_float(correct_RSSI_freq); -#ifdef TINYSA4 - { - float dt = Si446x_get_temp() - CENTER_TEMPERATURE; - if (dt > 0) - a += dt * DB_PER_DEGREE_ABOVE; // Temperature correction - else - a += dt * DB_PER_DEGREE_BELOW; // Temperature correction - } - a += 3.0; // Always 3dB in attenuator -#endif if (a != old_a) { -#ifdef TINYSA4 - int very_low_flag = false; -#endif old_a = a; +#ifdef TINYSA4 + set_output_path(f, a); +#else a = a - level_max(); // convert to all settings maximum power output equals a = zero if (a < -SWITCH_ATTENUATION) { a = a + SWITCH_ATTENUATION; -#ifdef TINYSA3 SI4432_Sel = SI4432_RX ; set_switch_receive(); -#else - enable_rx_output(false); - very_low_flag = true; -#endif } else { -#ifdef TINYSA3 SI4432_Sel = SI4432_RX ; set_switch_transmit(); -#else - enable_rx_output(true); - -#endif } -#ifdef TINYSA4 -#define LOWEST_LEVEL (very_low_flag ? 0 : MIN_DRIVE) -#else #define LOWEST_LEVEL MIN_DRIVE -#endif int d; -#ifdef TINYSA4 - d = MAX_DRIVE-8; // Start in the middle -#else d = MAX_DRIVE-3; // Start in the middle -#endif - float blw = BELOW_MAX_DRIVE(d); while (a > blw && d < MAX_DRIVE) { // Increase if needed d++; @@ -3238,41 +3332,20 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / blw = BELOW_MAX_DRIVE(d); } a -= blw; -#ifdef __SI4432__ SI4432_Sel = SI4432_RX ; SI4432_Drive(d); -#endif -#ifdef __SI4463__ - SI4463_set_output_level(d); -#endif -#ifdef TINYSA4 - a -= 3.0; // Always at least 3dB attenuation -#endif if (a > 0) { a = 0; -#ifdef TINYSA4 - if (!level_error) redraw_request |= REDRAW_CAL_STATUS; - level_error = true; -#endif - } else { -#ifdef TINYSA4 - if (level_error) redraw_request |= REDRAW_CAL_STATUS; - level_error = false; -#endif - } if (a < -31.5) a = -31.5; a = -a - 0.25; // Rounding -#ifdef __PE4302__ setting.attenuate_x2 = (int)(a * 2); PE4302_Write_Byte(setting.attenuate_x2); -#endif #if 0 if (SDU1.config->usbp->state == USB_ACTIVE) shell_printf ("level=%f, d=%d, a=%f, s=%d\r\n", setting.level, d, a, (very_low_flag ? 1 : 0)); #endif - - } +#endif } } else if (setting.mode == M_GENHIGH) { @@ -3284,17 +3357,6 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / #endif { float a = setting.level - level_max(); -#ifdef TINYSA4 -#ifndef __NEW_SWITCHES__ - if (!config.high_out_adf4350) { - float dt = Si446x_get_temp() - CENTER_TEMPERATURE; - if (dt > 0) - a += dt * DB_PER_DEGREE_ABOVE; // Temperature correction - else - a += dt * DB_PER_DEGREE_BELOW; // Temperature correction - } -#endif -#endif if (a <= -SWITCH_ATTENUATION) { setting.atten_step = true; a = a + SWITCH_ATTENUATION; @@ -3302,12 +3364,8 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / SI4432_Sel = SI4432_LO ; set_switch_receive(); #else -#ifndef __NEW_SWITCHES__ - if (!config.high_out_adf4350) - enable_rx_output(false); - else -#endif - ADF4351_enable_aux_out(false); + enable_ADF_output(true, false); +; #endif } else { setting.atten_step = false; @@ -3315,12 +3373,8 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / SI4432_Sel = SI4432_LO ; set_switch_transmit(); #else -#ifndef __NEW_SWITCHES__ - if (!config.high_out_adf4350) - enable_rx_output(true); - else -#endif - ADF4351_enable_aux_out(true); + enable_ADF_output(true, true); + #endif } @@ -3447,6 +3501,7 @@ modulation_again: #endif } } else if (setting.mode == M_GENLOW) { +#if 0 if (ultra && (f > ultra_start || (setting.mixer_output && f > MAX_LOW_OUTPUT_FREQ))) { // Ultra mode output using both SI and ADF if (!SI4463_is_in_tx_mode()) SI4463_init_tx(); @@ -3460,21 +3515,17 @@ modulation_again: if (SI4463_is_in_tx_mode()) SI4463_init_rx(); - ADF4351_enable_aux_out(true); - ADF4351_enable_out(true); - ADF4351_enable(true); + enable_ADF_output(true, true); enable_direct(false); - enable_ultra(true); + enable_ultra(setting.atten_step); enable_high(false); } else { // Direct mode output using only SI if (!SI4463_is_in_tx_mode()) SI4463_init_tx(); - enable_ADF_output(false); - ADF4351_enable_aux_out(false); - ADF4351_enable_out(false); - ADF4351_enable(false); + enable_ADF_output(false, false); + enable_ultra(true); enable_direct(true); @@ -3484,11 +3535,12 @@ modulation_again: } else { // Normal output mode using both SI and ADF if (!SI4463_is_in_tx_mode()) SI4463_init_tx(); - enable_ADF_output(true); + enable_ADF_output(true, false); enable_ultra(false); enable_high(false); enable_direct(false); } +#endif } #endif // -------------------------------- Acquisition loop for one requested frequency covering spur avoidance and vbwsteps ------------------------ @@ -3817,7 +3869,7 @@ again: // Spur redu } else { ADF4350_shift_ref(false); } - } + } else if (get_sweep_frequency(ST_SPAN)<5000000) { // When scanning less then 5MHz if (actual_rbw_x10 <= 3000) { setting.increased_R = true; @@ -3939,10 +3991,7 @@ again: // Spur redu // // ----------------- end duplication of code // - if (old_drive != actual_drive) { - ADF4351_drive(actual_drive); // Max drive - old_drive = actual_drive; - } + ADF4351_drive(actual_drive); // Max drive } set_freq(ADF4351_LO, target_f); #if 1 // Compensate frequency ADF4350 error with SI4468 diff --git a/si4432.h b/si4432.h index 7edfa81..fefda19 100644 --- a/si4432.h +++ b/si4432.h @@ -171,12 +171,13 @@ void ADF4351_drive(int p); void ADF4351_aux_drive(int p); void ADF4351_enable(int p); void ADF4351_enable_aux_out(int p); -void ADF4351_enable_out(int p); int ADF4351_locked(void); void ADF4350_shift_ref(int f); -void ADF4351_enable(int s); -void ADF4351_enable_aux_out(int s); +//void ADF4351_enable_out(int p); +//void ADF4351_enable(int s); +//void ADF4351_enable_aux_out(int s); + extern int si5351_available; #endif @@ -206,7 +207,7 @@ void enable_ultra(int s); void enable_rx_output(int s); void enable_high(int s); void enable_direct(int s); -void enable_ADF_output(int f); +void enable_ADF_output(int f, int t); #endif diff --git a/si4468.c b/si4468.c index 1f6bec6..f72a6a8 100644 --- a/si4468.c +++ b/si4468.c @@ -2032,13 +2032,11 @@ void enable_high(int s) #endif } -void enable_ADF_output(int f) +void enable_ADF_output(int f, int t) { - static int old_f = 2; - if (f==old_f) - return; - old_f = f; + ADF4351_enable(f); ADF4351_enable_out(f); + ADF4351_enable_aux_out(t); } #ifdef __NEW_SWITCHES__ diff --git a/ui_sa.c b/ui_sa.c index fd14981..6ad4878 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -1033,9 +1033,11 @@ static UI_FUNCTION_ADV_CALLBACK(menu_lowoutput_settings_acb) return; case 0: setting.mixer_output = false; + dirty = true; break; case 1: setting.mixer_output = true; + dirty = true; break; } menu_move_back(false); @@ -3168,20 +3170,28 @@ static const menuitem_t menu_stimulus[] = { { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; +#ifdef TINYSA4 +const menuitem_t menu_mode[] = { +// { MT_FORM | MT_TITLE, 0, "tinySA MODE", NULL}, + { MT_FORM | MT_ADV_CALLBACK | MT_ICON, I_LOW_INPUT+I_SA, "Spectrum Analyzer", menu_mode_acb}, + { MT_FORM | MT_ADV_CALLBACK | MT_ICON, I_LOW_OUTPUT+I_SINUS, "Signal Generator", menu_mode_acb}, + { MT_FORM | MT_ADV_CALLBACK | MT_ICON, I_HIGH_OUTPUT+I_GEN, "%s to HIGH out", menu_mode_acb}, + { MT_FORM | MT_ADV_CALLBACK | MT_ICON, I_CONNECT+I_GEN, "Calibration Output: %s", menu_sreffer_acb}, + { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel +}; +#else const menuitem_t menu_mode[] = { // { MT_FORM | MT_TITLE, 0, "tinySA MODE", NULL}, { MT_FORM | MT_ADV_CALLBACK | MT_ICON, I_LOW_INPUT+I_SA, "%s to LOW in", menu_mode_acb}, -#ifndef TINYSA4 { MT_FORM | MT_ADV_CALLBACK | MT_ICON, I_HIGH_INPUT+I_SA, "%s to HIGH in", menu_mode_acb}, -#endif { MT_FORM | MT_ADV_CALLBACK | MT_ICON, I_LOW_OUTPUT+I_SINUS, "%s to LOW out", menu_mode_acb}, { MT_FORM | MT_ADV_CALLBACK | MT_ICON, I_HIGH_OUTPUT+I_GEN, "%s to HIGH out", menu_mode_acb}, { MT_FORM | MT_ADV_CALLBACK | MT_ICON, I_CONNECT+I_GEN, "Cal. output: %s", menu_sreffer_acb}, // { MT_SUBMENU, 0, "EXPERT\nCONFIG", menu_settings3}, - // { MT_FORM | MT_CANCEL, 0, S_RARROW" BACK", NULL }, { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel }; +#endif static const menuitem_t menu_top[] = { { MT_SUBMENU, 0, "PRESET", menu_load_preset},