GNSS-SDR 0.0.21
An Open Source GNSS Software Defined Receiver
Loading...
Searching...
No Matches
max2771_evkit_signal_source_fpga.h
Go to the documentation of this file.
1/*!
2 * \file max2771_evkit_signal_source_fpga.h
3 * \brief Signal source for the MAX2771EVKIT evaluation board connected directly
4 * to FPGA accelerators.
5 * This source implements only the MAX2771 control. It is NOT compatible with
6 * conventional SDR acquisition and tracking blocks.
7 *
8 * -----------------------------------------------------------------------------
9 *
10 * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
11 * This file is part of GNSS-SDR.
12 *
13 * Copyright (C) 2010-2024 (see AUTHORS file for a list of contributors)
14 * SPDX-License-Identifier: GPL-3.0-or-later
15 *
16 * -----------------------------------------------------------------------------
17 */
18
19#ifndef GNSS_SDR_MAX2771_EVKIT_SIGNAL_SOURCE_FPGA_H
20#define GNSS_SDR_MAX2771_EVKIT_SIGNAL_SOURCE_FPGA_H
21
22#include "command_event.h"
23#include "concurrent_queue.h"
24#include "fpga_buffer_monitor.h"
25#include "fpga_spidev.h"
27#include "signal_source_base.h"
28#include <pmt/pmt.h> // for pmt::pmt_t
29#include <cstdint> // for fixed-width integer types
30#include <memory> // for smart pointers
31#include <mutex> // for mutex
32#include <string> // for strings
33#include <thread> // for threads
34#include <vector> // for std::vector
35
36
37/** \addtogroup Signal_Source
38 * \{ */
39/** \addtogroup Signal_Source_adapters
40 * \{ */
41
42
44
45class MAX2771EVKITSignalSourceFPGA : public SignalSourceBase
46{
47public:
48 MAX2771EVKITSignalSourceFPGA(const ConfigurationInterface *configuration,
49 const std::string &role, unsigned int in_stream,
50 unsigned int out_stream, Concurrent_Queue<pmt::pmt_t> *queue);
51
52 ~MAX2771EVKITSignalSourceFPGA();
53
54 std::vector<uint32_t> setup_regs(uint64_t freq);
55
56 inline size_t item_size() override
57 {
58 return item_size_;
59 }
60
61 void connect(gr::top_block_sptr top_block) override;
62 void disconnect(gr::top_block_sptr top_block) override;
63 gr::basic_block_sptr get_left_block() override;
64 gr::basic_block_sptr get_right_block() override;
65
66private:
67 const std::string DEFAULT_BUFF_MON_FILENAME = std::string("FPGA_buffer_monitor_dump.dat"); // Default buffer monitor output file
68 const std::string FREQ_BAND_0_SPI_DEVICE_NAME = std::string("/dev/spidev2.0"); // SPI 0 device name
69 const std::string FREQ_BAND_1_SPI_DEVICE_NAME = std::string("/dev/spidev1.0"); // SPI 1 device name
70 const uint32_t MAX_NUM_FREQ_BANDS = 2; // Maximum number of frequency bands
71 const uint32_t DEFAULT_NUM_FREQ_BANDS = 1; // Default number of frequency bands used
72 const uint64_t DEFAULT_BANDWIDTH = 16400000; // Default bandwidth
73 const uint32_t DEFAULT_FILTER_ORDER = 5; // Default filter order
74 const uint64_t DEFAULT_SAMPLING_RATE = 16368000; // Default sampling rate
75 const uint32_t DEFAULT_PGA_GAIN_VALUE = 0x3A; // default PGA gain when AGC is off
76 // max PGA gain value
77 const uint32_t MAX_PGA_GAIN_VALUE = 0x3F;
78 // check buffer overflow and perform buffer monitoring every 1s by default
79 const uint32_t BUFFER_MONITOR_PERIOD_MS = 1000;
80 // buffer overflow and buffer monitoring initial delay
81 const uint32_t BUFFER_MONITOR_INITIAL_DELAY_MS = 2000;
82 // MAX2771 number of configuration registers
83 const uint32_t MAX2771_NUM_REGS = 11;
84 // MAX2771 configuration register fields
85 const uint32_t IDLE = 0x0; // Idle mode disabled
86 const uint32_t MIXPOLE = 0x0; // set the passive filter pole at mixer output at 13 MHz.
87 const uint32_t MIXERMODE_HIGH_BAND = 0x0; // L1 band enabled
88 const uint32_t MIXERMODE_LOW_BAND = 0X1; // L2/L5 band enabled
89 const uint32_t FCEN = 0x58; // Center frequency not used when in low-pass filter mode. Set to default value.
90 const uint32_t FCENX = 0x0; // POlyphase filter selection set to Lowpass filter
91 const uint32_t ANAIMON = 0x0; // analog monitor disabled
92 const uint32_t IQEN = 0x1; // I and Q channels enable
93 const uint32_t GAINREF = 0xAA; // AGC Gain ref
94 const uint32_t SPI_SDIO_CONFIG = 0x0; // SPI SDIO config when tri-stated: nothing applied
95 const uint32_t FORMAT = 0x1; // sign and magnitude
96 const uint32_t BITS = 0x2; // number of bits in the ADC = 2
97 const uint32_t DRVCFG = 0x0; // output driver configuration = CMOS Logic
98 const uint32_t DIEID = 0x0; // identifies version of IC
99 const uint32_t HILOADEN = 0x0; // disable output driver for high loads
100 const uint32_t FHIPEN = 0x1; // enable highpass coupling between filter and PGA.
101 const uint32_t PGAIEN = 0x1; // I-Channel PGA Enable
102 const uint32_t PGAQEN = 0x1; // Q-Channel PGA Enable
103 const uint32_t STRMEN = 0x0; // disable DSP interface for serial streaming of data
104 const uint32_t STRMSTART = 0x0; // the rising edge of this bit enables data streaming to the output, clock, data, sync and frame sync outputs.
105 const uint32_t STRMSTOP = 0x0; // the rising edge of this bit disables data streaming to the output, clock, data sync and frame sync outputs.
106 const uint32_t STRMBITS = 0x1; // number of bits to be streamed: I MSB, I LSB
107 const uint32_t STAMPEN = 0x1; // enable frame number insertion
108 const uint32_t TIMESYNCEN = 0x1; // enable the output of the time sync pulses at all times when streaming is enabled.
109 const uint32_t DATASYNCEN = 0x0; // disable the sync pulses at the DATASYNC output
110 const uint32_t STRMRST = 0x0; // counter reset not active
111 const uint32_t LOBAND_L1 = 0x0; // L1 band
112 const uint32_t LOBAND_L5 = 0x1; // L5 band
113 const uint32_t REFOUTEN = 0x1; // Output clock buffer enable
114 const uint32_t IXTAL = 0x1; // XTAL osscillator/buffer set to normal current
115 const uint32_t ICP = 0x0; // charge pump current selection set to 0.5 mA
116 const uint32_t INT_PLL = 0x1; // PLL mode set to integer-N PLL
117 const uint32_t PWRSAV = 0x0; // PLL power save mode disabled
118 const uint32_t RDIV = 0x10; // Set the PLL reference division ratio
119 const uint32_t FDIV = 0x80000; // PLL fractional division ratio not used. Set to default value
120 const uint32_t EXTADCCLK = 0x0; // use internally generated clock
121 const uint32_t REFCLK_L_CNT = 0x100; // set the L counter of the reference clock configuration to its default value
122 const uint32_t REFCLK_M_CNT = 0x61B; // set the M counter of the reference clock configuration to its default value
123 const uint32_t FCLKIN = 0x0; // fractional clock divider set to default value
124 const uint32_t ADCCLK = 0x0; // ADC clock selection set to reference clock divider/multiplier
125 const uint32_t MODE = 0x0; // DSP interface mode selection
126 const uint32_t ADCCLK_L_CNT = 0x100; // set the L counter of the ADC clock configuration to its default value
127 const uint32_t ADCCLK_M_CNT = 0x61B; // set the M counter of the ADC clock configuration to its default value
128 const uint32_t PRE_FRACDIV_SEL = 0x0; // bypass fractional clock divider
129 const uint32_t CLKOUT_SEL = 0x1; // CLKOUT selection set to ADC clock
130 // MAX2771 configuration register registers
131 const uint32_t TEST_MODE_1_REG_VAL = 0x01E0F401; // reserved
132 const uint32_t TEST_MODE_2_REG_VAL = 0x00000002;
133
134 bool configure(std::vector<uint32_t> register_values);
135 void run_buffer_monitor_process();
136
137 mutable std::mutex buffer_monitor_mutex;
138
139 std::thread thread_buffer_monitor;
140
141 std::shared_ptr<Fpga_buffer_monitor> buffer_monitor_fpga;
142 std::shared_ptr<Fpga_spidev> spidev_fpga;
143
144 uint64_t freq_; // Tuning frequency in single-band mode
145 uint64_t freq0_; // Tuning frequency for band 0 when dual-band mode is enabled
146 uint64_t freq1_; // Tuning frequency for band 1 when dual-band mode is enabled
147 uint64_t sample_rate_;
148
149 uint32_t RF_channels_;
150 uint32_t in_stream_;
151 uint32_t out_stream_;
152 uint32_t bandwidth_; // 2500000, 4200000, 8700000, 16400000, 23400000, 36000000
153 uint32_t filter_order_; // 3, 5
154 uint32_t gain_in_; // 0 to 0x3F
155
156 size_t item_size_; // 1
157
158 bool chipen_; // chip enable
159 bool if_filter_gain_; // true, false
160 bool LNA_active_; // true, false
161 bool enable_agc_; // true, false
162 bool enable_ovf_check_buffer_monitor_active_;
163 bool dump_;
164 bool rf_shutdown_;
165};
166
167
168/** \} */
169/** \} */
170#endif // GNSS_SDR_MAX2771_EVKIT_SIGNAL_SOURCE_FPGA_H
This class implements a thread-safe std::queue.
This abstract class represents an interface to configuration parameters.
SignalSourceBase(ConfigurationInterface const *configuration, std::string role, std::string impl)
Constructor.
Class that defines a receiver command event.
Interface of a thread-safe std::queue.
Check receiver buffer overflow and monitor the status of the receiver buffers.
FPGA SPI control.
This interface represents a GNSS block.
Header file of the base class to signal_source GNSS blocks.