diff --git a/main.c b/main.c index a3c4f67..193651b 100644 --- a/main.c +++ b/main.c @@ -23,7 +23,9 @@ //#include "hal_serial.h" #include "usbcfg.h" +#ifdef __VNA__ #include "si5351.h" +#endif #include "nanovna.h" #ifdef __VNA__ #include "fft.h" @@ -713,7 +715,7 @@ duplicate_buffer_to_dump(int16_t *p) memcpy(dump_buffer, p, sizeof dump_buffer); } #endif - +#ifdef __AUDIO__ void i2s_end_callback(I2SDriver *i2sp, size_t offset, size_t n) { #if PORT_SUPPORTS_RT @@ -755,6 +757,7 @@ static const I2SConfig i2sconfig = { 2 // i2spr }; #endif +#endif #define MAX_DATA 2 VNA_SHELL_FUNCTION(cmd_data) @@ -2652,7 +2655,7 @@ THD_FUNCTION(myshellThread, p) } #endif -#if 1 +#ifdef __VNA__ // I2C clock bus setting: depend from STM32_I2C1SW in mcuconf.h static const I2CConfig i2ccfg = { .timingr = STM32_TIMINGR_PRESC(0U) | /* 72MHz I2CCLK. ~ 600kHz i2c */ @@ -2755,8 +2758,10 @@ int main(void) //palSetPadMode(GPIOB, 8, PAL_MODE_ALTERNATE(1) | PAL_STM32_OTYPE_OPENDRAIN); //palSetPadMode(GPIOB, 9, PAL_MODE_ALTERNATE(1) | PAL_STM32_OTYPE_OPENDRAIN); +#ifdef __VNA__ i2cStart(&I2CD1, &i2ccfg); si5351_init(); +#endif #ifdef __SI4432__ /* diff --git a/mcuconf.h b/mcuconf.h index 9520c1c..be724e5 100644 --- a/mcuconf.h +++ b/mcuconf.h @@ -134,7 +134,7 @@ /* * I2C driver system settings. */ -#define STM32_I2C_USE_I2C1 TRUE +#define STM32_I2C_USE_I2C1 FALSE #define STM32_I2C_USE_I2C2 FALSE #define STM32_I2C_BUSY_TIMEOUT 50 #define STM32_I2C_I2C1_IRQ_PRIORITY 3 diff --git a/nanovna.h b/nanovna.h index 7bb485e..6c0858e 100644 --- a/nanovna.h +++ b/nanovna.h @@ -37,7 +37,7 @@ #define __SELFTEST__ #define __CALIBRATE__ #define __FAST_SWEEP__ // Pre-fill SI4432 RSSI buffer to get fastest sweep in zero span mode -#define __AUDIO__ +// #define __AUDIO__ #define __HAM_BAND__ //#define __ULTRA__ // Add harmonics mode on low input. //#define __ULTRA_SA__ // Adds ADF4351 control for extra high 1st IF stage diff --git a/sa_core.c b/sa_core.c index 124552b..0127541 100644 --- a/sa_core.c +++ b/sa_core.c @@ -218,7 +218,9 @@ uint32_t calc_min_sweep_time_us(void) // Estimate minimum sweep time in t = 200*sweep_points; // 200 microseconds is the delay set in perform when sweeping in output mode else { uint32_t bare_sweep_time=0; +#ifdef __SI4432__ bare_sweep_time = (SI4432_step_delay + MEASURE_TIME) * (sweep_points); // Single RSSI delay and measurement time in uS while scanning +#endif if (FREQ_IS_CW()) { bare_sweep_time = MINIMUM_SWEEP_TIME; // minimum sweep time in fast CW mode if (setting.repeat != 1 || setting.sweep_time_us >= 100*ONE_MS_TIME || setting.spur_removal != 0) // if no fast CW sweep possible @@ -3746,7 +3748,7 @@ void self_test(int test) ili9341_clear_screen(); reset_settings(M_LOW); set_refer_output(-1); -#ifdef DOESNOTFIT +#ifndef DOESNOTFIT } else if (test == 1) { float p2, p1, p; in_selftest = true; // Spur search @@ -3772,7 +3774,7 @@ void self_test(int test) f = 400000; while (f < DEFAULT_MAX_FREQ) { p = PURE_TO_float(perform(false, 1, f, false)); -#define SPUR_DELTA 6 +#define SPUR_DELTA 15 if ( p2 < p1 - SPUR_DELTA && p < p1 - SPUR_DELTA) { shell_printf("Spur of %4.2f at %d with count %d\n\r", p1,(f - setting.frequency_step)/1000, add_spur(f - setting.frequency_step)); } diff --git a/si5351.c b/si5351.c index 572189d..e421908 100644 --- a/si5351.c +++ b/si5351.c @@ -19,6 +19,7 @@ */ #include "hal.h" #include "nanovna.h" +#ifdef __VNA__ #include "si5351.h" #define SI5351_I2C_ADDR (0x60<<1) @@ -463,3 +464,4 @@ int si5351_set_frequency_with_offset(uint32_t freq, int offset, uint8_t drive_st current_band = band; return delay; } +#endif diff --git a/tlv320aic3204.c b/tlv320aic3204.c index 4ebfb9e..788509a 100644 --- a/tlv320aic3204.c +++ b/tlv320aic3204.c @@ -17,9 +17,10 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #include "hal.h" #include "nanovna.h" - +#ifdef __AUDIO__ #define REFCLK_8000KHZ #define AIC3204_ADDR 0x18 @@ -64,7 +65,7 @@ static const uint8_t conf_data_routing[] = { 2, 0x01, 0x08, /* Disable Internal Crude AVdd in presence of external AVdd supply or before powering up internal AVdd LDO*/ 2, 0x02, 0x01, /* Enable Master Analog Power Control */ 2, 0x7b, 0x01, /* Set the REF charging time to 40ms */ - 2, 0x14, 0x25, /* HP soft stepping settings for optimal pop performance at power up Rpop used is 6k with N = 6 and soft step = 20usec. This should work with 47uF coupling capacitor. Can try N=5,6 or 7 time constants as well. Trade-off delay vs “pop” sound. */ + 2, 0x14, 0x25, /* HP soft stepping settings for optimal pop performance at power up Rpop used is 6k with N = 6 and soft step = 20usec. This should work with 47uF coupling capacitor. Can try N=5,6 or 7 time constants as well. Trade-off delay vs sound. */ 2, 0x0a, 0x33, /* Set the Input Common Mode to 0.9V and Output Common Mode for Headphone to 1.65V */ 2, 0x3d, 0x00, /* Select ADC PTM_R4 */ @@ -152,3 +153,4 @@ void tlv320aic3204_set_gain(int lgain, int rgain) }; tlv320aic3204_config(data); } +#endif