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 
00026 #if !defined(_SPANDSP_PRIVATE_V27TER_RX_H_)
00027 #define _SPANDSP_PRIVATE_V27TER_RX_H_
00028 
00029 /* Target length for the equalizer is about 43 taps for 4800bps and 32 taps for 2400bps
00030    to deal with the worst stuff in V.56bis. */
00031 /*! The length of the equalizer buffer. Must be a power of 2 */
00032 #define V27TER_EQUALIZER_LEN            32
00033 /*! Samples before the target central position in the equalizer buffer */
00034 #define V27TER_EQUALIZER_PRE_LEN        16
00035 
00036 /*! The number of taps in the 4800bps pulse shaping/bandpass filter */
00037 #define V27TER_RX_4800_FILTER_STEPS     27
00038 /*! The number of taps in the 2400bps pulse shaping/bandpass filter */
00039 #define V27TER_RX_2400_FILTER_STEPS     27
00040 
00041 #if V27TER_RX_4800_FILTER_STEPS > V27TER_RX_2400_FILTER_STEPS
00042 #define V27TER_RX_FILTER_STEPS V27TER_RX_4800_FILTER_STEPS
00043 #else
00044 #define V27TER_RX_FILTER_STEPS V27TER_RX_2400_FILTER_STEPS
00045 #endif
00046 
00047 /*!
00048     V.27ter modem receive side descriptor. This defines the working state for a
00049     single instance of a V.27ter modem receiver.
00050 */
00051 struct v27ter_rx_state_s
00052 {
00053     /*! \brief The bit rate of the modem. Valid values are 2400 and 4800. */
00054     int bit_rate;
00055     /*! \brief The callback function used to put each bit received. */
00056     put_bit_func_t put_bit;
00057     /*! \brief A user specified opaque pointer passed to the put_bit routine. */
00058     void *put_bit_user_data;
00059 
00060     /*! \brief The callback function used to report modem status changes. */
00061     modem_rx_status_func_t status_handler;
00062     /*! \brief A user specified opaque pointer passed to the status function. */
00063     void *status_user_data;
00064 
00065     /*! \brief A callback function which may be enabled to report every symbol's
00066                constellation position. */
00067     qam_report_handler_t qam_report;
00068     /*! \brief A user specified opaque pointer passed to the qam_report callback
00069                routine. */
00070     void *qam_user_data;
00071 
00072     /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */
00073 #if defined(SPANDSP_USE_FIXED_POINT)
00074     int16_t rrc_filter[V27TER_RX_FILTER_STEPS];
00075 #else
00076     float rrc_filter[V27TER_RX_FILTER_STEPS];
00077 #endif
00078     /*! \brief Current offset into the RRC pulse shaping filter buffer. */
00079     int rrc_filter_step;
00080 
00081     /*! \brief The register for the training and data scrambler. */
00082     unsigned int scramble_reg;
00083     /*! \brief A counter for the number of consecutive bits of repeating pattern through
00084                the scrambler. */
00085     int scrambler_pattern_count;
00086     /*! \brief The current step in the table of BC constellation positions. */
00087     int training_bc;
00088     /*! \brief TRUE if the previous trained values are to be reused. */
00089     int old_train;
00090     /*! \brief The section of the training data we are currently in. */
00091     int training_stage;
00092     /*! \brief A count of how far through the current training step we are. */
00093     int training_count;
00094     /*! \brief A measure of how much mismatch there is between the real constellation,
00095         and the decoded symbol positions. */
00096     float training_error;
00097     /*! \brief The value of the last signal sample, using the a simple HPF for signal power estimation. */
00098     int16_t last_sample;
00099     /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.27ter signal. */
00100     int signal_present;
00101     /*! \brief Whether or not a carrier drop was detected and the signal delivery is pending. */
00102     int carrier_drop_pending;
00103     /*! \brief A count of the current consecutive samples below the carrier off threshold. */
00104     int low_samples;
00105     /*! \brief A highest magnitude sample seen. */
00106     int16_t high_sample;
00107 
00108     /*! \brief The position of the current symbol in the constellation, used for
00109                differential decoding. */
00110     int constellation_state;
00111 
00112     /*! \brief The current phase of the carrier (i.e. the DDS parameter). */
00113     uint32_t carrier_phase;
00114     /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */
00115     int32_t carrier_phase_rate;
00116     /*! \brief The carrier update rate saved for reuse when using short training. */
00117     int32_t carrier_phase_rate_save;
00118 #if defined(SPANDSP_USE_FIXED_POINTx)
00119     /*! \brief The proportional part of the carrier tracking filter. */
00120     float carrier_track_p;
00121     /*! \brief The integral part of the carrier tracking filter. */
00122     float carrier_track_i;
00123 #else
00124     /*! \brief The proportional part of the carrier tracking filter. */
00125     float carrier_track_p;
00126     /*! \brief The integral part of the carrier tracking filter. */
00127     float carrier_track_i;
00128 #endif
00129 
00130     /*! \brief A power meter, to measure the HPF'ed signal power in the channel. */    
00131     power_meter_t power;
00132     /*! \brief The power meter level at which carrier on is declared. */
00133     int32_t carrier_on_power;
00134     /*! \brief The power meter level at which carrier off is declared. */
00135     int32_t carrier_off_power;
00136 
00137     /*! \brief Current read offset into the equalizer buffer. */
00138     int eq_step;
00139     /*! \brief Current write offset into the equalizer buffer. */
00140     int eq_put_step;
00141     /*! \brief Symbol counter to the next equalizer update. */
00142     int eq_skip;
00143 
00144     /*! \brief The current half of the baud. */
00145     int baud_half;
00146 
00147 #if defined(SPANDSP_USE_FIXED_POINT)
00148     /*! \brief The scaling factor accessed by the AGC algorithm. */
00149     int16_t agc_scaling;
00150     /*! \brief The previous value of agc_scaling, needed to reuse old training. */
00151     int16_t agc_scaling_save;
00152 
00153     /*! \brief The current delta factor for updating the equalizer coefficients. */
00154     float eq_delta;
00155     /*! \brief The adaptive equalizer coefficients. */
00156     /*complexi16_t*/ complexf_t  eq_coeff[V27TER_EQUALIZER_LEN];
00157     /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
00158     /*complexi16_t*/ complexf_t  eq_coeff_save[V27TER_EQUALIZER_LEN];
00159     /*! \brief The equalizer signal buffer. */
00160     /*complexi16_t*/ complexf_t eq_buf[V27TER_EQUALIZER_LEN];
00161 #else
00162     /*! \brief The scaling factor accessed by the AGC algorithm. */
00163     float agc_scaling;
00164     /*! \brief The previous value of agc_scaling, needed to reuse old training. */
00165     float agc_scaling_save;
00166 
00167     /*! \brief The current delta factor for updating the equalizer coefficients. */
00168     float eq_delta;
00169     /*! \brief The adaptive equalizer coefficients. */
00170     complexf_t eq_coeff[V27TER_EQUALIZER_LEN];
00171     /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
00172     complexf_t eq_coeff_save[V27TER_EQUALIZER_LEN];
00173     /*! \brief The equalizer signal buffer. */
00174     complexf_t eq_buf[V27TER_EQUALIZER_LEN];
00175 #endif
00176 
00177     /*! \brief Integration variable for damping the Gardner algorithm tests. */
00178     int gardner_integrate;
00179     /*! \brief Current step size of Gardner algorithm integration. */
00180     int gardner_step;
00181     /*! \brief The total symbol timing correction since the carrier came up.
00182                This is only for performance analysis purposes. */
00183     int total_baud_timing_correction;
00184 
00185     /*! \brief Starting phase angles for the coarse carrier aquisition step. */
00186     int32_t start_angles[2];
00187     /*! \brief History list of phase angles for the coarse carrier aquisition step. */
00188     int32_t angles[16];
00189     /*! \brief Error and flow logging control */
00190     logging_state_t logging;
00191 };
00192 
00193 #endif
00194 /*- End of file ------------------------------------------------------------*/

Generated on 25 Jan 2012 for spandsp by  doxygen 1.6.1