diff options
Diffstat (limited to 'controller/fw/src/dsss_demod.h')
-rw-r--r-- | controller/fw/src/dsss_demod.h | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/controller/fw/src/dsss_demod.h b/controller/fw/src/dsss_demod.h index 30ec3f7..b9e75d2 100644 --- a/controller/fw/src/dsss_demod.h +++ b/controller/fw/src/dsss_demod.h @@ -5,6 +5,9 @@ #define DSSS_GOLD_CODE_COUNT ((1<<DSSS_GOLD_CODE_NBITS) + 1) #define DSSS_CORRELATION_LENGTH (DSSS_GOLD_CODE_LENGTH * DSSS_DECIMATION) +/* FIXME: move to makefile */ +#define DSSS_MATCHER_CACHE_SIZE 8 +/* FIXME: move to more appropriate header */ #define PAYLOAD_DATA_BYTE ((PAYLOAD_DATA_BIT+7)/8) struct iir_biquad { @@ -20,22 +23,26 @@ struct cwt_iir_filter_state { struct iir_biquad_state st[3]; }; -struct { +struct group { int len; /* length of group in samples */ float max; /* signed value of largest peak in group on any channel */ uint64_t max_ts; /* absolute position of above peak */ int max_ch; /* channel (gold sequence index) of above peak */ -} group; +}; -struct decoder_state { - int last_phase; +struct matcher_state { + int last_phase; /* 0 .. DSSS_CORRELATION_LENGTH */ int candidate_phase; float last_score; float candidate_score; - uint8_t data[PAYLOAD_DATA_BYTE]; +#if DSSS_GOLD_CODE_NBITS > 7 +#error DSSS_GOLD_CODE_NBITS is too large for matcher_state.data data type (uint8_t) +#endif + uint8_t data[TRANSMISSION_SYMBOLS]; int data_pos; + uint8_t candidate_data; }; struct dsss_demod_state { @@ -49,9 +56,13 @@ struct dsss_demod_state { struct group group; - struct group group_cache[DSSS_GROUP_CACHE_SIZE]; + struct matcher_state matcher_cache[DSSS_MATCHER_CACHE_SIZE]; }; + +extern void handle_dsss_received(uint8_t data[TRANSMISSION_SYMBOLS]); + +void dsss_demod_init(struct dsss_demod_state *st); #ifdef SIMULATION void dsss_demod_step(struct dsss_demod_state *st, float new_value, uint64_t ts, int record_channel); #else /* SIMULATION */ |