GNSS-SDR  0.0.20
An Open Source GNSS Software Defined Receiver
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"
26 #include "gnss_block_interface.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 
46 {
47 public:
49  const std::string &role, unsigned int in_stream,
50  unsigned int out_stream, Concurrent_Queue<pmt::pmt_t> *queue);
51 
53 
54  std::vector<uint32_t> setup_regs(void);
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 
66 private:
67  const std::string default_dump_filename = std::string("FPGA_buffer_monitor_dump.dat");
68  const uint64_t default_bandwidth = 2500000;
69  const uint32_t default_filter_order = 5;
70  const uint64_t default_sampling_rate = 4092000;
71  const uint32_t default_PGA_gain_value = 0x3A; // default PGA gain when AGC is off
72  // max PGA gain value
73  const uint32_t max_PGA_gain_value = 0x3F;
74  // check buffer overflow and perform buffer monitoring every 1s by default
75  const uint32_t buffer_monitor_period_ms = 1000;
76  // buffer overflow and buffer monitoring initial delay
77  const uint32_t buffer_monitoring_initial_delay_ms = 2000;
78  // MAX2771 number of configuration registers
79  const uint32_t MAX2771_NUM_REGS = 11;
80  // MAX2771 configuration register fields
81  const uint32_t NUM_FREQ_BANDS = 1;
82  const uint32_t IDLE = 0x0; // Idle mode disabled
83  const uint32_t MIXPOLE = 0x0; // set the passive filter pole at mixer output at 13 MHz.
84  const uint32_t MIXERMODE = 0x0; // L1 band enabled
85  const uint32_t FCEN = 0x58; // Center frequency not used when in low-pass filter mode. Set to default value.
86  const uint32_t FCENX = 0x0; // POlyphase filter selection set to Lowpass filter
87  const uint32_t ANAIMON = 0x0; // analog monitor disabled
88  const uint32_t IQEN = 0x1; // I and Q channels enable
89  const uint32_t GAINREF = 0xAA; // AGC Gain ref
90  const uint32_t SPI_SDIO_CONFIG = 0x0; // SPI SDIO config when tri-stated: nothing applied
91  const uint32_t FORMAT = 0x1; // sign and magnitude
92  const uint32_t BITS = 0x2; // number of bits in the ADC = 2
93  const uint32_t DRVCFG = 0x0; // output driver configuration = CMOS Logic
94  const uint32_t DIEID = 0x0; // identifies version of IC
95  const uint32_t HILOADEN = 0x0; // disable output driver for high loads
96  const uint32_t FHIPEN = 0x1; // enable highpass coupling between filter and PGA.
97  const uint32_t PGAIEN = 0x1; // I-Channel PGA Enable
98  const uint32_t PGAQEN = 0x1; // Q-Channel PGA Enable
99  const uint32_t STRMEN = 0x0; // disable DSP interface for serial streaming of data
100  const uint32_t STRMSTART = 0x0; // the rising edge of this bit enables data streaming to the output, clock, data, sync and frame sync outputs.
101  const uint32_t STRMSTOP = 0x0; // the rising edge of this bit disables data streaming to the output, clock, data sync and frame sync outputs.
102  const uint32_t STRMBITS = 0x1; // number of bits to be streamed: I MSB, I LSB
103  const uint32_t STAMPEN = 0x1; // enable frame number insertion
104  const uint32_t TIMESYNCEN = 0x1; // enable the output of the time sync pulses at all times when streaming is enabled.
105  const uint32_t DATASYNCEN = 0x0; // disable the sync pulses at the DATASYNC output
106  const uint32_t STRMRST = 0x0; // counter reset not active
107  const uint32_t LOBAND = 0x0; // L1 band
108  const uint32_t REFOUTEN = 0x1; // Output clock buffer enable
109  const uint32_t IXTAL = 0x1; // XTAL osscillator/buffer set to normal current
110  const uint32_t ICP = 0x0; // charge pump current selection set to 0.5 mA
111  const uint32_t INT_PLL = 0x1; // PLL mode set to integer-N PLL
112  const uint32_t PWRSAV = 0x0; // PLL power save mode disabled
113  const uint32_t RDIV = 0x10; // Set the PLL reference division ratio such that the L1 band is tuned to 1575.42 Mhz
114  const uint32_t FDIV = 0x80000; // PLL fractional division ratio not used. Set to default value
115  const uint32_t EXTADCCLK = 0x0; // use internally generated clock
116  const uint32_t REFCLK_L_CNT = 0x100; // set the L counter of the reference clock configuration to its default value
117  const uint32_t REFCLK_M_CNT = 0x61B; // set the M counter of the reference clock configuration to its default value
118  const uint32_t FCLKIN = 0x0; // fractional clock divider set to default value
119  const uint32_t ADCCLK = 0x0; // ADC clock selection set to reference clock divider/multiplier
120  const uint32_t MODE = 0x0; // DSP interface mode selection
121  const uint32_t ADCCLK_L_CNT = 0x100; // set the L counter of the ADC clock configuration to its default value
122  const uint32_t ADCCLK_M_CNT = 0x61B; // set the M counter of the ADC clock configuration to its default value
123  const uint32_t PRE_FRACDIV_SEL = 0x0; // bypass fractional clock divider
124  const uint32_t CLKOUT_SEL = 0x1; // CLKOUT selection set to ADC clock
125  // MAX2771 configuration register registers
126  const uint32_t TEST_MODE_1_REG_VAL = 0x01E0F401; // reserved
127  const uint32_t TEST_MODE_2_REG_VAL = 0x00000002;
128 
129  bool configure(std::vector<uint32_t> register_values);
130  void run_buffer_monitor_process();
131 
132  mutable std::mutex buffer_monitor_mutex;
133 
134  std::thread thread_buffer_monitor;
135 
136  std::shared_ptr<Fpga_buffer_monitor> buffer_monitor_fpga;
137  std::shared_ptr<Fpga_spidev> spidev_fpga;
138 
139  uint64_t freq_; // frequency of local oscillator
140  uint64_t sample_rate_;
141 
142  uint32_t in_stream_;
143  uint32_t out_stream_;
144  uint32_t bandwidth_; // 2500000, 4200000, 8700000, 16400000, 23400000, 36000000
145  uint32_t filter_order_; // 3, 5
146  uint32_t gain_in_; // 0 to 0x3F
147 
148  size_t item_size_; // 1
149 
150  bool chipen_; // chip enable
151  bool if_filter_gain_; // true, false
152  bool LNA_active_; // true, false
153  bool enable_agc_; // true, false
154  bool enable_ovf_check_buffer_monitor_active_;
155  bool dump_;
156  bool rf_shutdown_;
157 };
158 
159 
160 /** \} */
161 /** \} */
162 #endif // GNSS_SDR_MAX2771_EVKIT_SIGNAL_SOURCE_FPGA_H
Interface of a thread-safe std::queue.
Header file of the base class to signal_source GNSS blocks.
FPGA SPI control.
Class that defines a receiver command event.
Check receiver buffer overflow and monitor the status of the receiver buffers.
This interface represents a GNSS block.
This abstract class represents an interface to configuration parameters.