GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
gnss_sdr_fpga_sample_counter.h
Go to the documentation of this file.
1 /*!
2  * \file gnss_sdr_fpga_sample_counter.h
3  * \brief Simple block to report the current receiver time based on the output
4  * of the tracking or telemetry blocks
5  * \author Javier Arribas 2018. jarribas(at)cttc.es
6  *
7  *
8  * -----------------------------------------------------------------------------
9  *
10  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
11  *
12  * GNSS-SDR is a software defined Global Navigation
13  * Satellite Systems receiver
14  *
15  * This file is part of GNSS-SDR.
16  *
17  * SPDX-License-Identifier: GPL-3.0-or-later
18  *
19  * -----------------------------------------------------------------------------
20  */
21 
22 #ifndef GNSS_SDR_GNSS_SDR_FPGA_SAMPLE_COUNTER_H
23 #define GNSS_SDR_GNSS_SDR_FPGA_SAMPLE_COUNTER_H
24 
25 #include <gnuradio/block.h>
26 #include <gnuradio/types.h> // for gr_vector_const_void_star
27 #include <cstdint>
28 #include <string>
29 #if GNURADIO_USES_STD_POINTERS
30 #include <memory>
31 #else
32 #include <boost/shared_ptr.hpp>
33 #endif
34 
36 
37 #if GNURADIO_USES_STD_POINTERS
38 using gnss_sdr_fpga_sample_counter_sptr = std::shared_ptr<gnss_sdr_fpga_sample_counter>;
39 #else
40 using gnss_sdr_fpga_sample_counter_sptr = boost::shared_ptr<gnss_sdr_fpga_sample_counter>;
41 #endif
42 
43 gnss_sdr_fpga_sample_counter_sptr gnss_sdr_make_fpga_sample_counter(double _fs, int32_t _interval_ms);
44 
45 class gnss_sdr_fpga_sample_counter : public gr::block
46 {
47 public:
49  int general_work(int noutput_items,
50  gr_vector_int &ninput_items,
51  gr_vector_const_void_star &input_items,
52  gr_vector_void_star &output_items);
53 
54 private:
55  static const uint32_t page_size = 0x10000; // default page size for the multicorrelator memory map
56  static const uint32_t test_reg_sanity_check = 0x55AA; // value to check the presence of the test register (to detect the hw)
57 
58  friend gnss_sdr_fpga_sample_counter_sptr gnss_sdr_make_fpga_sample_counter(double _fs, int32_t _interval_ms);
59  gnss_sdr_fpga_sample_counter(double _fs, int32_t _interval_ms);
60  uint32_t test_register(uint32_t writeval);
61  void configure_samples_per_output(uint32_t interval);
62  void close_device(void);
63  void open_device(void);
64  bool start();
65  bool stop();
66  void wait_for_interrupt(void);
67 
68  volatile uint32_t *map_base; // driver memory map
69  std::string device_name = "/dev/uio2"; // HW device name
70 
71  double fs;
72  uint64_t sample_counter;
73  uint64_t last_sample_counter;
74  uint64_t current_T_rx_ms; // Receiver time in ms since the beginning of the run
75 
76  uint32_t samples_per_output;
77  uint32_t samples_per_report;
78  uint32_t interval_ms;
79  uint32_t current_s; // Receiver time in seconds, modulo 60
80  uint32_t current_m; // Receiver time in minutes, modulo 60
81  uint32_t current_h; // Receiver time in hours, modulo 24
82  uint32_t current_days; // Receiver time in days since the beginning of the run
83  int32_t report_interval_ms;
84  int32_t fd; // driver descriptor
85 
86  bool flag_enable_send_msg;
87  bool flag_m; // True if the receiver has been running for at least 1 minute
88  bool flag_h; // True if the receiver has been running for at least 1 hour
89  bool flag_days; // True if the receiver has been running for at least 1 day
90  bool is_open;
91 };
92 
93 #endif // GNSS_SDR_GNSS_SDR_FPGA_SAMPLE_COUNTER_H