diff options
author | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-03-11 13:57:22 +0100 |
---|---|---|
committer | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-03-11 13:57:22 +0100 |
commit | 0af1a534e2930da77ebbab6481adcd17069581ef (patch) | |
tree | 6b8c1399fbf69d75c296f2b5060549e63553fa75 /controller/fw/src/dsss_demod.c | |
parent | 0cd07d397fb5a5e7710af66cb1e9e0b61705c94a (diff) | |
download | master-thesis-0af1a534e2930da77ebbab6481adcd17069581ef.tar.gz master-thesis-0af1a534e2930da77ebbab6481adcd17069581ef.tar.bz2 master-thesis-0af1a534e2930da77ebbab6481adcd17069581ef.zip |
Start with integration of everything
Diffstat (limited to 'controller/fw/src/dsss_demod.c')
-rw-r--r-- | controller/fw/src/dsss_demod.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/controller/fw/src/dsss_demod.c b/controller/fw/src/dsss_demod.c index c5a2070..0758525 100644 --- a/controller/fw/src/dsss_demod.c +++ b/controller/fw/src/dsss_demod.c @@ -23,12 +23,15 @@ struct iir_biquad cwt_filter_bq[DSSS_FILTER_CLEN] = {DSSS_FILTER_COEFF}; void debug_print_vector(const char *name, size_t len, const float *data, size_t stride, bool index, bool debug); static float gold_correlate_step(const size_t ncode, const float a[DSSS_CORRELATION_LENGTH], size_t offx, bool debug); static float cwt_convolve_step(const float v[DSSS_WAVELET_LUT_SIZE], size_t offx); +#if 0 static float run_iir(const float x, const int order, const struct iir_biquad q[order], struct iir_biquad_state st[order]); static float run_biquad(float x, const struct iir_biquad *const q, struct iir_biquad_state *const restrict st); +#endif static void matcher_init(struct matcher_state states[static DSSS_MATCHER_CACHE_SIZE]); static void matcher_tick(struct matcher_state states[static DSSS_MATCHER_CACHE_SIZE], uint64_t ts, int peak_ch, float peak_ampl); static void group_received(struct dsss_demod_state *st); +static uint8_t decode_peak(int peak_ch, float peak_ampl); #ifdef SIMULATION void debug_print_vector(const char *name, size_t len, const float *data, size_t stride, bool index, bool debug) { @@ -48,7 +51,8 @@ void debug_print_vector(const char *name, size_t len, const float *data, size_t DEBUG_PRINTN("]\n"); } #else -void debug_print_vector(const char *name, size_t len, const float *data, size_t stride, bool index, bool debug) {} +void debug_print_vector(unused_a const char *name, unused_a size_t len, unused_a const float *data, + unused_a size_t stride, unused_a bool index, unused_a bool debug) {} #endif void dsss_demod_init(struct dsss_demod_state *st) { @@ -74,7 +78,7 @@ void dsss_demod_step(struct dsss_demod_state *st, float new_value, uint64_t ts) float avg = 0.0f; for (size_t i=0; i<DSSS_GOLD_CODE_COUNT; i++) - avg += fabs(cwt[i]); + avg += fabsf(cwt[i]); avg /= (float)DSSS_GOLD_CODE_COUNT; /* FIXME fix this filter */ //avg = run_iir(avg, ARRAY_LENGTH(cwt_filter_bq), cwt_filter_bq, st->cwt_filter.st); @@ -86,12 +90,12 @@ void dsss_demod_step(struct dsss_demod_state *st, float new_value, uint64_t ts) for (size_t i=0; i<DSSS_GOLD_CODE_COUNT; i++) { float val = cwt[i] / avg; - if (fabs(val) > fabs(max_val)) { + if (fabsf(val) > fabsf(max_val)) { max_val = val; max_ch = i; max_ts = ts; - if (fabs(val) > DSSS_THESHOLD_FACTOR) + if (fabsf(val) > DSSS_THESHOLD_FACTOR) found = true; } } @@ -155,7 +159,7 @@ void matcher_tick(struct matcher_state states[static DSSS_MATCHER_CACHE_SIZE], u if (current_phase == states[i].last_phase) { /* Skip sampling */ - float score = fabs(peak_ampl) * (1.0f - skip_sampling_depreciation); + float score = fabsf(peak_ampl) * (1.0f - skip_sampling_depreciation); if (score > states[i].candidate_score) { /* We win, update candidate */ assert(i < DSSS_MATCHER_CACHE_SIZE); @@ -272,6 +276,7 @@ void group_received(struct dsss_demod_state *st) { } } +#if 0 float run_iir(const float x, const int order, const struct iir_biquad q[order], struct iir_biquad_state st[order]) { float intermediate = x; for (int i=0; i<(order+1)/2; i++) @@ -287,6 +292,7 @@ float run_biquad(float x, const struct iir_biquad *const q, struct iir_biquad_st st->reg[0] = intermediate; return out; } +#endif float cwt_convolve_step(const float v[DSSS_WAVELET_LUT_SIZE], size_t offx) { float sum = 0.0f; |