mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
feat: if 12kHz to reduce flash usage
This commit is contained in:
parent
5a10105b1a
commit
3e5974d0d4
74
dsp.c
74
dsp.c
|
|
@ -26,21 +26,6 @@ int16_t samp_buf[SAMPLE_LEN];
|
||||||
int16_t ref_buf[SAMPLE_LEN];
|
int16_t ref_buf[SAMPLE_LEN];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const int16_t sincos_tbl[48][2] = {
|
|
||||||
{ 10533, 31029 }, { 27246, 18205 }, { 32698, -2143 }, { 24636, -21605 },
|
|
||||||
{ 6393, -32138 }, {-14493, -29389 }, {-29389, -14493 }, {-32138, 6393 },
|
|
||||||
{-21605, 24636 }, { -2143, 32698 }, { 18205, 27246 }, { 31029, 10533 },
|
|
||||||
{ 31029, -10533 }, { 18205, -27246 }, { -2143, -32698 }, {-21605, -24636 },
|
|
||||||
{-32138, -6393 }, {-29389, 14493 }, {-14493, 29389 }, { 6393, 32138 },
|
|
||||||
{ 24636, 21605 }, { 32698, 2143 }, { 27246, -18205 }, { 10533, -31029 },
|
|
||||||
{-10533, -31029 }, {-27246, -18205 }, {-32698, 2143 }, {-24636, 21605 },
|
|
||||||
{ -6393, 32138 }, { 14493, 29389 }, { 29389, 14493 }, { 32138, -6393 },
|
|
||||||
{ 21605, -24636 }, { 2143, -32698 }, {-18205, -27246 }, {-31029, -10533 },
|
|
||||||
{-31029, 10533 }, {-18205, 27246 }, { 2143, 32698 }, { 21605, 24636 },
|
|
||||||
{ 32138, 6393 }, { 29389, -14493 }, { 14493, -29389 }, { -6393, -32138 },
|
|
||||||
{-24636, -21605 }, {-32698, -2143 }, {-27246, 18205 }, {-10533, 31029 }
|
|
||||||
};
|
|
||||||
|
|
||||||
float acc_samp_s;
|
float acc_samp_s;
|
||||||
float acc_samp_c;
|
float acc_samp_c;
|
||||||
float acc_ref_s;
|
float acc_ref_s;
|
||||||
|
|
@ -57,27 +42,54 @@ dsp_process(int16_t *capture, size_t length)
|
||||||
int32_t ref_s = 0;
|
int32_t ref_s = 0;
|
||||||
int32_t ref_c = 0;
|
int32_t ref_c = 0;
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
// quadrature steps for if=12kHz on fs=48kHz
|
||||||
uint32_t sr = *p++;
|
for (i = 0; i < len;) {
|
||||||
int16_t ref = sr & 0xffff;
|
uint32_t sr;
|
||||||
int16_t smp = (sr>>16) & 0xffff;
|
int16_t ref, smp;
|
||||||
|
|
||||||
|
sr = *p++;
|
||||||
|
ref = sr & 0xffff;
|
||||||
|
smp = (sr>>16) & 0xffff;
|
||||||
#ifdef ENABLED_DUMP
|
#ifdef ENABLED_DUMP
|
||||||
ref_buf[i] = ref;
|
ref_buf[i] = ref;
|
||||||
samp_buf[i] = smp;
|
samp_buf[i] = smp;
|
||||||
#endif
|
#endif
|
||||||
int32_t s = sincos_tbl[i][0];
|
i++;
|
||||||
int32_t c = sincos_tbl[i][1];
|
samp_s += smp;
|
||||||
samp_s += smp * s / 16;
|
ref_s += ref;
|
||||||
samp_c += smp * c / 16;
|
|
||||||
ref_s += ref * s / 16;
|
sr = *p++;
|
||||||
ref_c += ref * c / 16;
|
ref = sr & 0xffff;
|
||||||
#if 0
|
smp = (sr>>16) & 0xffff;
|
||||||
uint32_t sc = *(uint32_t)&sincos_tbl[i];
|
#ifdef ENABLED_DUMP
|
||||||
samp_s = __SMLABB(sr, sc, samp_s);
|
ref_buf[i] = ref;
|
||||||
samp_c = __SMLABT(sr, sc, samp_c);
|
samp_buf[i] = smp;
|
||||||
ref_s = __SMLATB(sr, sc, ref_s);
|
|
||||||
ref_c = __SMLATT(sr, sc, ref_c);
|
|
||||||
#endif
|
#endif
|
||||||
|
i++;
|
||||||
|
samp_c += smp;
|
||||||
|
ref_c += ref;
|
||||||
|
|
||||||
|
sr = *p++;
|
||||||
|
ref = sr & 0xffff;
|
||||||
|
smp = (sr>>16) & 0xffff;
|
||||||
|
#ifdef ENABLED_DUMP
|
||||||
|
ref_buf[i] = ref;
|
||||||
|
samp_buf[i] = smp;
|
||||||
|
#endif
|
||||||
|
i++;
|
||||||
|
samp_s -= smp;
|
||||||
|
ref_s -= ref;
|
||||||
|
|
||||||
|
sr = *p++;
|
||||||
|
ref = sr & 0xffff;
|
||||||
|
smp = (sr>>16) & 0xffff;
|
||||||
|
#ifdef ENABLED_DUMP
|
||||||
|
ref_buf[i] = ref;
|
||||||
|
samp_buf[i] = smp;
|
||||||
|
#endif
|
||||||
|
i++;
|
||||||
|
samp_c -= smp;
|
||||||
|
ref_c -= ref;
|
||||||
}
|
}
|
||||||
acc_samp_s += samp_s;
|
acc_samp_s += samp_s;
|
||||||
acc_samp_c += samp_c;
|
acc_samp_c += samp_c;
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
// Maximum frequency set
|
// Maximum frequency set
|
||||||
#define STOP_MAX 2700000000U
|
#define STOP_MAX 2700000000U
|
||||||
// Frequency offset (sin_cos table in dsp.c generated for this offset, if change need create new table)
|
// Frequency offset (sin_cos table in dsp.c generated for this offset, if change need create new table)
|
||||||
#define FREQUENCY_OFFSET 5000
|
#define FREQUENCY_OFFSET 12000
|
||||||
// Speed of light const
|
// Speed of light const
|
||||||
#define SPEED_OF_LIGHT 299792458
|
#define SPEED_OF_LIGHT 299792458
|
||||||
// pi const
|
// pi const
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue