summaryrefslogtreecommitdiff
path: root/controller/fw/src
diff options
context:
space:
mode:
Diffstat (limited to 'controller/fw/src')
-rw-r--r--controller/fw/src/dsss_demod.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/controller/fw/src/dsss_demod.c b/controller/fw/src/dsss_demod.c
index 7a2e0cc..7feb41b 100644
--- a/controller/fw/src/dsss_demod.c
+++ b/controller/fw/src/dsss_demod.c
@@ -32,6 +32,7 @@ void dsss_demod_step(struct dsss_demod_state *st, float new_value) {
//#define DEBUG_PRINT(...) ((void)0)
//#define DEBUG_PRINTN(...) ((void)0)
bool debug = sim_pos % DSSS_CORRELATION_LENGTH == DSSS_CORRELATION_LENGTH-1;
+ //bool debug = sim_pos > 1000;
if (debug) DEBUG_PRINT("Iteration %zd", sim_pos);
//const float peak_group_threshold = 0.05 * DSSS_CORRELATION_LENGTH;
//const float hole_patching_threshold = 0.01 * DSSS_CORRELATION_LENGTH;
@@ -42,12 +43,16 @@ void dsss_demod_step(struct dsss_demod_state *st, float new_value) {
/* use new, incremented wpos for gold_correlate_step as first element of old data in ring buffer */
for (size_t i=0; i<DSSS_GOLD_CODE_COUNT; i++)
- st->correlation[i][st->correlation_wpos] = gold_correlate_step(i, st->signal, st->signal_wpos, debug);
+ st->correlation[i][st->correlation_wpos] = gold_correlate_step(i, st->signal, st->signal_wpos, false);
/* debug */
if (debug) {
+ DEBUG_PRINTN(" [");
+ for (size_t i=0; i<DSSS_GOLD_CODE_COUNT; i++)
+ DEBUG_PRINTN("%8d ", i);
+ DEBUG_PRINTN("]\n");
DEBUG_PRINTN(" correlation: [");
for (size_t i=0; i<DSSS_GOLD_CODE_COUNT; i++)
- DEBUG_PRINTN("%f, ", st->correlation[i][st->correlation_wpos]);
+ DEBUG_PRINTN("%8.5f, ", st->correlation[i][st->correlation_wpos]);
DEBUG_PRINTN("]\n");
}
/* end */
@@ -57,24 +62,20 @@ void dsss_demod_step(struct dsss_demod_state *st, float new_value) {
for (size_t i=0; i<DSSS_GOLD_CODE_COUNT; i++)
cwt[i] = cwt_convolve_step(st->correlation[i], st->correlation_wpos);
/* debug */
- /*
- if (debug) DEBUG_PRINTN(" cwt: [");
+ if (debug) DEBUG_PRINTN(" cwt: [");
for (size_t i=0; i<DSSS_GOLD_CODE_COUNT; i++)
- if (debug) DEBUG_PRINTN("%f, ", cwt[i]);
+ if (debug) DEBUG_PRINTN("%8.5f, ", cwt[i]);
if (debug) DEBUG_PRINTN("]\n");
- */
/* end */
float avg[DSSS_GOLD_CODE_COUNT];
for (size_t i=0; i<DSSS_GOLD_CODE_COUNT; i++)
avg[i] = run_iir(fabs(cwt[i]), ARRAY_LENGTH(cwt_filter_bq), cwt_filter_bq, st->cwt_filter[i].st);
/* debug */
- /*
- DEBUG_PRINTN(" avg: [");
+ if (debug) DEBUG_PRINTN(" avg: [");
for (size_t i=0; i<DSSS_GOLD_CODE_COUNT; i++)
- DEBUG_PRINTN("%f, ", avg[i]);
- DEBUG_PRINTN("]\n");
- */
+ if (debug) DEBUG_PRINTN("%8.5f, ", avg[i]);
+ if (debug) DEBUG_PRINTN("]\n");
/* end */
float max_val = st->group.max;
@@ -150,7 +151,7 @@ float cwt_convolve_step(const float v[DSSS_WAVELET_LUT_SIZE], size_t offx) {
sum += v[(offx + j) % DSSS_WAVELET_LUT_SIZE] * dsss_cwt_wavelet_table[j];
//DEBUG_PRINT(" j=%d v=%f w=%f", j, v[(offx + j) % DSSS_WAVELET_LUT_SIZE], dsss_cwt_wavelet_table[j]);
}
- return sum / DSSS_WAVELET_LUT_SIZE;
+ return sum;
}
/* Compute last element of correlation for input [a] and hard-coded gold sequences.