1 //
2 // Copyright 2015 Ettus Research LLC
3 // Copyright 2018 Ettus Research, a National Instruments Company
4 //
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 
8 #ifndef INCLUDED_DBOARD_TWINRX_CTRL_HPP
9 #define INCLUDED_DBOARD_TWINRX_CTRL_HPP
10 
11 #include "twinrx_io.hpp"
12 #include <uhd/types/ranges.hpp>
13 #include <uhd/types/wb_iface.hpp>
14 #include <uhd/utils/noncopyable.hpp>
15 
16 namespace uhd { namespace usrp { namespace dboard { namespace twinrx {
17 
18 class twinrx_ctrl : public uhd::noncopyable
19 {
20 public:
21     typedef std::shared_ptr<twinrx_ctrl> sptr;
22 
23     static sptr make(dboard_iface::sptr db_iface,
24         twinrx_gpio::sptr gpio_iface,
25         twinrx_cpld_regmap::sptr cpld_regmap,
26         dboard_id_t rx_id);
27 
~twinrx_ctrl()28     virtual ~twinrx_ctrl() {}
29 
30     enum channel_t { CH1 = 0, CH2 = 1, BOTH = 2 };
31 
32     enum preamp_state_t { PREAMP_LOWBAND, PREAMP_HIGHBAND, PREAMP_BYPASS };
33 
34     enum signal_path_t { PATH_LOWBAND, PATH_HIGHBAND };
35 
36     enum preselector_path_t { PRESEL_PATH1, PRESEL_PATH2, PRESEL_PATH3, PRESEL_PATH4 };
37 
38     enum lo_source_t { LO_INTERNAL, LO_EXTERNAL, LO_COMPANION, LO_DISABLED, LO_REIMPORT };
39 
40     enum lo_export_source_t { LO_CH1_SYNTH, LO_CH2_SYNTH, LO_EXPORT_DISABLED };
41 
42     enum antenna_mapping_t {
43         ANTX_NATIVE,
44         ANT1_SHARED,
45         ANT2_SHARED,
46         ANTX_SWAPPED,
47         ANTX_DISABLED
48     };
49 
50     enum cal_mode_t { CAL_DISABLED, CAL_CH1, CAL_CH2 };
51 
52     virtual void commit() = 0;
53 
54     virtual void set_chan_enabled(channel_t ch, bool enabled, bool commit = true) = 0;
55 
56     virtual void set_preamp1(channel_t ch, preamp_state_t value, bool commit = true) = 0;
57 
58     virtual void set_preamp2(channel_t ch, bool enabled, bool commit = true) = 0;
59 
60     virtual void set_lb_preamp_preselector(
61         channel_t ch, bool enabled, bool commit = true) = 0;
62 
63     virtual void set_signal_path(
64         channel_t ch, signal_path_t path, bool commit = true) = 0;
65 
66     virtual void set_lb_preselector(
67         channel_t ch, preselector_path_t path, bool commit = true) = 0;
68 
69     virtual void set_hb_preselector(
70         channel_t ch, preselector_path_t path, bool commit = true) = 0;
71 
72     virtual void set_input_atten(channel_t ch, uint8_t atten, bool commit = true) = 0;
73 
74     virtual void set_lb_atten(channel_t ch, uint8_t atten, bool commit = true) = 0;
75 
76     virtual void set_hb_atten(channel_t ch, uint8_t atten, bool commit = true) = 0;
77 
78     virtual void set_lo1_source(channel_t ch, lo_source_t source, bool commit = true) = 0;
79 
80     virtual void set_lo2_source(channel_t ch, lo_source_t source, bool commit = true) = 0;
81 
82     virtual void set_lo1_export_source(lo_export_source_t source, bool commit = true) = 0;
83 
84     virtual void set_lo2_export_source(lo_export_source_t source, bool commit = true) = 0;
85 
86     virtual void set_antenna_mapping(antenna_mapping_t mapping, bool commit = true) = 0;
87 
88     virtual void set_crossover_cal_mode(cal_mode_t cal_mode, bool commit = true) = 0;
89 
90     virtual double set_lo1_synth_freq(channel_t ch, double freq, bool commit = true) = 0;
91 
92     virtual double set_lo2_synth_freq(channel_t ch, double freq, bool commit = true) = 0;
93 
94     virtual double set_lo1_charge_pump(
95         channel_t ch, double current, bool commit = true) = 0;
96 
97     virtual double set_lo2_charge_pump(
98         channel_t ch, double current, bool commit = true) = 0;
99 
100     virtual uhd::meta_range_t get_lo1_charge_pump_range() = 0;
101 
102     virtual uhd::meta_range_t get_lo2_charge_pump_range() = 0;
103 
104     virtual bool read_lo1_locked(channel_t ch) = 0;
105 
106     virtual bool read_lo2_locked(channel_t ch) = 0;
107 };
108 
109 }}}} // namespace uhd::usrp::dboard::twinrx
110 
111 #endif /* INCLUDED_DBOARD_TWINRX_CTRL_HPP */
112