From ef32ae6686054905fbd4678a35a01bf3ffb77733 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Sat, 12 Jun 2021 19:03:17 +0200 Subject: [PATCH] HW version and harmonic spur removal for tinySA3 --- main.c | 4 ++++ sa_core.c | 25 ++++++++++++++++++++----- ui_sa.c | 16 ++++++++++++++++ 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 6f4d3f9..5f821c4 100644 --- a/main.c +++ b/main.c @@ -1594,7 +1594,11 @@ VNA_SHELL_FUNCTION(cmd_version) { (void)argc; (void)argv; +#ifdef TINYSA4 shell_printf("%s\r\nHW Version:%d\r\n", TINYSA_VERSION, adc1_single_read(0)); +#else + shell_printf("%s\r\n", TINYSA_VERSION); +#endif } VNA_SHELL_FUNCTION(cmd_vbat) diff --git a/sa_core.c b/sa_core.c index 3a1c33a..2c2e496 100644 --- a/sa_core.c +++ b/sa_core.c @@ -604,6 +604,11 @@ void set_extra_lna(int t) void toggle_mirror_masking(void) { setting.mirror_masking = !setting.mirror_masking; +#ifdef __HARMONIC__ + if (setting.harmonic) { + setting.spur_removal = setting.mirror_masking; + } +#endif dirty = true; } @@ -3273,8 +3278,16 @@ again: // Spur redu target_f = local_IF+lf; // otherwise to above IF, local_IF == 0 in high mode #ifdef __SI4432__ #ifdef __HARMONIC__ - if (setting.harmonic) - target_f /= setting.harmonic; + if (setting.harmonic) { + if (spur_second_pass) { + if (setting.harmonic == 2) + target_f /= setting.harmonic+1; + else + target_f /= setting.harmonic+2; + } + else + target_f /= setting.harmonic; + } #endif set_freq (SI4432_LO, target_f); // otherwise to above IF #endif @@ -3655,7 +3668,7 @@ again: // Spur redu // } #ifdef __SPUR__ static pureRSSI_t spur_RSSI = -1; // Initialization only to avoid warning. - if (setting.mode == M_LOW && S_STATE(setting.spur_removal) && !debug_avoid) { + if ((setting.mode == M_LOW || setting.mode == M_HIGH) && S_STATE(setting.spur_removal) && !debug_avoid) { if (!spur_second_pass) { // If first spur pass spur_RSSI = pureRSSI; // remember measure RSSI spur_second_pass = true; @@ -3735,8 +3748,10 @@ static bool sweep(bool break_on_operation) modulation_counter = 0; // init modulation counter in case needed int refreshing = false; - if (MODE_OUTPUT(setting.mode) && config.cor_am == 0) { // Calibrate the modulation frequencies at first use - calibrate_modulation(MO_AM, &config.cor_am); + if (MODE_OUTPUT(setting.mode) && config.cor_nfm == 0) { // Calibrate the modulation frequencies at first use +#ifndef TINYSA4 + calibrate_modulation(MO_AM, &config.cor_am); // No AM mondulation for now +#endif calibrate_modulation(MO_NFM, &config.cor_nfm); calibrate_modulation(MO_WFM, &config.cor_wfm); } diff --git a/ui_sa.c b/ui_sa.c index 6fa09fd..09c8f31 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -1064,6 +1064,21 @@ static UI_FUNCTION_ADV_CALLBACK(menu_spur_acb) // menu_move_back(false); ui_mode_normal(); } +#if 0 +#ifdef __HARMONIC__ +static UI_FUNCTION_ADV_CALLBACK(menu_harmonic_spur_acb) +{ + (void)data; + (void)item; + if (b){ + b->icon = AUTO_ICON(setting.spur_removal); + return; + } + toggle_spur(); + ui_mode_normal(); +}#endif +#endif +#endif #endif #ifdef TINYSA4 @@ -2544,6 +2559,7 @@ static const menuitem_t menu_settings3[] = { MT_ADV_CALLBACK, 0, "PULSE\nHIGH", menu_settings_pulse_acb}, #ifdef __HARMONIC__ { MT_SUBMENU | MT_HIGH,0, "HARMONIC", menu_harmonic}, +// { MT_ADV_CALLBACK,0, "SPUR\nREMOVAL", menu_harmonic_spur_acb}, #endif #ifdef __USE_SERIAL_CONSOLE__ { MT_SUBMENU, 0, "CONNECTION", menu_connection},