mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
add wait_dsp function, add trace all off command, fix hang on ploting polar with trace 0
This commit is contained in:
parent
25dd4bf182
commit
69c41aa57e
9
dsp.c
9
dsp.c
|
|
@ -75,7 +75,7 @@ hilbert_transform(void)
|
|||
}
|
||||
}
|
||||
|
||||
void calclate_gamma(float *gamma)
|
||||
void calculate_gamma(float *gamma)
|
||||
#if 0
|
||||
{
|
||||
__SIMD32_TYPE *r = __SIMD32_CONST(refiq_buf);
|
||||
|
|
@ -110,10 +110,12 @@ void calclate_gamma(float *gamma)
|
|||
float acc_ref = 0;
|
||||
int i;
|
||||
float rn;
|
||||
|
||||
int32_t offset_s0 = 0;
|
||||
int32_t offset_r0 = 0;
|
||||
int32_t offset_i0 = 0;
|
||||
|
||||
__disable_irq();
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
offset_s0 += *s++;
|
||||
offset_i0 += *r++;
|
||||
|
|
@ -133,6 +135,9 @@ void calclate_gamma(float *gamma)
|
|||
acc_i += (float)(s0 * ri);
|
||||
acc_ref += (float)rr*rr + (float)ri*ri;
|
||||
}
|
||||
|
||||
__enable_irq();
|
||||
|
||||
//rn = sqrtf(acc_ref / len) * 2e3 * len;
|
||||
rn = acc_ref / 10;
|
||||
gamma[0] = -acc_r / rn;
|
||||
|
|
|
|||
67
main.c
67
main.c
|
|
@ -211,13 +211,18 @@ static struct {
|
|||
int16_t rx_buffer[AUDIO_BUFFER_LEN * 2];
|
||||
|
||||
int16_t dump_buffer[AUDIO_BUFFER_LEN];
|
||||
volatile int16_t wait_count = 0;
|
||||
int16_t dump_selection = 0;
|
||||
volatile int16_t wait_count = 0;
|
||||
|
||||
int16_t dsp_disabled = FALSE;
|
||||
float measured[2][101][2];
|
||||
|
||||
|
||||
static void
|
||||
wait_dsp(int count)
|
||||
{
|
||||
wait_count = count;
|
||||
while (wait_count)
|
||||
;
|
||||
}
|
||||
|
||||
void i2s_end_callback(I2SDriver *i2sp, size_t offset, size_t n)
|
||||
{
|
||||
|
|
@ -230,8 +235,7 @@ void i2s_end_callback(I2SDriver *i2sp, size_t offset, size_t n)
|
|||
(void)n;
|
||||
//palClearPad(GPIOC, GPIOC_LED);
|
||||
|
||||
if (!dsp_disabled)
|
||||
dsp_process(p, n);
|
||||
dsp_process(p, n);
|
||||
|
||||
if (wait_count > 0) {
|
||||
if (dump_selection == 1)
|
||||
|
|
@ -297,10 +301,9 @@ static void cmd_dump(BaseSequentialStream *chp, int argc, char *argv[])
|
|||
if (argc == 1)
|
||||
dump_selection = atoi(argv[0]);
|
||||
|
||||
wait_count = 3;
|
||||
//palClearPad(GPIOC, GPIOC_LED);
|
||||
while (wait_count)
|
||||
;
|
||||
wait_dsp(3);
|
||||
|
||||
len = AUDIO_BUFFER_LEN;
|
||||
if (dump_selection == 1 || dump_selection == 2)
|
||||
len /= 2;
|
||||
|
|
@ -320,12 +323,8 @@ static void cmd_gamma(BaseSequentialStream *chp, int argc, char *argv[])
|
|||
(void)argv;
|
||||
|
||||
pause_sweep();
|
||||
wait_count = 4;
|
||||
while (wait_count)
|
||||
;
|
||||
dsp_disabled = TRUE;
|
||||
calclate_gamma(gamma);
|
||||
dsp_disabled = FALSE;
|
||||
wait_dsp(4);
|
||||
calculate_gamma(gamma);
|
||||
|
||||
chprintf(chp, "%d %d\r\n", gamma[0], gamma[1]);
|
||||
}
|
||||
|
|
@ -390,17 +389,11 @@ static void cmd_scan(BaseSequentialStream *chp, int argc, char *argv[])
|
|||
delay += 2;
|
||||
for (i = 0; i < sweep_points; i++) {
|
||||
freq = freq + step;
|
||||
wait_count = delay + 1;
|
||||
while (wait_count)
|
||||
;
|
||||
//dsp_disabled = TRUE;
|
||||
__disable_irq();
|
||||
wait_dsp(delay+1);
|
||||
delay = set_frequency(freq);
|
||||
palClearPad(GPIOC, GPIOC_LED);
|
||||
calclate_gamma(gamma);
|
||||
calculate_gamma(gamma);
|
||||
palSetPad(GPIOC, GPIOC_LED);
|
||||
//dsp_disabled = FALSE;
|
||||
__enable_irq();
|
||||
chprintf(chp, "%d %d\r\n", gamma[0], gamma[1]);
|
||||
}
|
||||
}
|
||||
|
|
@ -414,24 +407,18 @@ void scan_lcd(void)
|
|||
delay = set_frequency(frequencies[0]);
|
||||
delay += 2;
|
||||
for (i = 0; i < sweep_points; i++) {
|
||||
wait_count = delay + 2;
|
||||
tlv320aic3204_select_in3();
|
||||
while (wait_count)
|
||||
;
|
||||
wait_dsp(delay+2);
|
||||
palClearPad(GPIOC, GPIOC_LED);
|
||||
__disable_irq();
|
||||
|
||||
/* calculate reflection coeficient */
|
||||
calclate_gamma(measured[0][i]);
|
||||
__enable_irq();
|
||||
calculate_gamma(measured[0][i]);
|
||||
|
||||
tlv320aic3204_select_in1();
|
||||
wait_count = 2 + 2;
|
||||
while (wait_count)
|
||||
;
|
||||
__disable_irq();
|
||||
wait_dsp(2+2);
|
||||
|
||||
/* calculate transmission coeficient */
|
||||
calclate_gamma(measured[1][i]);
|
||||
__enable_irq();
|
||||
calculate_gamma(measured[1][i]);
|
||||
|
||||
delay = set_frequency(frequencies[(i+1)%sweep_points]);
|
||||
palSetPad(GPIOC, GPIOC_LED);
|
||||
|
|
@ -879,6 +866,16 @@ static void cmd_trace(BaseSequentialStream *chp, int argc, char *argv[])
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(argv[0], "all") == 0 &&
|
||||
argc > 1 && strcmp(argv[1], "off") == 0) {
|
||||
set_trace_type(0, TRC_OFF);
|
||||
set_trace_type(1, TRC_OFF);
|
||||
set_trace_type(2, TRC_OFF);
|
||||
set_trace_type(3, TRC_OFF);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
t = atoi(argv[0]);
|
||||
if (t < 0 || t >= 4)
|
||||
goto usage;
|
||||
|
|
@ -919,7 +916,7 @@ static void cmd_trace(BaseSequentialStream *chp, int argc, char *argv[])
|
|||
exit:
|
||||
return;
|
||||
usage:
|
||||
chprintf(chp, "trace [n] [logmag|phase|smith|swr] [src]\r\n");
|
||||
chprintf(chp, "trace {0|1|2|3|all} [logmag|phase|smith|linear|delay|swr|off] [src]\r\n");
|
||||
}
|
||||
|
||||
static void cmd_marker(BaseSequentialStream *chp, int argc, char *argv[])
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ extern int16_t samp_buf[];
|
|||
extern int16_t refiq_buf[];
|
||||
|
||||
void dsp_process(int16_t *src, size_t len);
|
||||
void calclate_gamma(float *gamma);
|
||||
void calculate_gamma(float *gamma);
|
||||
|
||||
int si5351_set_frequency_with_offset(int freq, int offset, uint8_t drive_strength);
|
||||
|
||||
|
|
|
|||
8
plot.c
8
plot.c
|
|
@ -1066,10 +1066,10 @@ draw_cell(int m, int n)
|
|||
|
||||
#if 1
|
||||
/* draw rectanglar plot */
|
||||
if (search_index_x(x0, trace_index[0], &i0, &i1)) {
|
||||
for (t = 0; t < TRACES_MAX; t++) {
|
||||
if (!trace[t].enabled || trace[t].polar)
|
||||
continue;
|
||||
for (t = 0; t < TRACES_MAX; t++) {
|
||||
if (!trace[t].enabled || trace[t].polar)
|
||||
continue;
|
||||
if (search_index_x(x0, trace_index[t], &i0, &i1)) {
|
||||
if (i0 > 0)
|
||||
i0--;
|
||||
for (i = i0; i < i1; i++) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue