From eca14f8e3cd7a36b8ca332541a4102e8ee248d62 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Tue, 30 Jun 2020 19:38:56 +0300 Subject: [PATCH 1/5] Small code optimization (less size) in marker move from leveler Now step increase every 4 step on one --- ui.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/ui.c b/ui.c index 0f49589..8483d3a 100644 --- a/ui.c +++ b/ui.c @@ -1907,29 +1907,22 @@ ui_mode_normal(void) static void lever_move_marker(int status) { - int step = 1; - int count = 0; + uint16_t step = 1<<2; do { if (active_marker >= 0 && markers[active_marker].enabled) { - if ((status & EVT_DOWN) && markers[active_marker].index > 0) { - markers[active_marker].index -= step; + if (status & EVT_DOWN) { + markers[active_marker].index -= step>>2; if (markers[active_marker].index < 0) markers[active_marker].index = 0 ; - markers[active_marker].frequency = frequencies[markers[active_marker].index]; - redraw_marker(active_marker); } - if ((status & EVT_UP) && markers[active_marker].index < sweep_points-1) { - markers[active_marker].index += step; + if (status & EVT_UP) { + markers[active_marker].index += step>>2; if (markers[active_marker].index > sweep_points-1) markers[active_marker].index = sweep_points-1 ; - markers[active_marker].frequency = frequencies[markers[active_marker].index]; - redraw_marker(active_marker); - } - count++; - if (count > 10) { - step *= 2; - count = 0; } + markers[active_marker].frequency = frequencies[markers[active_marker].index]; + redraw_marker(active_marker); + step++; } status = btn_wait_release(); } while (status != 0); From 82265cd4471a8137b241706a4920cf3a238052cb Mon Sep 17 00:00:00 2001 From: DiSlord Date: Tue, 30 Jun 2020 19:43:54 +0300 Subject: [PATCH 2/5] Add thread information on debug screen Increase main thread stack size, now 0x200 --- Makefile | 2 +- main.c | 30 +++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index ad5d38a..6ce429d 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ endif # Stack size to be allocated to the Cortex-M process stack. This stack is # the stack used by the main() thread. ifeq ($(USE_PROCESS_STACKSIZE),) - USE_PROCESS_STACKSIZE = 0x180 + USE_PROCESS_STACKSIZE = 0x200 endif # Stack size to the allocated to the Cortex-M main/exceptions stack. This diff --git a/main.c b/main.c index 82d04a6..a9688dd 100644 --- a/main.c +++ b/main.c @@ -2208,13 +2208,13 @@ VNA_SHELL_FUNCTION(cmd_color) #if CH_CFG_USE_REGISTRY == FALSE #error "Threads Requite enabled CH_CFG_USE_REGISTRY in chconf.h" #endif +static const char *states[] = {CH_STATE_NAMES}; VNA_SHELL_FUNCTION(cmd_threads) { - static const char *states[] = {CH_STATE_NAMES}; thread_t *tp; (void)argc; (void)argv; - shell_printf("stklimit| |stk free| addr|refs|prio| state| name"VNA_SHELL_NEWLINE_STR); + shell_printf("stklimit| |stk free| addr|refs|prio| state| name"VNA_SHELL_NEWLINE_STR); tp = chRegFirstThread(); do { uint32_t max_stack_use = 0U; @@ -2783,8 +2783,8 @@ void hard_fault_handler_c(uint32_t *sp) uint32_t pc = sp[6]; uint32_t psr = sp[7]; int y = 0; - int x = 20; - static char buf[16]; + int x = OFFSETX + 1; + static char buf[96]; ili9341_set_background(0x0000); ili9341_set_foreground(0xFFFF); @@ -2805,7 +2805,27 @@ void hard_fault_handler_c(uint32_t *sp) plot_printf(buf, sizeof(buf), "LR 0x%08x", lr);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); plot_printf(buf, sizeof(buf), "PC 0x%08x", pc);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); plot_printf(buf, sizeof(buf), "PSR 0x%08x", psr);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); - +#ifdef ENABLE_THREADS_COMMAND + thread_t *tp; + tp = chRegFirstThread(); + do { + uint32_t max_stack_use = 0U; +#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || (CH_CFG_USE_DYNAMIC == TRUE) + uint32_t stklimit = (uint32_t)tp->wabase; +#if CH_DBG_FILL_THREADS == TRUE + uint8_t *p = (uint8_t *)tp->wabase; while(p[max_stack_use]==CH_DBG_STACK_FILL_VALUE) max_stack_use++; +#endif +#else + uint32_t stklimit = 0U; +#endif + plot_printf(buf, sizeof(buf), "%08x|%08x|%08x|%08x|%4u|%4u|%9s|%12s", + stklimit, (uint32_t)tp->ctx.sp, max_stack_use, (uint32_t)tp, + (uint32_t)tp->refs - 1, (uint32_t)tp->prio, states[tp->state], + tp->name == NULL ? "" : tp->name); + ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); + tp = chRegNextThread(tp); + } while (tp != NULL); +#endif shell_printf("===================================\r\n"); #else (void)sp; From 9b4a8d916ca765f67566a78ff256fcff5a8fa04b Mon Sep 17 00:00:00 2001 From: DiSlord Date: Tue, 30 Jun 2020 20:37:49 +0300 Subject: [PATCH 3/5] remove not correct select waterfall button on enable spur removal --- sa_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sa_core.c b/sa_core.c index f78b29b..f265e1b 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1594,7 +1594,7 @@ again: // Waiting for a trigger jumps back to here t = setting.sweep_time_us; } else setting.additional_step_delay_us = 0; - setting.actual_sweep_time_us = t; + //setting.actual_sweep_time_us = t; if (MODE_OUTPUT(setting.mode) && setting.additional_step_delay_us < 500) // Minimum wait time to prevent LO from lockup during output frequency sweep setting.additional_step_delay_us = 500; if (break_on_operation && MODE_INPUT(setting.mode)) { // during normal operation From 5c8ae50a3edf2f4476283cb8973c990b8b76b7c4 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Tue, 30 Jun 2020 20:44:43 +0300 Subject: [PATCH 4/5] Fix wrong file update Revert "remove not correct select waterfall button on enable spur removal" This reverts commit 9b4a8d916ca765f67566a78ff256fcff5a8fa04b. --- sa_core.c | 2 +- ui_sa.c | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/sa_core.c b/sa_core.c index f265e1b..f78b29b 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1594,7 +1594,7 @@ again: // Waiting for a trigger jumps back to here t = setting.sweep_time_us; } else setting.additional_step_delay_us = 0; - //setting.actual_sweep_time_us = t; + setting.actual_sweep_time_us = t; if (MODE_OUTPUT(setting.mode) && setting.additional_step_delay_us < 500) // Minimum wait time to prevent LO from lockup during output frequency sweep setting.additional_step_delay_us = 500; if (break_on_operation && MODE_INPUT(setting.mode)) { // during normal operation diff --git a/ui_sa.c b/ui_sa.c index 4f1f99b..fcdc3a5 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -1679,11 +1679,6 @@ static void menu_item_modify_attribute( if (item == 5 && get_waterfall()){ mark = true; } -#ifdef __SPUR__ - if (item == 5 && setting.spur) { - mark = true; - } -#endif } else if (menu == menu_settings) { if (item ==0 && setting.tracking_output){ mark = true; From d845c67d2365240a1839c5c0fc3b4bbba1be44aa Mon Sep 17 00:00:00 2001 From: DiSlord Date: Tue, 30 Jun 2020 23:35:45 +0300 Subject: [PATCH 5/5] small code optimization --- sa_core.c | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/sa_core.c b/sa_core.c index f78b29b..2c31482 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1318,40 +1318,22 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) // M // ----------------------------------------------------- modulation for output modes --------------------------------------- if (MODE_OUTPUT(setting.mode)){ if (setting.modulation == MO_AM_1kHz || setting.modulation == MO_AM_10Hz) { // AM modulation - int p = setting.attenuate * 2 + am_modulation[modulation_counter]; - if (p>63) - p = 63; - if (p<0) - p = 0; + int p = setting.attenuate * 2 + am_modulation[modulation_counter++]; + if (p>63) p = 63; + else if (p< 0) p = 0; PE4302_Write_Byte(p); - if (modulation_counter == 4) { // 3dB modulation depth + if (modulation_counter == 5) // 3dB modulation depth modulation_counter = 0; - } else { - modulation_counter++; - } - if (setting.modulation == MO_AM_10Hz) - my_microsecond_delay(20000); - else - my_microsecond_delay(180); -// chThdSleepMicroseconds(200); + my_microsecond_delay(setting.modulation == MO_AM_10Hz ? 20000 : 180); } else if (setting.modulation == MO_NFM || setting.modulation == MO_WFM ) { //FM modulation SI4432_Sel = 1; - int offset; - if (setting.modulation == MO_NFM ) { - offset = nfm_modulation[modulation_counter] ; - SI4432_Write_Byte(SI4432_FREQ_OFFSET1, (offset & 0xff )); // Use frequency hopping channel for FM modulation - SI4432_Write_Byte(SI4432_FREQ_OFFSET2, ((offset >> 8) & 0x03 )); // Use frequency hopping channel for FM modulation - } - else { - offset = wfm_modulation[modulation_counter] ; - SI4432_Write_Byte(SI4432_FREQ_OFFSET1, (offset & 0xff )); // Use frequency hopping channel for FM modulation - SI4432_Write_Byte(SI4432_FREQ_OFFSET2, ((offset >> 8) & 0x03 )); // Use frequency hopping channel for FM modulation - } - if (modulation_counter == 4) + int offset = setting.modulation == MO_NFM ? nfm_modulation[modulation_counter] : wfm_modulation[modulation_counter] ; + SI4432_Write_Byte(SI4432_FREQ_OFFSET1, (offset & 0xff )); // Use frequency hopping channel for FM modulation + SI4432_Write_Byte(SI4432_FREQ_OFFSET2, ((offset >> 8) & 0x03 )); // Use frequency hopping channel for FM modulation + modulation_counter++; + if (modulation_counter == 5) // 3dB modulation depth modulation_counter = 0; - else - modulation_counter++; my_microsecond_delay(200); // chThdSleepMicroseconds(200); }