diff --git a/NANOVNA_STM32_F303/board.c b/NANOVNA_STM32_F303/board.c index 82b9c2f..6ca71af 100644 --- a/NANOVNA_STM32_F303/board.c +++ b/NANOVNA_STM32_F303/board.c @@ -78,7 +78,7 @@ void __early_init(void) { // __enable_irq(); // reset magic bytes *((unsigned long *)BOOT_FROM_SYTEM_MEMORY_MAGIC_ADDRESS) = 0; - #if 1 + #if 0 // https://stm32f4-discovery.net/2017/04/tutorial-jump-system-memory-software-stm32/ // Step: Disable systick timer and reset it to default values #if 0 @@ -109,12 +109,22 @@ void __early_init(void) { //msp = *(uint32_t *) 0; msp = 0x20002250; #endif +// bootloader = (pFunction) 0x1FFFF796; __set_MSP(msp); bootloader(); while(1); #else - __set_MSP(SYSTEM_BOOT_MSP); - ( (void (*)(void)) (*((uint32_t *)(STM32F303xC_SYSTEM_MEMORY+4))) )(); + __disable_irq(); + uint32_t foo = SYSCFG->CFGR1; + foo = (foo & ~SYSCFG_CFGR1_MEM_MODE) || SYSCFG_CFGR1_MEM_MODE_0; + SYSCFG->CFGR1 = foo; + __DSB(); + __ISB(); + + __set_MSP(*((uint32_t *)(STM32F303xC_SYSTEM_MEMORY))); + ((void (*)(void))(*((uint32_t *)(STM32F303xC_SYSTEM_MEMORY + 4))))(); // jump to DFU + // __set_MSP(SYSTEM_BOOT_MSP); + // ( (void (*)(void)) (*((uint32_t *)(STM32F303xC_SYSTEM_MEMORY+4))) )(); while(1); #endif } diff --git a/nanovna.h b/nanovna.h index 0ef510e..6c02c45 100644 --- a/nanovna.h +++ b/nanovna.h @@ -84,6 +84,7 @@ #define __LIMITS__ #define __CURVE_EDIT__ #ifdef TINYSA3 +#define __HAS_DFU__ #define __MCU_CLOCK_SHIFT__ #endif #ifdef TINYSA4 @@ -1176,7 +1177,6 @@ typedef struct setting uint8_t atten_step; // 0...1 !!! need convert to bool int8_t _active_marker; // -1...MARKER_MAX uint8_t unit_scale_index; // table index - uint8_t repeat; // 1...100 uint8_t noise; // 2...50 uint8_t lo_drive; // 0-3 , 3dB steps uint8_t rx_drive; // 0-15 , 7=+20dBm, 3dB steps @@ -1186,6 +1186,7 @@ typedef struct setting uint8_t _traces; // enabled traces flags uint8_t draw_line; // uses the trigger level setting + uint16_t repeat; // 1...100 uint16_t linearity_step; // range equal POINTS_COUNT uint16_t _sweep_points; int16_t attenuate_x2; // 0...60 !!! in calculation can be < 0 @@ -1391,7 +1392,7 @@ typedef struct properties { //sizeof(properties_t) == 0x1200 #define CONFIG_MAGIC 0x434f4e60 /* 'CONF' */ -#define SETTING_MAGIC 0x434f4e60 +#define SETTING_MAGIC 0x434f4e61 extern int16_t lastsaveid; //extern properties_t *active_props; diff --git a/sa_core.c b/sa_core.c index 20aa93f..51a26d2 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1083,17 +1083,17 @@ void set_modulation_frequency(int f) f = 50; if (f > 10000) f = 10000; -//#ifdef TINYSA4 -// if (setting.modulation == MO_WFM && f > 2000) -// f = 2000; -//#endif +#ifdef TINYSA4 + if (setting.modulation == MO_WFM && f > 3500) + f = 3500; +#endif setting.modulation_frequency = f; dirty = true; } void set_repeat(int r) { - if (r > 0 && r <= 500) { + if (r > 0 && r <= 10000) { setting.repeat = r; // dirty = true; // No HW update required, only status panel refresh } diff --git a/ui.c b/ui.c index c9961ab..53a1a30 100644 --- a/ui.c +++ b/ui.c @@ -666,7 +666,7 @@ extern const char *states[]; lcd_set_font(FONT_SMALL); } -#ifndef TINYSA4 +#ifdef __HAS_DFU__ void enter_dfu(void) { @@ -2143,7 +2143,7 @@ static UI_FUNCTION_CALLBACK(menu_config_cb) redraw_frame(); request_to_redraw_grid(); } -#ifndef TINYSA4 +#ifdef __HAS_DFU__ static UI_FUNCTION_CALLBACK(menu_dfu_cb) { (void)data; @@ -3882,7 +3882,7 @@ static const menuitem_t menu_modulation[] = { { MT_FORM | MT_ADV_CALLBACK | MT_LOW, MO_AM, "AM", menu_modulation_acb}, #ifdef TINYSA4 { MT_FORM | MT_ADV_CALLBACK, MO_WFM, "FM", menu_modulation_acb}, - { MT_FORM | MT_KEYPAD, KM_MODULATION, "FREQ: %s", "50Hz..5kHz"}, + { MT_FORM | MT_KEYPAD, KM_MODULATION, "FREQ: %s", "50Hz..3.5kHz"}, { MT_FORM | MT_KEYPAD, KM_DEPTH, "AM DEPTH: %s%%", "0..100"}, { MT_FORM | MT_KEYPAD, KM_DEVIATION, "FM DEVIATION: %s", "1kHz..300kHz"}, // { MT_FORM | MT_ADV_CALLBACK, MO_NFM2, MT_CUSTOM_LABEL, menu_modulation_acb}, @@ -4097,7 +4097,7 @@ static const menuitem_t menu_marker[] = { { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; -#ifndef TINYSA4 +#ifdef __HAS_DFU__ static const menuitem_t menu_dfu[] = { { MT_FORM | MT_CALLBACK, 0, "ENTER DFU", menu_dfu_cb}, { MT_FORM | MT_NONE, 0, NULL, menu_back} // next-> menu_back @@ -4502,14 +4502,14 @@ static const menuitem_t menu_config[] = { #ifdef __SPUR__ { MT_ADV_CALLBACK,0, "%s", menu_spur_acb}, #endif - { MT_KEYPAD, KM_REPEAT, "SAMPLE REP\n\b%s", "1..100"}, + { MT_KEYPAD, KM_REPEAT, "SAMPLE REP\n\b%s", "1..10000"}, #ifdef __LCD_BRIGHTNESS__ { MT_ADV_CALLBACK, 0, "BRIGHTNESS\n \b%d%%", menu_brightness_acb}, #endif #ifdef __USE_RTC__ { MT_SUBMENU, 0, "DATE\nTIME", menu_date_time}, #endif -#ifndef TINYSA4 +#ifdef __HAS_DFU__ { MT_SUBMENU, 0, S_RARROW" DFU", menu_dfu}, #endif { MT_SUBMENU, 0, S_RARROW"MORE", menu_config2},