diff --git a/NANOVNA_STM32_F303/adc.c b/NANOVNA_STM32_F303/adc.c index 20610e6..5e60cf4 100644 --- a/NANOVNA_STM32_F303/adc.c +++ b/NANOVNA_STM32_F303/adc.c @@ -21,7 +21,7 @@ #include "hal.h" #include "nanovna.h" -#define ADC_FULL_SCALE 3000 +#define ADC_FULL_SCALE 3300 #define F303_ADC_VREF_ALWAYS_ON #define ADC_CHSELR_VREFINT ADC_CHANNEL_IN18 diff --git a/main.c b/main.c index af405b4..cd79494 100644 --- a/main.c +++ b/main.c @@ -154,7 +154,7 @@ static THD_FUNCTION(Thread1, arg) b.mode = setting.mode; uint32_t *f = (uint32_t *)&b; uint32_t *t = &backup; - int i = 5; + int i = USED_BACKUP_SIZE; while (i--) *t++ = *f++; @@ -2576,7 +2576,7 @@ int main(void) #endif if(config_recall()) { uint32_t *f = &backup; // Clear backup when no valid config data - int i = 5; + int i = USED_BACKUP_SIZE; while (i--) *f++ = 0; } @@ -2632,10 +2632,10 @@ int main(void) backup_t b; uint32_t *f = &backup; uint32_t *t = (uint32_t *)&b; - int i = 5; + int i = USED_BACKUP_SIZE; while (i--) *t++ = *f++; -#if 0 // Set mode not working reliably +#ifdef TINYSA4 // Set mode not working reliably set_mode(b.mode); switch (b.mode) { case M_LOW: diff --git a/nanovna.h b/nanovna.h index 7f7178b..342d3c0 100644 --- a/nanovna.h +++ b/nanovna.h @@ -1564,7 +1564,7 @@ extern const menuitem_t menu_mode[]; extern void menu_push_submenu(const menuitem_t *submenu); typedef struct { - uint32_t frequency0, frequency1; + freq_t frequency0, frequency1; uint8_t attenuation; uint8_t reflevel; uint8_t RBW; @@ -1574,7 +1574,17 @@ typedef struct { #define backup (*(uint32_t *)0x40002850) // backup registers 5 * 32 bits +#ifdef TINYSA4 +#define MAX_BACKUP_SIZE 16 +#define USED_BACKUP_SIZE 5 +#else +#define MAX_BACKUP_SIZE 5 +#define USED_BACKUP_SIZE 3 +#endif +#if USED_BACKUP_SIZE > MAX_BACKUP_SIZE +#error "backup_t too large" +#endif /* * misclinous */