From 57fd136d840f094afba68e23d655fd28ac078a58 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Mon, 4 Jul 2022 13:17:33 +0200 Subject: [PATCH] tinySA3 cal change, UI bug --- main.c | 26 ++++++++++++++++++++++++++ nanovna.h | 4 ++-- sa_core.c | 4 ++++ ui_sa.c | 2 +- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index bf5342d..cd83606 100644 --- a/main.c +++ b/main.c @@ -2435,16 +2435,36 @@ static void dac_init(void){ rccEnableDAC1(false); // Enable DAC1 } +#ifdef TINYSA4__ +#define PULSE { palClearPad(GPIOB, 14); my_microsecond_delay(2); palSetPad(GPIOB, 14); } +#else +#define PULSE +#endif + int main(void) { halInit(); + /* + * Initiate 1 micro second timer + */ + #ifdef TINYSA4 + gptStart(&GPTD4, &gpt4cfg); + gptPolledDelay(&GPTD4, 10); // 10 us delay + #else + gptStart(&GPTD14, &gpt4cfg); + gptPolledDelay(&GPTD14, 10); // 10 us delay + #endif + + PULSE chSysInit(); + PULSE /* * Initialize RTC library (not used ChibiOS RTC module) */ #ifdef __USE_RTC__ rtc_init(); #endif + PULSE //palSetPadMode(GPIOB, 8, PAL_MODE_ALTERNATE(1) | PAL_STM32_OTYPE_OPENDRAIN); //palSetPadMode(GPIOB, 9, PAL_MODE_ALTERNATE(1) | PAL_STM32_OTYPE_OPENDRAIN); @@ -2499,6 +2519,7 @@ int main(void) #endif spi_init(); + PULSE /* @@ -2506,6 +2527,7 @@ int main(void) * Starting DAC1 driver, setting up the output pin as analog as suggested by the Reference Manual. */ dac_init(); + PULSE DAC->CR|= DAC_CR_EN1 | DAC_CR_EN2; // Use DAC: CH1 and CH2 #ifdef __LCD_BRIGHTNESS__ lcd_setBrightness(DEFAULT_BRIGHTNESS); @@ -2516,12 +2538,16 @@ int main(void) * SPI LCD Initialize */ ili9341_init(); + PULSE #ifdef TINYSA4 ili9341_set_foreground(LCD_FG_COLOR); + PULSE ili9341_drawstring("Starting...", 0,0); + PULSE disk_initialize(0); + PULSE // SD_PowerOn(); #endif diff --git a/nanovna.h b/nanovna.h index ae4f3eb..da6d0c2 100644 --- a/nanovna.h +++ b/nanovna.h @@ -18,7 +18,7 @@ */ #include "ch.h" -//#ifdef TINYSA_F303 +#ifdef TINYSA_F303 #ifdef TINYSA_F072 #error "Remove comment for #ifdef TINYSA_F303" #endif @@ -26,7 +26,7 @@ #define TINYSA4 #endif #define TINYSA4_PROTO -//#endif +#endif #ifdef TINYSA_F072 #ifdef TINYSA_F303 diff --git a/sa_core.c b/sa_core.c index 34f4645..2df9a05 100644 --- a/sa_core.c +++ b/sa_core.c @@ -7122,8 +7122,12 @@ again: set_attenuation(10); #endif set_sweep_frequency(ST_CENTER, 30000000); +#ifdef TINYSA4 set_sweep_frequency(ST_SPAN, 10000); markers[0].mtype |= M_AVER; +#else + set_sweep_frequency(ST_SPAN, 5000000); +#endif setting.rbw_x10 = 3000; setting.repeat = 10; int test_case = TEST_POWER; diff --git a/ui_sa.c b/ui_sa.c index 53b9f19..f173fcd 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -3249,7 +3249,7 @@ static void fetch_numeric_target(uint8_t mode) switch (mode) { case KM_START: uistat.freq_value = get_sweep_frequency(ST_START) + (setting.frequency_offset - FREQUENCY_SHIFT); - plot_printf(uistat.text, sizeof uistat.text, "%.3QMHz", uistat.freq_value); + plot_printf(uistat.text, sizeof uistat.text, "%.3QHz", uistat.freq_value); break; case KM_STOP: uistat.freq_value = get_sweep_frequency(ST_STOP) + (setting.frequency_offset - FREQUENCY_SHIFT);