private/v27ter_rx.h

00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * private/v27ter_rx.h - ITU V.27ter modem receive part
00005  *
00006  * Written by Steve Underwood <steveu@coppice.org>
00007  *
00008  * Copyright (C) 2003 Steve Underwood
00009  *
00010  * All rights reserved.
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU Lesser General Public License version 2.1,
00014  * as published by the Free Software Foundation.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public
00022  * License along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024  *
00025  * $Id: v27ter_rx.h,v 1.1 2008/10/13 13:14:01 steveu Exp $
00026  */
00027 
00028 #if !defined(_SPANDSP_PRIVATE_V27TER_RX_H_)
00029 #define _SPANDSP_PRIVATE_V27TER_RX_H_
00030 
00031 /*!
00032     V.27ter modem receive side descriptor. This defines the working state for a
00033     single instance of a V.27ter modem receiver.
00034 */
00035 struct v27ter_rx_state_s
00036 {
00037     /*! \brief The bit rate of the modem. Valid values are 2400 and 4800. */
00038     int bit_rate;
00039     /*! \brief The callback function used to put each bit received. */
00040     put_bit_func_t put_bit;
00041     /*! \brief A user specified opaque pointer passed to the put_bit routine. */
00042     void *put_bit_user_data;
00043 
00044     /*! \brief The callback function used to report modem status changes. */
00045     modem_rx_status_func_t status_handler;
00046     /*! \brief A user specified opaque pointer passed to the status function. */
00047     void *status_user_data;
00048 
00049     /*! \brief A callback function which may be enabled to report every symbol's
00050                constellation position. */
00051     qam_report_handler_t qam_report;
00052     /*! \brief A user specified opaque pointer passed to the qam_report callback
00053                routine. */
00054     void *qam_user_data;
00055 
00056     /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */
00057 #if defined(SPANDSP_USE_FIXED_POINT)
00058     int16_t rrc_filter[V27TER_RX_FILTER_STEPS];
00059 #else
00060     float rrc_filter[V27TER_RX_FILTER_STEPS];
00061 #endif
00062     /*! \brief Current offset into the RRC pulse shaping filter buffer. */
00063     int rrc_filter_step;
00064 
00065     /*! \brief The register for the training and data scrambler. */
00066     unsigned int scramble_reg;
00067     /*! \brief A counter for the number of consecutive bits of repeating pattern through
00068                the scrambler. */
00069     int scrambler_pattern_count;
00070     /*! \brief The current step in the table of BC constellation positions. */
00071     int training_bc;
00072     /*! \brief TRUE if the previous trained values are to be reused. */
00073     int old_train;
00074     /*! \brief The section of the training data we are currently in. */
00075     int training_stage;
00076     /*! \brief A count of how far through the current training step we are. */
00077     int training_count;
00078     /*! \brief A measure of how much mismatch there is between the real constellation,
00079         and the decoded symbol positions. */
00080     float training_error;
00081     /*! \brief The value of the last signal sample, using the a simple HPF for signal power estimation. */
00082     int16_t last_sample;
00083     /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.27ter signal. */
00084     int signal_present;
00085     /*! \brief Whether or not a carrier drop was detected and the signal delivery is pending. */
00086     int carrier_drop_pending;
00087     /*! \brief A count of the current consecutive samples below the carrier off threshold. */
00088     int low_samples;
00089     /*! \brief A highest magnitude sample seen. */
00090     int16_t high_sample;
00091 
00092     /*! \brief The position of the current symbol in the constellation, used for
00093                differential decoding. */
00094     int constellation_state;
00095 
00096     /*! \brief The current phase of the carrier (i.e. the DDS parameter). */
00097     uint32_t carrier_phase;
00098     /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */
00099     int32_t carrier_phase_rate;
00100     /*! \brief The carrier update rate saved for reuse when using short training. */
00101     int32_t carrier_phase_rate_save;
00102 #if defined(SPANDSP_USE_FIXED_POINTx)
00103     /*! \brief The proportional part of the carrier tracking filter. */
00104     float carrier_track_p;
00105     /*! \brief The integral part of the carrier tracking filter. */
00106     float carrier_track_i;
00107 #else
00108     /*! \brief The proportional part of the carrier tracking filter. */
00109     float carrier_track_p;
00110     /*! \brief The integral part of the carrier tracking filter. */
00111     float carrier_track_i;
00112 #endif
00113 
00114     /*! \brief A power meter, to measure the HPF'ed signal power in the channel. */    
00115     power_meter_t power;
00116     /*! \brief The power meter level at which carrier on is declared. */
00117     int32_t carrier_on_power;
00118     /*! \brief The power meter level at which carrier off is declared. */
00119     int32_t carrier_off_power;
00120 
00121     /*! \brief Current read offset into the equalizer buffer. */
00122     int eq_step;
00123     /*! \brief Current write offset into the equalizer buffer. */
00124     int eq_put_step;
00125     /*! \brief Symbol counter to the next equalizer update. */
00126     int eq_skip;
00127 
00128     /*! \brief The current half of the baud. */
00129     int baud_half;
00130 
00131 #if defined(SPANDSP_USE_FIXED_POINT)
00132     /*! \brief The scaling factor accessed by the AGC algorithm. */
00133     int16_t agc_scaling;
00134     /*! \brief The previous value of agc_scaling, needed to reuse old training. */
00135     int16_t agc_scaling_save;
00136 
00137     /*! \brief The current delta factor for updating the equalizer coefficients. */
00138     float eq_delta;
00139     /*! \brief The adaptive equalizer coefficients. */
00140     /*complexi16_t*/ complexf_t  eq_coeff[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
00141     /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
00142     /*complexi16_t*/ complexf_t  eq_coeff_save[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
00143     /*! \brief The equalizer signal buffer. */
00144     /*complexi16_t*/ complexf_t eq_buf[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
00145 #else
00146     /*! \brief The scaling factor accessed by the AGC algorithm. */
00147     float agc_scaling;
00148     /*! \brief The previous value of agc_scaling, needed to reuse old training. */
00149     float agc_scaling_save;
00150 
00151     /*! \brief The current delta factor for updating the equalizer coefficients. */
00152     float eq_delta;
00153     /*! \brief The adaptive equalizer coefficients. */
00154     complexf_t eq_coeff[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
00155     /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
00156     complexf_t eq_coeff_save[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
00157     /*! \brief The equalizer signal buffer. */
00158     complexf_t eq_buf[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
00159 #endif
00160 
00161     /*! \brief Integration variable for damping the Gardner algorithm tests. */
00162     int gardner_integrate;
00163     /*! \brief Current step size of Gardner algorithm integration. */
00164     int gardner_step;
00165     /*! \brief The total symbol timing correction since the carrier came up.
00166                This is only for performance analysis purposes. */
00167     int total_baud_timing_correction;
00168 
00169     /*! \brief Starting phase angles for the coarse carrier aquisition step. */
00170     int32_t start_angles[2];
00171     /*! \brief History list of phase angles for the coarse carrier aquisition step. */
00172     int32_t angles[16];
00173     /*! \brief Error and flow logging control */
00174     logging_state_t logging;
00175 };
00176 
00177 #endif
00178 /*- End of file ------------------------------------------------------------*/

Generated on Tue Aug 4 03:36:15 2009 for spandsp by  doxygen 1.5.9