From cd3bfac519c6180905b096a91d47be331056c9e0 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Sun, 23 Aug 2020 10:32:34 +0200 Subject: [PATCH] Make PE4302 optional --- nanovna.h | 1 + sa_core.c | 10 ++++++++++ si4432.c | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/nanovna.h b/nanovna.h index 686928a..31ba7f8 100644 --- a/nanovna.h +++ b/nanovna.h @@ -26,6 +26,7 @@ #define __SA__ #define __SI4432__ +//#define __PE4302__ //#define __SIMULATION__ //#define __PIPELINE__ #define __SCROLL__ diff --git a/sa_core.c b/sa_core.c index 76864d7..573d3f8 100644 --- a/sa_core.c +++ b/sa_core.c @@ -871,10 +871,12 @@ void calculate_step_delay(void) 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 * 2)); +#endif if (setting.mode == M_LOW) { } @@ -974,8 +976,10 @@ void setupSA(void) SI4432_Sel = SI4432_LO ; SI4432_Transmit(0); #endif +#ifdef __PE4302__ PE4302_init(); PE4302_Write_Byte(0); +#endif #if 0 // Measure fast scan time setting.sweep_time_us = 0; setting.additional_step_delay_us = 0; @@ -1513,7 +1517,9 @@ pureRSSI_t perform(bool break_on_operation, int i, uint32_t f, int tracking) if (a < -31) a = -31; a = -a; +#ifdef __PE4302__ PE4302_Write_Byte((int)(a * 2) ); +#endif } } if (setting.mode == M_LOW && S_IS_AUTO(setting.agc) && UNIT_IS_LOG(setting.unit)) { // If in low input mode with auto AGC and log unit @@ -1529,7 +1535,9 @@ pureRSSI_t perform(bool break_on_operation, int i, uint32_t f, int tracking) int p = setting.attenuate * 2 + am_modulation[modulation_counter++]; if (p>63) p = 63; else if (p< 0) p = 0; +#ifdef __PE4302__ PE4302_Write_Byte(p); +#endif if (modulation_counter == 5) // 3dB modulation depth modulation_counter = 0; my_microsecond_delay(setting.modulation == MO_AM_10Hz ? 20000 : 180); @@ -2039,7 +2047,9 @@ sweep_again: // stay in sweep loop when output mo // Try update settings if (changed){ +#ifdef __PE4302__ PE4302_Write_Byte((int) get_attenuation() * 2); +#endif redraw_request |= REDRAW_CAL_STATUS; #ifdef __SI4432__ SI4432_Sel = SI4432_RX ; diff --git a/si4432.c b/si4432.c index 4b7dc20..38193a9 100644 --- a/si4432.c +++ b/si4432.c @@ -658,6 +658,7 @@ void SI4432_SetReference(int freq) #endif //------------PE4302 ----------------------------------------------- +#ifdef __PE4302__ // Comment out this define to use parallel mode PE4302 @@ -707,7 +708,7 @@ bool PE4302_Write_Byte(unsigned char DATA ) return true; } - +#endif #if 0 //-----------------SI4432 dummy------------------