From e4587197f5a114ea74d1497eae7ed8882bb8619a Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Thu, 21 Jan 2021 17:24:17 +0100 Subject: [PATCH] updated USB command --- NANOVNA_STM32_F303/board.h | 2 +- main.c | 6 ++++-- sa_cmd.c | 28 +++++++++++++++++++++------- sa_core.c | 28 ++++++++++++++-------------- ui_sa.c | 14 +++++++++++--- 5 files changed, 51 insertions(+), 27 deletions(-) diff --git a/NANOVNA_STM32_F303/board.h b/NANOVNA_STM32_F303/board.h index a23812f..46f13fc 100644 --- a/NANOVNA_STM32_F303/board.h +++ b/NANOVNA_STM32_F303/board.h @@ -25,7 +25,7 @@ * Board identifier. */ #define BOARD_NANOVNA_STM32_F303 -#define BOARD_NAME "tinySA-H4" +#define BOARD_NAME "tinySA4" #include /* diff --git a/main.c b/main.c index 096593b..c29bb69 100644 --- a/main.c +++ b/main.c @@ -887,7 +887,7 @@ config_t config = { #ifdef TINYSA4 .frequency_IF1 = DEFAULT_IF, .frequency_IF2 = 0, - .ultra_threshold = 600000000, + .ultra_threshold = 800000000, #endif .low_level_offset = 100, // Uncalibrated .high_level_offset = 100, // Uncalibrated @@ -897,7 +897,8 @@ config_t config = { #endif #ifdef TINYSA4 .correction_frequency = { 10000, 100000, 200000, 500000, 1000000000U, 1500000000U, 2500000000U, 2800000000U, 3000000000U, 3300000000U }, - .correction_value = { 0, 0, 0, 0, 0.0, 1.5, 3, 6, 10, 10 }, + .correction_value = { 0, 0, 0, 0, 0.0, 0, 0, 0, 0, 0 }, + // .correction_value = { 0, 0, 0, 0, 0.0, 1.5, 3, 6, 10, 10 }, #endif .setting_frequency_10mhz = 10000000, .cor_am = -14, @@ -2412,6 +2413,7 @@ static const VNAShellCommand commands[] = { "spur", cmd_spur, 0 }, { "lna", cmd_lna, 0 }, { "ultra", cmd_ultra, 0 }, + { "ultra_start", cmd_ultra_start, CMD_WAIT_MUTEX }, { "load", cmd_load, 0 }, { "offset", cmd_offset, 0}, { "output", cmd_output, 0 }, diff --git a/sa_cmd.c b/sa_cmd.c index 8253e41..43e6b69 100644 --- a/sa_cmd.c +++ b/sa_cmd.c @@ -100,7 +100,7 @@ VNA_SHELL_FUNCTION(cmd_spur) // shell_printf("usage: spur %s\r\n", cmd); // return; // } - int m = generic_option_cmd("spur", "off|on", argc, argv[0]); + int m = generic_option_cmd("spur", "off|on|auto", argc, argv[0]); if (m>=0) { set_spur(m); redraw_request |= REDRAW_CAL_STATUS | REDRAW_AREA; @@ -280,18 +280,18 @@ VNA_SHELL_FUNCTION(cmd_rbw) { if (argc != 1) { usage: - shell_printf("usage: rbw 2..600|auto\r\n"); + shell_printf("usage: rbw 0.3..600|auto\r\n"); return; } if (get_str_index(argv[0], "auto|0")>=0) { if (setting.rbw_x10 != 0) set_RBW(0); } else { - uint32_t a = my_atoui(argv[0]); - if (a < 2 || a>600) + float a = my_atof(argv[0]); + if (a < 0.2 || a>900) goto usage; if (setting.rbw_x10 != a*10) - set_RBW(a*10); + set_RBW((int) ( a*10)); } } @@ -299,7 +299,7 @@ VNA_SHELL_FUNCTION(cmd_if) { if (argc != 1) { usage: - shell_printf("usage: if {433M..435M}\r\n"); + shell_printf("usage: if {433M..435M}\r\n%qHz\r\n", setting.frequency_IF); return; } else { uint32_t a = (uint32_t)my_atoi(argv[0]); @@ -310,11 +310,25 @@ VNA_SHELL_FUNCTION(cmd_if) } } +VNA_SHELL_FUNCTION(cmd_ultra_start) +{ + if (argc != 1) { + usage: + shell_printf("usage: ultra_start {0..4290M}\r\n%qHz\r\n", config.ultra_threshold); + return; + } else { + uint32_t a = (uint32_t)my_atoi(argv[0]); + config.ultra_threshold = a; + config_save(); + } +} + + VNA_SHELL_FUNCTION(cmd_if1) { if (argc != 1) { usage: - shell_printf("usage: if1 {975M..979M}\r\n"); + shell_printf("usage: if1 {975M..979M}\r\n%qHz\r\n", config.frequency_IF1); return; } else { uint32_t a = (uint32_t)my_atoi(argv[0]); diff --git a/sa_core.c b/sa_core.c index 5046c4a..653b6b6 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1541,7 +1541,11 @@ case M_GENLOW: // Mixed output from 0 case M_GENHIGH: // Direct output from 1 if (setting.mute) goto mute; -#ifdef __SI4432__ + enable_high(true); // Must be first to protect SAW filters + enable_extra_lna(false); + enable_ultra(false); + + #ifdef __SI4432__ SI4432_Sel = SI4432_RX ; SI4432_Receive(); set_switch_receive(); @@ -1573,20 +1577,16 @@ case M_GENHIGH: // Direct output from 1 ADF4351_enable_aux_out(false); ADF4351_enable_out(false); #ifdef __SI4468__ -// SI4463_set_output_level(setting.rx_drive); SI4463_init_tx(); - if (setting.lo_drive < 32) { - enable_rx_output(false); // use switch as attenuator - } else { +// if (setting.lo_drive < 32) { +// enable_rx_output(false); // use switch as attenuator +// } else { enable_rx_output(true); - } - SI4463_set_output_level(setting.lo_drive & 0x01F); +// } + SI4463_set_output_level(setting.lo_drive); #endif } - enable_high(true); - enable_extra_lna(false); - enable_ultra(false); break; } @@ -1765,8 +1765,8 @@ static const uint32_t spur_table[] = // Frequenc 117716000, 243775000, // 244250000, - 324875000, - 325190000, + 325000000, +// 325190000, 487541650, // This is linked to the MODULO of the ADF4350 // 487993000, // 488020700, @@ -1774,7 +1774,7 @@ static const uint32_t spur_table[] = // Frequenc // 487578000, // 488500000, 650700000, - 651333333, +// 651333333, 732750000, 746083000 /* @@ -2079,7 +2079,7 @@ modulation_again: } // -------------------------------- Acquisition loop for one requested frequency covering spur avoidance and vbwsteps ------------------------ pureRSSI_t RSSI = float_TO_PURE_RSSI(-150); -//#define __DEBUG_SPUR__ +#define __DEBUG_SPUR__ #ifdef __DEBUG_SPUR__ // For debugging the spur avoidance control if (!setting.auto_IF) stored_t[i] = -90.0; // Display when to do spur shift in the stored trace diff --git a/ui_sa.c b/ui_sa.c index 0b5ad3a..7147f19 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -750,12 +750,16 @@ static UI_FUNCTION_ADV_CALLBACK(menu_lo_drive_acb) { (void)item; if(b){ +#ifdef TINYSA4 + b->param_1.i = data+20; +#else b->param_1.i = menu_drive_value[data] + (setting.mode==M_GENHIGH ? setting.offset : 0); +#endif b->icon = data == setting.lo_drive ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP; return; } //Serial.println(item); - set_lo_drive(data); + set_lo_drive(data+20); menu_move_back(); // ui_mode_normal(); // draw_cal_status(); @@ -765,7 +769,11 @@ static UI_FUNCTION_ADV_CALLBACK(menu_sdrive_acb){ (void)item; (void)data; if(b){ +#ifdef TINYSA4 + b->param_1.i = setting.lo_drive; +#else b->param_1.i = menu_drive_value[setting.lo_drive] + (setting.mode==M_GENHIGH ? setting.offset : 0); +#endif return; } menu_push_submenu(menu_drive_wide); @@ -1176,7 +1184,7 @@ static UI_FUNCTION_CALLBACK(menu_marker_delete_cb) } } -static const uint16_t rbwsel_x10[]={0,3,10,30,100,300,1000,3000,9000}; +static const uint16_t rbwsel_x10[]={0,3,10,30,100,300,1000,3000,6000}; static UI_FUNCTION_ADV_CALLBACK(menu_rbw_acb) { (void)item; @@ -2800,7 +2808,7 @@ redraw_cal_status: // Version y += YSTEP + YSTEP/2 ; - strncpy(buf,&VERSION[8], BLEN-1); + strncpy(buf,&VERSION[11], BLEN-1); ili9341_drawstring(buf, x, y);