comparison spandsp-0.0.6pre17/src/spandsp/private/v27ter_rx.h @ 4:26cd8f1ef0b1

import spandsp-0.0.6pre17
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Fri, 25 Jun 2010 15:50:58 +0200
parents
children
comparison
equal deleted inserted replaced
3:c6c5a16ce2f2 4:26cd8f1ef0b1
1 /*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * private/v27ter_rx.h - ITU V.27ter modem receive part
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2003 Steve Underwood
9 *
10 * All rights reserved.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 2.1,
14 * as published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 * $Id: v27ter_rx.h,v 1.2 2009/07/09 13:52:09 steveu Exp $
26 */
27
28 #if !defined(_SPANDSP_PRIVATE_V27TER_RX_H_)
29 #define _SPANDSP_PRIVATE_V27TER_RX_H_
30
31 /* Target length for the equalizer is about 43 taps for 4800bps and 32 taps for 2400bps
32 to deal with the worst stuff in V.56bis. */
33 /*! Samples before the target position in the equalizer buffer */
34 #define V27TER_EQUALIZER_PRE_LEN 16 /* This much before the real event */
35 /*! Samples after the target position in the equalizer buffer */
36 #define V27TER_EQUALIZER_POST_LEN 14 /* This much after the real event (must be even) */
37
38 /*! The number of taps in the 4800bps pulse shaping/bandpass filter */
39 #define V27TER_RX_4800_FILTER_STEPS 27
40 /*! The number of taps in the 2400bps pulse shaping/bandpass filter */
41 #define V27TER_RX_2400_FILTER_STEPS 27
42
43 #if V27TER_RX_4800_FILTER_STEPS > V27TER_RX_2400_FILTER_STEPS
44 #define V27TER_RX_FILTER_STEPS V27TER_RX_4800_FILTER_STEPS
45 #else
46 #define V27TER_RX_FILTER_STEPS V27TER_RX_2400_FILTER_STEPS
47 #endif
48
49 /*!
50 V.27ter modem receive side descriptor. This defines the working state for a
51 single instance of a V.27ter modem receiver.
52 */
53 struct v27ter_rx_state_s
54 {
55 /*! \brief The bit rate of the modem. Valid values are 2400 and 4800. */
56 int bit_rate;
57 /*! \brief The callback function used to put each bit received. */
58 put_bit_func_t put_bit;
59 /*! \brief A user specified opaque pointer passed to the put_bit routine. */
60 void *put_bit_user_data;
61
62 /*! \brief The callback function used to report modem status changes. */
63 modem_rx_status_func_t status_handler;
64 /*! \brief A user specified opaque pointer passed to the status function. */
65 void *status_user_data;
66
67 /*! \brief A callback function which may be enabled to report every symbol's
68 constellation position. */
69 qam_report_handler_t qam_report;
70 /*! \brief A user specified opaque pointer passed to the qam_report callback
71 routine. */
72 void *qam_user_data;
73
74 /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */
75 #if defined(SPANDSP_USE_FIXED_POINT)
76 int16_t rrc_filter[V27TER_RX_FILTER_STEPS];
77 #else
78 float rrc_filter[V27TER_RX_FILTER_STEPS];
79 #endif
80 /*! \brief Current offset into the RRC pulse shaping filter buffer. */
81 int rrc_filter_step;
82
83 /*! \brief The register for the training and data scrambler. */
84 unsigned int scramble_reg;
85 /*! \brief A counter for the number of consecutive bits of repeating pattern through
86 the scrambler. */
87 int scrambler_pattern_count;
88 /*! \brief The current step in the table of BC constellation positions. */
89 int training_bc;
90 /*! \brief TRUE if the previous trained values are to be reused. */
91 int old_train;
92 /*! \brief The section of the training data we are currently in. */
93 int training_stage;
94 /*! \brief A count of how far through the current training step we are. */
95 int training_count;
96 /*! \brief A measure of how much mismatch there is between the real constellation,
97 and the decoded symbol positions. */
98 float training_error;
99 /*! \brief The value of the last signal sample, using the a simple HPF for signal power estimation. */
100 int16_t last_sample;
101 /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.27ter signal. */
102 int signal_present;
103 /*! \brief Whether or not a carrier drop was detected and the signal delivery is pending. */
104 int carrier_drop_pending;
105 /*! \brief A count of the current consecutive samples below the carrier off threshold. */
106 int low_samples;
107 /*! \brief A highest magnitude sample seen. */
108 int16_t high_sample;
109
110 /*! \brief The position of the current symbol in the constellation, used for
111 differential decoding. */
112 int constellation_state;
113
114 /*! \brief The current phase of the carrier (i.e. the DDS parameter). */
115 uint32_t carrier_phase;
116 /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */
117 int32_t carrier_phase_rate;
118 /*! \brief The carrier update rate saved for reuse when using short training. */
119 int32_t carrier_phase_rate_save;
120 #if defined(SPANDSP_USE_FIXED_POINTx)
121 /*! \brief The proportional part of the carrier tracking filter. */
122 float carrier_track_p;
123 /*! \brief The integral part of the carrier tracking filter. */
124 float carrier_track_i;
125 #else
126 /*! \brief The proportional part of the carrier tracking filter. */
127 float carrier_track_p;
128 /*! \brief The integral part of the carrier tracking filter. */
129 float carrier_track_i;
130 #endif
131
132 /*! \brief A power meter, to measure the HPF'ed signal power in the channel. */
133 power_meter_t power;
134 /*! \brief The power meter level at which carrier on is declared. */
135 int32_t carrier_on_power;
136 /*! \brief The power meter level at which carrier off is declared. */
137 int32_t carrier_off_power;
138
139 /*! \brief Current read offset into the equalizer buffer. */
140 int eq_step;
141 /*! \brief Current write offset into the equalizer buffer. */
142 int eq_put_step;
143 /*! \brief Symbol counter to the next equalizer update. */
144 int eq_skip;
145
146 /*! \brief The current half of the baud. */
147 int baud_half;
148
149 #if defined(SPANDSP_USE_FIXED_POINT)
150 /*! \brief The scaling factor accessed by the AGC algorithm. */
151 int16_t agc_scaling;
152 /*! \brief The previous value of agc_scaling, needed to reuse old training. */
153 int16_t agc_scaling_save;
154
155 /*! \brief The current delta factor for updating the equalizer coefficients. */
156 float eq_delta;
157 /*! \brief The adaptive equalizer coefficients. */
158 /*complexi16_t*/ complexf_t eq_coeff[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
159 /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
160 /*complexi16_t*/ complexf_t eq_coeff_save[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
161 /*! \brief The equalizer signal buffer. */
162 /*complexi16_t*/ complexf_t eq_buf[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
163 #else
164 /*! \brief The scaling factor accessed by the AGC algorithm. */
165 float agc_scaling;
166 /*! \brief The previous value of agc_scaling, needed to reuse old training. */
167 float agc_scaling_save;
168
169 /*! \brief The current delta factor for updating the equalizer coefficients. */
170 float eq_delta;
171 /*! \brief The adaptive equalizer coefficients. */
172 complexf_t eq_coeff[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
173 /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
174 complexf_t eq_coeff_save[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
175 /*! \brief The equalizer signal buffer. */
176 complexf_t eq_buf[V27TER_EQUALIZER_PRE_LEN + 1 + V27TER_EQUALIZER_POST_LEN];
177 #endif
178
179 /*! \brief Integration variable for damping the Gardner algorithm tests. */
180 int gardner_integrate;
181 /*! \brief Current step size of Gardner algorithm integration. */
182 int gardner_step;
183 /*! \brief The total symbol timing correction since the carrier came up.
184 This is only for performance analysis purposes. */
185 int total_baud_timing_correction;
186
187 /*! \brief Starting phase angles for the coarse carrier aquisition step. */
188 int32_t start_angles[2];
189 /*! \brief History list of phase angles for the coarse carrier aquisition step. */
190 int32_t angles[16];
191 /*! \brief Error and flow logging control */
192 logging_state_t logging;
193 };
194
195 #endif
196 /*- End of file ------------------------------------------------------------*/

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.