From be8599d664a31ad585d39e669b62666b8e0ba838 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Sat, 27 Jun 2020 15:03:56 +0300 Subject: [PATCH] Set frequencyStop and frequencyStart uint32_t type --- main.c | 6 ++++-- sa_cmd.c | 23 ++++++++++++++--------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/main.c b/main.c index e416c09..c723fee 100644 --- a/main.c +++ b/main.c @@ -38,8 +38,8 @@ extern uint32_t minFreq; extern uint32_t maxFreq; -float frequencyStart; -float frequencyStop; +uint32_t frequencyStart; +uint32_t frequencyStop; int32_t frequencyExtra; #define START_MIN minFreq #define STOP_MAX maxFreq @@ -133,6 +133,7 @@ static THD_FUNCTION(Thread1, arg) ui_process(); while (1) { +// START_PROFILE if (sweep_mode&(SWEEP_ENABLE|SWEEP_ONCE)) { // if (dirty) completed = sweep(true); @@ -151,6 +152,7 @@ static THD_FUNCTION(Thread1, arg) // if (setting.mode != -1) __WFI(); } +// STOP_PROFILE // Run Shell command in sweep thread if (shell_function) { operation_requested = OP_NONE; // otherwise commands will be aborted diff --git a/sa_cmd.c b/sa_cmd.c index c2c4fc5..f95027c 100644 --- a/sa_cmd.c +++ b/sa_cmd.c @@ -371,7 +371,7 @@ VNA_SHELL_FUNCTION(cmd_a) { (void)argc; if (argc != 1) { - shell_printf("a=%d\r\n", frequencyStart); + shell_printf("a=%u\r\n", frequencyStart); return; } uint32_t value = my_atoui(argv[0]); @@ -383,7 +383,7 @@ VNA_SHELL_FUNCTION(cmd_b) { (void)argc; if (argc != 1) { - shell_printf("b=%d\r\n", frequencyStop); + shell_printf("b=%u\r\n", frequencyStop); return; } uint32_t value = my_atoui(argv[0]); @@ -425,20 +425,25 @@ VNA_SHELL_FUNCTION(cmd_s) void sweep_remote(void) { - int old_step = setting.frequency_step; - uint32_t f_step = (frequencyStop-frequencyStart)/ points; - setting.frequency_step = f_step; + uint32_t i; + uint32_t step = (points - 1); + uint32_t span = frequencyStop - frequencyStart; + uint32_t delta = span / step; + uint32_t error = span % step; + uint32_t f = frequencyStart - setting.frequency_IF, df = step>>1; + uint32_t old_step = setting.frequency_step; + setting.frequency_step = delta; streamPut(shell_stream, '{'); dirty = true; - for (int i = 0; i>8) & 0xFF)); - // enable led + df+=error;if (df >=step) {f++;df -= step;} } streamPut(shell_stream, '}'); setting.frequency_step = old_step;