diff --git a/main.c b/main.c index 678d5b9..d458f83 100644 --- a/main.c +++ b/main.c @@ -2504,7 +2504,9 @@ static const VNAShellCommand commands[] = { "a", cmd_a, CMD_WAIT_MUTEX }, { "b", cmd_b, CMD_WAIT_MUTEX }, { "t", cmd_t, CMD_WAIT_MUTEX }, +#ifdef TINYSA4 { "k", cmd_k, CMD_WAIT_MUTEX }, +#endif { "e", cmd_e, CMD_WAIT_MUTEX }, { "s", cmd_s, CMD_WAIT_MUTEX }, { "m", cmd_m, CMD_WAIT_MUTEX }, diff --git a/nanovna.h b/nanovna.h index 59bbf60..2307785 100644 --- a/nanovna.h +++ b/nanovna.h @@ -18,7 +18,7 @@ */ #include "ch.h" -//#ifdef TINYSA_F303 +#ifdef TINYSA_F303 #include "adc_F303.h" #ifdef TINYSA_F072 #error "Remove comment for #ifdef TINYSA_F303" @@ -27,7 +27,7 @@ #define TINYSA4 #endif #define TINYSA4_PROTO -//#endif +#endif #ifdef TINYSA_F072 #ifdef TINYSA_F303 diff --git a/plot.c b/plot.c index 314b2b0..810c6a5 100644 --- a/plot.c +++ b/plot.c @@ -303,6 +303,29 @@ marker_to_value(const int i) return(value(ref_marker_levels[markers[i].index])); } +#ifdef TINYSA3 +float sa_sqrtf(const float x) +{ + union + { + int i; + float x; + } u; + u.x = x; + u.i = (1<<29) + (u.i >> 1) - (1<<22); + + // Two Babylonian Steps (simplified from:) + // u.x = 0.5f * (u.x + x/u.x); + // u.x = 0.5f * (u.x + x/u.x); + u.x = u.x + x/u.x; + u.x = 0.25f*u.x + x/u.x; + + return u.x; +} +#else +#define sa_sqrtf(x) sqrtf(x) +#endif + // Function for convert to different type of values from dBm // Replaced some equal functions and use recalculated constants: // powf(10,x) = expf(x * logf(10)) @@ -1469,7 +1492,7 @@ static void cell_draw_marker_info(int x0, int y0) h += marker_to_value(1); h_i++; } - float thd = 100.0 * sqrtf(h/p); + float thd = 100.0 * sa_sqrtf(h/p); setting.unit = old_unit; ili9341_set_foreground(marker_color(markers[0].mtype)); // j = 1; diff --git a/sa_core.c b/sa_core.c index 4e50941..60f0ca8 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1073,6 +1073,8 @@ void set_offset_delay(int d) // override RSSI measurement delay void set_average(int v) { + if (setting.average == v) + dirty = true; setting.average = v; trace[TRACE_TEMP].enabled = ((v != 0) #ifdef __QUASI_PEAK__ diff --git a/si4468.c b/si4468.c index 79568d9..be7b628 100644 --- a/si4468.c +++ b/si4468.c @@ -868,65 +868,65 @@ static uint8_t SI4463_wait_response(void* buff, uint8_t len, uint8_t use_timeout return 1; } +#define SI_FAST_SPEED SPI_BR_DIV2 + void SI4463_do_api(void* data, uint8_t len, void* out, uint8_t outLen) { set_SPI_mode(SPI_MODE_SI); - SPI_BR_SET(SI4432_SPI, SI4432_SPI_SPEED); + SPI_BR_SET(SI4432_SPI, SI_FAST_SPEED); - while (!SI4463_READ_CTS) { my_microsecond_delay(1); } // Wait for CTS +#define SHORT_DELAY my_microsecond_delay(1) +//#define SHORT_DELAY - { - // SPI_BR_SET(SI4432_SPI, SPI_BR_DIV8); + while (!SI4463_READ_CTS) {SHORT_DELAY; } // Wait for CTS - __disable_irq(); - SI_CS_LOW; - for(uint8_t i=0;iparam_1.text = uistat.text; @@ -609,6 +609,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_curve_acb) common: set_sweep_frequency(ST_SPAN, 1000000); set_sweep_frequency(ST_CENTER, config.correction_frequency[current_curve][data]); + setting.step_delay_mode = SD_PRECISE; current_curve_index = data; menu_push_submenu(menu_curve_confirm); break; @@ -1401,7 +1402,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_average_acb) return; } set_average(data); - menu_move_back(true); +// menu_move_back(true); } extern const menuitem_t menu_marker_modify[]; @@ -2395,7 +2396,7 @@ static const menuitem_t menu_actual_power[] = #ifdef TINYSA4 { MT_CALLBACK, 0, "INPUT\nCURVE", menu_input_curve_prepare_cb}, { MT_CALLBACK, 0, "LNA\nCURVE", menu_lna_curve_prepare_cb}, - { MT_SUBMENU | MT_LOW, 0, "OUTPUT\nCURVE", menu_output_curve_prepare_cb}, + { MT_CALLBACK, 0, "OUTPUT\nCURVE", menu_output_curve_prepare_cb}, #endif { MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_NONE, 0, NULL, NULL } // sentinel