mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
feat: add sample command to evalutate dynamic range
This commit is contained in:
parent
dc60e11698
commit
e626c581ee
14
dsp.c
14
dsp.c
|
|
@ -95,6 +95,20 @@ calculate_gamma(float gamma[2])
|
||||||
gamma[1] = (ss * rc - sc * rs) / rr;
|
gamma[1] = (ss * rc - sc * rs) / rr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fetch_amplitude(float gamma[2])
|
||||||
|
{
|
||||||
|
gamma[0] = acc_samp_s * 1e-9;
|
||||||
|
gamma[1] = acc_samp_c * 1e-9;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fetch_amplitude_ref(float gamma[2])
|
||||||
|
{
|
||||||
|
gamma[0] = acc_ref_s * 1e-9;
|
||||||
|
gamma[1] = acc_ref_c * 1e-9;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
reset_dsp_accumerator(void)
|
reset_dsp_accumerator(void)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
25
main.c
25
main.c
|
|
@ -378,6 +378,26 @@ static void cmd_gamma(BaseSequentialStream *chp, int argc, char *argv[])
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void (*sample_func)(float *gamma) = calculate_gamma;
|
||||||
|
|
||||||
|
static void cmd_sample(BaseSequentialStream *chp, int argc, char *argv[])
|
||||||
|
{
|
||||||
|
if (argc == 1) {
|
||||||
|
if (strcmp(argv[0], "ref") == 0) {
|
||||||
|
sample_func = fetch_amplitude_ref;
|
||||||
|
return;
|
||||||
|
} else if (strcmp(argv[0], "ampl") == 0) {
|
||||||
|
sample_func = fetch_amplitude;
|
||||||
|
return;
|
||||||
|
} else if (strcmp(argv[0], "gamma") == 0) {
|
||||||
|
sample_func = calculate_gamma;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chprintf(chp, "usage: sample {gamma|ampl|ref}\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
int32_t frequency0 = 1000000;
|
int32_t frequency0 = 1000000;
|
||||||
int32_t frequency1 = 300000000;
|
int32_t frequency1 = 300000000;
|
||||||
|
|
@ -485,13 +505,13 @@ void sweep(void)
|
||||||
palClearPad(GPIOC, GPIOC_LED);
|
palClearPad(GPIOC, GPIOC_LED);
|
||||||
|
|
||||||
/* calculate reflection coeficient */
|
/* calculate reflection coeficient */
|
||||||
calculate_gamma(measured[0][i]);
|
(*sample_func)(measured[0][i]);
|
||||||
|
|
||||||
tlv320aic3204_select_in1(); // CH1:TRANSMISSION
|
tlv320aic3204_select_in1(); // CH1:TRANSMISSION
|
||||||
wait_dsp(delay);
|
wait_dsp(delay);
|
||||||
|
|
||||||
/* calculate transmission coeficient */
|
/* calculate transmission coeficient */
|
||||||
calculate_gamma(measured[1][i]);
|
(*sample_func)(measured[1][i]);
|
||||||
|
|
||||||
// blink LED while scanning
|
// blink LED while scanning
|
||||||
palSetPad(GPIOC, GPIOC_LED);
|
palSetPad(GPIOC, GPIOC_LED);
|
||||||
|
|
@ -1653,6 +1673,7 @@ static const ShellCommand commands[] =
|
||||||
{ "stat", cmd_stat },
|
{ "stat", cmd_stat },
|
||||||
{ "gain", cmd_gain },
|
{ "gain", cmd_gain },
|
||||||
{ "power", cmd_power },
|
{ "power", cmd_power },
|
||||||
|
{ "sample", cmd_sample },
|
||||||
//{ "gamma", cmd_gamma },
|
//{ "gamma", cmd_gamma },
|
||||||
//{ "scan", cmd_scan },
|
//{ "scan", cmd_scan },
|
||||||
{ "sweep", cmd_sweep },
|
{ "sweep", cmd_sweep },
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,8 @@ extern int16_t samp_buf[];
|
||||||
void dsp_process(int16_t *src, size_t len);
|
void dsp_process(int16_t *src, size_t len);
|
||||||
void reset_dsp_accumerator(void);
|
void reset_dsp_accumerator(void);
|
||||||
void calculate_gamma(float *gamma);
|
void calculate_gamma(float *gamma);
|
||||||
|
void fetch_amplitude(float *gamma);
|
||||||
|
void fetch_amplitude_ref(float *gamma);
|
||||||
|
|
||||||
int si5351_set_frequency_with_offset(int freq, int offset, uint8_t drive_strength);
|
int si5351_set_frequency_with_offset(int freq, int offset, uint8_t drive_strength);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue