From 3707c681d809cb6c46be59bdbb575d4d31b719fb Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Tue, 17 Nov 2020 15:09:38 +0100 Subject: [PATCH] Revert "Broken scan" This reverts commit 9f33d285b05ff1b95439d1768280dc89f48203b3. --- nanovna.h | 4 +--- sa_core.c | 38 ++++++-------------------------------- si4432.c | 19 +------------------ 3 files changed, 8 insertions(+), 53 deletions(-) diff --git a/nanovna.h b/nanovna.h index 1236ab4..f84a9cb 100644 --- a/nanovna.h +++ b/nanovna.h @@ -1064,9 +1064,7 @@ enum { // -------------------- Si4432.c --------------- -#ifdef __SI4463__ extern int SI4463_R; void Si4463_set_refer(int ref); -void SI446x_set_AGC_LNA(uint8_t v); -#endif + /*EOF*/ diff --git a/sa_core.c b/sa_core.c index 86680d3..02a7051 100644 --- a/sa_core.c +++ b/sa_core.c @@ -717,7 +717,9 @@ void toggle_AGC(void) dirty = true; } +#ifdef __SI4432__ static unsigned char SI4432_old_v[2]; +#endif void auto_set_AGC_LNA(int auto_set, int agc) // Adapt the AGC setting if needed { @@ -733,17 +735,6 @@ void auto_set_AGC_LNA(int auto_set, int agc) SI4432_old_v[MODE_SELECT(setting.mode)] = v; } #endif -#ifdef __SI4463__ - unsigned char v; - if (auto_set) - v = 0x00; // Enable AGC and disable LNA - else - v = 0x88+agc; // Disable AGC and enable LNA - if (SI4432_old_v[0] != v) { - SI446x_set_AGC_LNA(v); - SI4432_old_v[0] = v; - } -#endif } #ifdef __SI4432__ @@ -756,18 +747,6 @@ void set_AGC_LNA(void) { } #endif -#ifdef __SI4463__ -void set_AGC_LNA(void) { - uint8_t v = 0; - if (!S_STATE(setting.agc)) - v |= 0x80; // Inverse!!!! - if (S_STATE(setting.lna)) - v |= 0x08; // Inverse!!!! - SI446x_set_AGC_LNA(v); - SI4432_old_v[0] = v; -} -#endif - void set_unit(int u) { if (setting.unit == u) @@ -1284,10 +1263,8 @@ case M_ULTRA: } else { set_switch_receive(); } -#endif set_AGC_LNA(); -#ifdef __SI4432__ SI4432_Sel = SI4432_LO ; if (setting.tracking_output) set_switch_transmit(); @@ -1313,8 +1290,8 @@ mute: } else { set_switch_receive(); } -#endif set_AGC_LNA(); +#endif break; case M_GENLOW: // Mixed output from 0 @@ -1759,12 +1736,10 @@ pureRSSI_t perform(bool break_on_operation, int i, uint32_t f, int tracking) } } if (setting.mode == M_LOW && S_IS_AUTO(setting.agc) && !check_for_AM && UNIT_IS_LOG(setting.unit)) { // If in low input mode with auto AGC and log unit -#ifdef __SI4432__ if (f < 1500000) auto_set_AGC_LNA(false, f*9/1500000); else auto_set_AGC_LNA(true, 0); -#endif } // Calculate the RSSI correction for later use if (MODE_INPUT(setting.mode)){ // only cases where the value can change on 0 point of sweep @@ -2209,7 +2184,6 @@ sweep_again: // stay in sweep loop when output mo // ----------------------- in loop AGC --------------------------------- -#ifdef __SI4432__ if (!in_selftest && setting.mode == M_HIGH && S_IS_AUTO(setting.agc) && UNIT_IS_LOG(setting.unit)) { #define AGC_RSSI_THRESHOLD (-55+get_attenuation()) @@ -2227,7 +2201,7 @@ sweep_again: // stay in sweep loop when output mo else auto_set_AGC_LNA(TRUE, 0); } -#endif + // Delay between points if needed, (all delays can apply in SI4432 fill) if (setting.measure_sweep_time_us == 0){ // If not already in buffer @@ -2502,7 +2476,6 @@ sweep_again: // stay in sweep loop when output mo if (!in_selftest && MODE_INPUT(setting.mode)) { -#ifdef __SI4432__ if (S_IS_AUTO(setting.agc)) { float actual_max_level = actual_t[max_index[0]] - get_attenuation(); if (UNIT_IS_LINEAR(setting.unit)) { // Auto AGC in linear mode @@ -2526,7 +2499,6 @@ sweep_again: // stay in sweep loop when output mo } } } else -#endif signal_is_AM = false; } @@ -2692,7 +2664,9 @@ sweep_again: // stay in sweep loop when output mo setting.agc = S_AUTO_OFF; setting.lna = S_AUTO_ON; } +#ifdef __SI4432__ set_AGC_LNA(); +#endif } } diff --git a/si4432.c b/si4432.c index 7bc83ec..ce0c24e 100644 --- a/si4432.c +++ b/si4432.c @@ -1713,23 +1713,6 @@ int16_t Si446x_RSSI(void) } -void SI446x_set_AGC_LNA(uint8_t v) -{ - - uint8_t data[2] = { - 0xd0, // AGC_OVERRIDE - v - }; - SI4463_do_api(data, sizeof(data), NULL, 0); -#if 0 - if (v == 0) { - data[0] = 0xd1; // Read AGC?????? NO - SI4463_do_api(data, 1, data, 1); - } -#endif -} - - // Do an ADC conversion static uint16_t getADC(uint8_t adc_en, uint8_t adc_cfg, uint8_t part) @@ -2223,7 +2206,7 @@ reset: my_microsecond_delay(1000); SI_SDN_LOW; my_microsecond_delay(1000); - ili9341_set_foreground(LCD_BRIGHT_COLOR_GREEN); + ili9341_set_foreground(BRIGHT_COLOR_GREEN); while (!SI4463_READ_CTS) { ili9341_drawstring_7x13("Waiting", 50, 200); my_microsecond_delay(100);