Saveconfig working and console command 64 bit frequencies

Removed_REF_marker
erikkaashoek 5 years ago
parent a04d69b011
commit 5ba6bdbe45

@ -254,11 +254,11 @@ int chvprintf(BaseSequentialStream *chp, const char *fmt, va_list ap) {
int precision, width;
int n = 0;
uint32_t state;
union {
volatile union {
uint32_t u;
int32_t l;
float f;
uint64_t x;
int64_t x;
}value;
#if CHPRINTF_USE_FLOAT
char tmpbuf[2*MAX_FILLER + 1];
@ -359,9 +359,9 @@ int chvprintf(BaseSequentialStream *chp, const char *fmt, va_list ap) {
case 'I':
case 'i':
if (state & IS_LONG)
value.x = va_arg(ap, uint64_t);
value.x = va_arg(ap, int64_t);
else
value.x = va_arg(ap, uint32_t);
value.x = va_arg(ap, int32_t);
if (value.x < 0) {
state|=NEGATIVE;
*p++ = '-';
@ -373,7 +373,7 @@ int chvprintf(BaseSequentialStream *chp, const char *fmt, va_list ap) {
else if (state & PLUS_SPACE)
*p++ = ' ';
#endif
p = long_to_string_with_divisor(p, (uint64_t)value.x, 10, 0);
p = long_to_string_with_divisor(p, (int64_t)value.x, 10, 0);
break;
case 'q':
if (state & IS_LONG)

@ -21,7 +21,7 @@
#include "hal.h"
#include "nanovna.h"
#include <string.h>
#include "usbcfg.h"
static int flash_wait_for_last_operation(void)
{
while (FLASH->SR == FLASH_SR_BSY) {
@ -70,8 +70,10 @@ checksum(const void *start, size_t len)
uint32_t *p = (uint32_t*)start;
uint32_t *tail = (uint32_t*)(start + len);
uint32_t value = 0;
while (p < tail)
while (p < tail) {
value = __ROR(value, 31) + *p++;
if (SDU1.config->usbp->state == USB_ACTIVE) shell_printf("%x\r\n", value);
}
return value;
}
@ -107,7 +109,7 @@ config_recall(void)
if (src->magic != CONFIG_MAGIC)
return -1;
if (checksum(src, sizeof *src - sizeof src->checksum) != src->checksum)
if (checksum(src, sizeof config - sizeof config.checksum) != src->checksum)
return -1;
/* duplicated saved data onto sram to be able to modify marker/trace */

@ -443,9 +443,9 @@ int set_frequency(freq_t freq)
// Rewrite universal standart str to value functions to more compact
//
// Convert string to int32
static int32_t my_atoi(const char *p)
static int64_t my_atoi(const char *p)
{
int32_t value = 0;
int64_t value = 0;
uint32_t c;
bool neg = false;
@ -466,9 +466,9 @@ static int32_t my_atoi(const char *p)
// 0o - for oct radix
// 0b - for bin radix
// default dec radix
uint32_t my_atoui(const char *p)
uint64_t my_atoui(const char *p)
{
uint32_t value = 0, radix = 10, c;
uint64_t value = 0, radix = 10, c;
if (*p == '+') p++;
if (*p == '0') {
switch (p[1]) {
@ -1124,7 +1124,7 @@ VNA_SHELL_FUNCTION(cmd_scan)
uint16_t mask = my_atoui(argv[3]);
if (mask) {
for (i = 0; i < points; i++) {
if (mask & 1) shell_printf("%u ", frequencies[i]);
if (mask & 1) shell_printf("%Lu ", frequencies[i]);
if (mask & 2) shell_printf("%f %f ", value(measured[2][i]), 0.0);
if (mask & 4) shell_printf("%f %f ", value(measured[1][i]), 0.0);
if (mask & 8) shell_printf("%f %f ", value(measured[0][i]), 0.0);
@ -1322,7 +1322,7 @@ get_sweep_frequency(int type)
VNA_SHELL_FUNCTION(cmd_sweep)
{
if (argc == 0) {
shell_printf("%d %d %d\r\n", get_sweep_frequency(ST_START), get_sweep_frequency(ST_STOP), sweep_points);
shell_printf("%Ld %Ld %d\r\n", get_sweep_frequency(ST_START), get_sweep_frequency(ST_STOP), sweep_points);
return;
} else if (argc > 3) {
goto usage;
@ -1990,7 +1990,7 @@ VNA_SHELL_FUNCTION(cmd_marker)
if (argc == 0) {
for (t = 0; t < MARKERS_MAX; t++) {
if (markers[t].enabled) {
shell_printf("%d %d %d %f\r\n", t+1, markers[t].index, markers[t].frequency, value(actual_t[markers[t].index]));
shell_printf("%d %d %Ld %f\r\n", t+1, markers[t].index, markers[t].frequency, value(actual_t[markers[t].index]));
}
}
return;
@ -2007,7 +2007,7 @@ VNA_SHELL_FUNCTION(cmd_marker)
goto usage;
if (argc == 1) {
display_marker:
shell_printf("%d %d %d %.2f\r\n", t+1, markers[t].index, markers[t].frequency, value(actual_t[markers[t].index]));
shell_printf("%d %d %Ld %.2f\r\n", t+1, markers[t].index, markers[t].frequency, value(actual_t[markers[t].index]));
active_marker = t;
// select active marker
markers[t].enabled = TRUE;
@ -2075,7 +2075,7 @@ VNA_SHELL_FUNCTION(cmd_frequencies)
(void)argv;
for (i = 0; i < sweep_points; i++) {
if (frequencies[i] != 0)
shell_printf("%u\r\n", frequencies[i]);
shell_printf("%Lu\r\n", frequencies[i]);
}
}
@ -2907,10 +2907,11 @@ int main(void)
/* restore config */
config_recall();
#if 1
if (caldata_recall(0) == -1) {
load_LCD_properties();
}
#endif
/*
* Init Shell console connection data (after load config for settings)
*/

@ -582,7 +582,7 @@ typedef struct config {
int8_t cor_wfm;
int8_t cor_nfm;
int8_t ultra;
int8_t dummy;
uint32_t dummy;
// uint8_t _reserved[22];
uint32_t checksum;
} config_t;

@ -575,7 +575,7 @@ VNA_SHELL_FUNCTION(cmd_a)
{
(void)argc;
if (argc != 1) {
shell_printf("a=%u\r\n", frequencyStart);
shell_printf("a=%Lu\r\n", frequencyStart);
return;
}
freq_t value = my_atoui(argv[0]);
@ -587,7 +587,7 @@ VNA_SHELL_FUNCTION(cmd_b)
{
(void)argc;
if (argc != 1) {
shell_printf("b=%u\r\n", frequencyStop);
shell_printf("b=%Lu\r\n", frequencyStop);
return;
}
freq_t value = my_atoui(argv[0]);
@ -720,7 +720,7 @@ VNA_SHELL_FUNCTION(cmd_correction)
if (argc == 0) {
shell_printf("index frequency value\r\n");
for (int i=0; i<CORRECTION_POINTS; i++) {
shell_printf("%d %d %.1f\r\n", i, config.correction_frequency[i], config.correction_value[i]);
shell_printf("%d %Ld %.1f\r\n", i, config.correction_frequency[i], config.correction_value[i]);
}
return;
}
@ -741,7 +741,7 @@ VNA_SHELL_FUNCTION(cmd_correction)
config.correction_frequency[i] = f;
config.correction_value[i] = v;
redraw_request|=REDRAW_AREA; // to ensure the change in level will be visible
shell_printf("updated %d to %d %.1f\r\n", i, config.correction_frequency[i], config.correction_value[i]);
shell_printf("updated %d to %Ld %.1f\r\n", i, config.correction_frequency[i], config.correction_value[i]);
}
VNA_SHELL_FUNCTION(cmd_scanraw)

@ -1819,6 +1819,8 @@ int binary_search(freq_t f)
return true;
if(config.frequency_IF1 > fmin && config.frequency_IF1 < fplus)
return true;
if(4*config.frequency_IF1 > fmin && 4*config.frequency_IF1 < fplus)
return true;
return false;
}

Loading…
Cancel
Save

Powered by TurnKey Linux.