From 44ba1781d5791b48de8d793935aa9a90277deebd Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Tue, 7 Jun 2022 14:23:10 +0200 Subject: [PATCH] output switch command and repaired mixer output --- sa_cmd.c | 17 +++++++++++++++-- sa_core.c | 16 ++++++++++------ si4468.c | 22 +++++++++------------- 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/sa_cmd.c b/sa_cmd.c index 2849a12..be8f7cb 100644 --- a/sa_cmd.c +++ b/sa_cmd.c @@ -205,11 +205,24 @@ VNA_SHELL_FUNCTION(cmd_ultra_start) VNA_SHELL_FUNCTION(cmd_output) { +#ifdef TINYSA4 + int m = generic_option_cmd("output", "on|off|normal|mixer", argc, argv[0]); +#else int m = generic_option_cmd("output", "on|off", argc, argv[0]); - if (m>=0) { +#endif + switch(m) + { + case 0: + case 1: setting.mute = m; - dirty = true; + break; +#ifdef TINYSA4 + case 2: + case 3: + setting.mixer_output = m-2; +#endif } + dirty = true; } VNA_SHELL_FUNCTION(cmd_load) diff --git a/sa_core.c b/sa_core.c index fab3dcf..88f892a 100644 --- a/sa_core.c +++ b/sa_core.c @@ -2906,10 +2906,10 @@ static const int am_modulation[MODULATION_STEPS] = { 5, 1, 0, 1, 5, 9, 11, 9 }; // // Offset is 14.4Hz when below 600MHz and 28.8 when above. // -#define LND 96 -#define HND 48 -#define LWD 1024 -#define HWD 512 +#define LND 96 // low range near FM +#define HND 48 // High range near FM +#define LWD 1024 // Low range wide FM +#define HWD 512 // High range wide FM #endif #define S1 1.5 @@ -4472,8 +4472,12 @@ static bool sweep(bool break_on_operation) ultra_start = 800000000; else ultra_start = 700000000; - } else if (setting.mode == M_GENLOW) - ultra_start = config.ultra_start; + } else if (setting.mode == M_GENLOW) { + if (setting.mixer_output) + ultra_start = MAX_LOW_OUTPUT_FREQ; + else + ultra_start = config.ultra_start; + } } #endif // ------------------------- start sweep loop ----------------------------------- diff --git a/si4468.c b/si4468.c index 3c1fc65..1f6bec6 100644 --- a/si4468.c +++ b/si4468.c @@ -505,6 +505,8 @@ void ADF4351_CP(int p) void ADF4351_drive(int p) { + if (((registers[4] >> 3) & 0x03 ) == (p & 0x03)) + return; maskedWrite(registers[4],3, 0x3, p); // p &= 0x03; // registers[4] &= ~(((uint32_t)0x3) << 3); @@ -516,6 +518,8 @@ void ADF4351_drive(int p) void ADF4351_aux_drive(int p) { + if (((registers[4] >> 6) & 0x03 ) == (p & 0x03)) + return; maskedWrite(registers[4],6, 0x3, p); // p &= 0x03; // registers[4] &= ~(((uint32_t)0x3) << 6); @@ -622,10 +626,8 @@ uint64_t ADF4351_prepare_frequency(int channel, uint64_t freq) // freq / 10Hz void ADF4351_enable(int s) { - static int old_s = -1; - if (s == old_s) + if (bitRead(registers[4],11) != (s & 0x01)) return; - old_s = s; if (s) bitClear(registers[4], 11); // Inverse logic!!!!! else @@ -635,10 +637,8 @@ void ADF4351_enable(int s) void ADF4351_enable_aux_out(int s) { - static int old_s = -1; - if (s == old_s) + if (bitRead(registers[4],8) == (s & 0x01)) return; - old_s = s; if (s) bitSet(registers[4], 8); else @@ -648,10 +648,8 @@ void ADF4351_enable_aux_out(int s) void ADF4351_enable_out(int s) { - static int old_s = -1; - if (s == old_s) + if (bitRead(registers[4],5) == (s & 0x01)) return; - old_s = s; if (s) { bitClear(registers[4], 11); // Disable VCO power down bitClear(registers[2], 5); // Disable power down @@ -976,6 +974,8 @@ int SI4463_refresh_gpio(void) void SI4463_set_gpio(int i, int s) { + if (gpio_state[i] == s) + return; gpio_state[i] = s; #if 0 // debug gpio gpio_state[2] = 3; @@ -2019,10 +2019,6 @@ void enable_rx_output(int s) void enable_high(int s) { -static int old_s = 2; - if (s == old_s) - return; - old_s = s; #ifdef __NEW_SWITCHES__ if (s) SI4463_set_gpio(2,SI446X_GPIO_MODE_DRIVE0);