📄 v17rx.h
字号:
/* We can store more trellis depth that we look back over, so that we can push out a group of symbols in one go, giving greater processing efficiency, at the expense of a bit more latency through the modem. *//* Right now we don't take advantage of this optimisation. */#define V17_TRELLIS_STORAGE_DEPTH 16#define V17_TRELLIS_LOOKBACK_DEPTH 16/*! V.17 modem receive side descriptor. This defines the working state for a single instance of a V.17 modem receiver.*/typedef struct{ /*! \brief The bit rate of the modem. Valid values are 7200 9600, 12000 and 14400. */ int bit_rate; /*! \brief The callback function used to put each bit received. */ put_bit_func_t put_bit; /*! \brief A user specified opaque pointer passed to the put_but routine. */ void *user_data; /*! \brief A callback function which may be enabled to report every symbol's constellation position. */ qam_report_handler_t *qam_report; /*! \brief A user specified opaque pointer passed to the qam_report callback routine. */ void *qam_user_data; /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */#if defined(USE_FIXED_POINTx) int32_t rrc_filter[2*V17_RX_FILTER_STEPS];#else float rrc_filter[2*V17_RX_FILTER_STEPS];#endif /*! \brief Current offset into the RRC pulse shaping filter buffer. */ int rrc_filter_step; /*! \brief The state of the differential decoder */ int diff; /*! \brief The register for the data scrambler. */ unsigned int scramble_reg; /*! \brief TRUE if the short training sequence is to be used. */ int short_train; /*! \brief The section of the training data we are currently in. */ int training_stage; int training_count; float training_error; /*! \brief The value of the last signal sample, using the a simple HPF for signal power estimation. */ int16_t last_sample; /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.17 signal. */ int signal_present; /*! \brief The current phase of the carrier (i.e. the DDS parameter). */ uint32_t carrier_phase; /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */ int32_t carrier_phase_rate; /*! \brief The carrier update rate saved for reuse when using short training. */ int32_t carrier_phase_rate_save; float carrier_track_p; float carrier_track_i; /*! \brief The received signal power monitor. */ power_meter_t power; int32_t carrier_on_power; int32_t carrier_off_power; float agc_scaling; float agc_scaling_save; float eq_delta; /*! \brief The adaptive equalizer coefficients */#if defined(USE_FIXED_POINTx) complexi_t eq_coeff[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN]; complexi_t eq_coeff_save[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN]; complexi_t eq_buf[V17_EQUALIZER_MASK + 1];#else complexf_t eq_coeff[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN]; complexf_t eq_coeff_save[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN]; complexf_t eq_buf[V17_EQUALIZER_MASK + 1];#endif /*! \brief Current offset into equalizer buffer. */ int eq_step; int eq_put_step; /*! \brief The current half of the baud. */ int baud_half; /*! \brief Band edge symbol sync. filter state. */#if defined(USE_FIXED_POINTx) int32_t symbol_sync_low[2]; int32_t symbol_sync_high[2]; int32_t symbol_sync_dc_filter[2]; int32_t baud_phase;#else float symbol_sync_low[2]; float symbol_sync_high[2]; float symbol_sync_dc_filter[2]; float baud_phase;#endif /*! \brief The total symbol timing correction since the carrier came up. This is only for performance analysis purposes. */ int total_baud_timing_correction; /*! \brief Starting phase angles for the coarse carrier aquisition step. */ int32_t start_angles[2]; /*! \brief History list of phase angles for the coarse carrier aquisition step. */ int32_t angles[16]; /*! \brief A pointer to the current constellation. */#if defined(USE_FIXED_POINTx) const complexi_t *constellation;#else const complexf_t *constellation;#endif /*! \brief A pointer to the current space map. There is a space map for each trellis state. */ int space_map; /*! \brief The number of bits in each symbol at the current bit rate. */ int bits_per_symbol; /*! \brief Current pointer to the trellis buffers */ int trellis_ptr; /*! \brief The trellis. */ int full_path_to_past_state_locations[V17_TRELLIS_STORAGE_DEPTH][8]; /*! \brief The trellis. */ int past_state_locations[V17_TRELLIS_STORAGE_DEPTH][8]; /*! \brief Euclidean distances (actually the sqaures of the distances) from the last states of the trellis. */#if defined(USE_FIXED_POINTx) int32_t distances[8];#else float distances[8];#endif /*! \brief Error and flow logging control */ logging_state_t logging;} v17_rx_state_t;#ifdef __cplusplusextern "C"{#endif/*! Initialise a V.17 modem receive context. \brief Initialise a V.17 modem receive context. \param s The modem context. \param rate The bit rate of the modem. Valid values are 7200, 9600, 12000 and 14400. \param put_bit The callback routine used to put the received data. \param user_data An opaque pointer passed to the put_bit routine. \return A pointer to the modem context, or NULL if there was a problem. */v17_rx_state_t *v17_rx_init(v17_rx_state_t *s, int rate, put_bit_func_t put_bit, void *user_data);/*! Reinitialise an existing V.17 modem receive context. \brief Reinitialise an existing V.17 modem receive context. \param s The modem context. \param rate The bit rate of the modem. Valid values are 7200, 9600, 12000 and 14400. \param short_train TRUE if a short training sequence is expected. \return 0 for OK, -1 for bad parameter */int v17_rx_restart(v17_rx_state_t *s, int rate, int short_train);/*! Release a V.17 modem receive context. \brief Release a V.17 modem receive context. \param s The modem context. \return 0 for OK */int v17_rx_release(v17_rx_state_t *s);/*! Change the put_bit function associated with a V.17 modem receive context. \brief Change the put_bit function associated with a V.17 modem receive context. \param s The modem context. \param put_bit The callback routine used to handle received bits. \param user_data An opaque pointer. */void v17_rx_set_put_bit(v17_rx_state_t *s, put_bit_func_t put_bit, void *user_data);/*! Process a block of received V.17 modem audio samples. \brief Process a block of received V.17 modem audio samples. \param s The modem context. \param amp The audio sample buffer. \param len The number of samples in the buffer.*/void v17_rx(v17_rx_state_t *s, const int16_t amp[], int len);/*! Get a snapshot of the current equalizer coefficients. \brief Get a snapshot of the current equalizer coefficients. \param s The modem context. \param coeffs The vector of complex coefficients. \return The number of coefficients in the vector. */#if defined(USE_FIXED_POINTx)int v17_rx_equalizer_state(v17_rx_state_t *s, complexi_t **coeffs);#elseint v17_rx_equalizer_state(v17_rx_state_t *s, complexf_t **coeffs);#endif/*! Get the current received carrier frequency. \param s The modem context. \return The frequency, in Hertz. */float v17_rx_carrier_frequency(v17_rx_state_t *s);/*! Get the current symbol timing correction since startup. \param s The modem context. \return The correction. */float v17_rx_symbol_timing_correction(v17_rx_state_t *s);/*! Get a current received signal power. \param s The modem context. \return The signal power, in dBm0. */float v17_rx_signal_power(v17_rx_state_t *s);/*! Set the power level at which the carrier detection will cut in \param s The modem context. \param cutoff The signal cutoff power, in dBm0. */void v17_rx_signal_cutoff(v17_rx_state_t *s, float cutoff);/*! Set a handler routine to process QAM status reports \param s The modem context. \param handler The handler routine. \param user_data An opaque pointer passed to the handler routine. */void v17_rx_set_qam_report_handler(v17_rx_state_t *s, qam_report_handler_t *handler, void *user_data);#ifdef __cplusplus}#endif#endif/*- End of file ------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -