GNSS-SDR  0.0.19
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  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
11  * This file is part of GNSS-SDR.
12  *
13  * Copyright (C) 2010-2020 (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_GNSS_SDR_FPGA_SAMPLE_COUNTER_H
20 #define GNSS_SDR_GNSS_SDR_FPGA_SAMPLE_COUNTER_H
21 
22 #include "gnss_block_interface.h"
23 #include <gnuradio/block.h>
24 #include <gnuradio/types.h> // for gr_vector_const_void_star
25 #include <cstdint>
26 #include <string>
27 
28 /** \addtogroup Core
29  * \{ */
30 /** \addtogroup Core_Receiver_Library
31  * \{ */
32 
33 
35 
36 using gnss_sdr_fpga_sample_counter_sptr = gnss_shared_ptr<gnss_sdr_fpga_sample_counter>;
37 
38 gnss_sdr_fpga_sample_counter_sptr gnss_sdr_make_fpga_sample_counter(double _fs, int32_t _interval_ms);
39 
40 class gnss_sdr_fpga_sample_counter : public gr::block
41 {
42 public:
44  int general_work(int noutput_items,
45  gr_vector_int &ninput_items,
46  gr_vector_const_void_star &input_items,
47  gr_vector_void_star &output_items);
48 
49 private:
50  const std::string device_name = "counter"; // UIO device name
51 
52  static const uint32_t FPGA_PAGE_SIZE = 0x1000; // default page size for the multicorrelator memory map
53  static const uint32_t test_reg_sanity_check = 0x55AA; // value to check the presence of the test register (to detect the hw)
54 
55  friend gnss_sdr_fpga_sample_counter_sptr gnss_sdr_make_fpga_sample_counter(double _fs, int32_t _interval_ms);
56  gnss_sdr_fpga_sample_counter(double _fs, int32_t _interval_ms);
57  uint32_t test_register(uint32_t writeval);
58  void configure_samples_per_output(uint32_t interval);
59  void close_device(void);
60  void open_device(void);
61  bool start();
62  bool stop();
63  void wait_for_interrupt(void) const;
64 
65  volatile uint32_t *map_base; // driver memory map
66 
67  double fs;
68  uint64_t sample_counter;
69  uint64_t last_sample_counter;
70  uint64_t current_T_rx_ms; // Receiver time in ms since the beginning of the run
71 
72  uint32_t samples_per_output;
73  uint32_t samples_per_report;
74  uint32_t interval_ms;
75  uint32_t current_s; // Receiver time in seconds, modulo 60
76  uint32_t current_m; // Receiver time in minutes, modulo 60
77  uint32_t current_h; // Receiver time in hours, modulo 24
78  uint32_t current_days; // Receiver time in days since the beginning of the run
79  int32_t report_interval_ms;
80  int32_t fd; // driver descriptor
81 
82  bool flag_enable_send_msg;
83  bool flag_m; // True if the receiver has been running for at least 1 minute
84  bool flag_h; // True if the receiver has been running for at least 1 hour
85  bool flag_days; // True if the receiver has been running for at least 1 day
86  bool is_open;
87 };
88 
89 
90 /** \} */
91 /** \} */
92 #endif // GNSS_SDR_GNSS_SDR_FPGA_SAMPLE_COUNTER_H
This interface represents a GNSS block.