From 42c70840d8f753ef7f7fb385b5b606ca73fd1180 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 5 Jun 2007 01:31:25 +0000 Subject: [PATCH] update git-svn-id: http://svn.openzap.org/svn/openzap/trunk@210 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/openzap/src/dsp/fsk.c | 34 +++++++++++++++++++++++++++++++++- libs/openzap/src/dsp/fsk.h | 11 ++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/libs/openzap/src/dsp/fsk.c b/libs/openzap/src/dsp/fsk.c index 8f4dfcad05..a53fa81e7b 100644 --- a/libs/openzap/src/dsp/fsk.c +++ b/libs/openzap/src/dsp/fsk.c @@ -306,7 +306,39 @@ dsp_fsk_sample (dsp_fsk_handle_t *handle, double normalized_sample) if (handle->cellpos > 1.0) { handle->cellpos -= 1.0; - (*handle->attr.bithandler) (handle->attr.bithandler_arg, handle->current_bit); + + + switch (handle->state) { + case FSK_STATE_DATA: + (*handle->attr.bithandler) (handle->attr.bithandler_arg, handle->current_bit); + break; + case FSK_STATE_CHANSEIZE: + if (handle->last_bit != handle->current_bit) { + + + handle->conscutive_state_bits++; + } else { + handle->conscutive_state_bits = 0; + } + if (handle->conscutive_state_bits > 15) { + handle->state = FSK_STATE_CARRIERSIG; + handle->conscutive_state_bits = 0; + } + break; + case FSK_STATE_CARRIERSIG: + if (handle->current_bit) { + handle->conscutive_state_bits++; + } else { + handle->conscutive_state_bits = 0; + } + if (handle->conscutive_state_bits > 15) { + handle->state = FSK_STATE_DATA; + handle->conscutive_state_bits = 0; + } + break; + } + + handle->last_bit = handle->current_bit; } } diff --git a/libs/openzap/src/dsp/fsk.h b/libs/openzap/src/dsp/fsk.h index e9cf0c0c1c..b494593ebf 100644 --- a/libs/openzap/src/dsp/fsk.h +++ b/libs/openzap/src/dsp/fsk.h @@ -35,6 +35,12 @@ #define __FSK_H__ #include "uart.h" +typedef enum { + FSK_STATE_CHANSEIZE = 0, + FSK_STATE_CARRIERSIG, + FSK_STATE_DATA +} fsk_state_t; + typedef struct dsp_fsk_attr_s { int sample_rate; /* sample rate in HZ */ @@ -46,7 +52,8 @@ typedef struct dsp_fsk_attr_s typedef struct { - dsp_fsk_attr_t attr; /* attributes structure */ + fsk_state_t state; + dsp_fsk_attr_t attr; /* attributes structure */ double *correlates[4]; /* one for each of sin/cos for mark/space */ int corrsize; /* correlate size (also number of samples in ring buffer) */ double *buffer; /* sample ring buffer */ @@ -55,8 +62,10 @@ typedef struct double celladj; /* bit cell adjustment for each sample */ int previous_bit; /* previous bit (for detecting a transition to sync-up cell position) */ int current_bit; /* current bit */ + int last_bit; int downsampling_count; /* number of samples to skip */ int current_downsample; /* current skip count */ + int conscutive_state_bits; /* number of bits in a row that matches the pattern for the current state */ } dsp_fsk_handle_t; /*