aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/dboard/twinrx/twinrx_gain_tables.hpp
blob: 1ef9516ad505709d5bda0a11a9b060fb2c51a9ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//
// Copyright 2016 Ettus Research LLC
// Copyright 2018 Ettus Research, a National Instruments Company
//
// SPDX-License-Identifier: GPL-3.0-or-later
//

#ifndef INCLUDED_DBOARD_TWINRX_GAIN_TABLES_HPP
#define INCLUDED_DBOARD_TWINRX_GAIN_TABLES_HPP

#include "twinrx_ctrl.hpp"
#include <uhd/config.hpp>
#include <uhd/types/ranges.hpp>
#include <stdint.h>

// Turn off optimization on macOS/Clang. With optimizations
// on, twinrx_gain_tables hours to build
#if defined(UHD_PLATFORM_MACOS)
#   pragma clang optimize off
#endif
namespace uhd { namespace usrp { namespace dboard { namespace twinrx {

class twinrx_gain_config_t
{
public:
    twinrx_gain_config_t(size_t index_,
        double sys_gain_,
        uint8_t atten1_,
        uint8_t atten2_,
        bool amp1_,
        bool amp2_)
        : index(index_)
        , sys_gain(sys_gain_)
        , atten1(atten1_)
        , atten2(atten2_)
        , amp1(amp1_)
        , amp2(amp2_)
    {
    }

    twinrx_gain_config_t(const twinrx_gain_config_t& gc) = default;
    ~twinrx_gain_config_t()                              = default;

    twinrx_gain_config_t& operator=(const twinrx_gain_config_t& src)
    {
        if (this != &src) {
            this->index    = src.index;
            this->sys_gain = src.sys_gain;
            this->atten1   = src.atten1;
            this->atten2   = src.atten2;
            this->amp1     = src.amp1;
            this->amp2     = src.amp2;
        }
        return *this;
    }

    size_t index;
    double sys_gain;
    uint8_t atten1;
    uint8_t atten2;
    bool amp1;
    bool amp2;
};

class twinrx_gain_table
{
public:
    static const twinrx_gain_table lookup_table(twinrx_ctrl::signal_path_t signal_path,
        twinrx_ctrl::preselector_path_t presel_path,
        std::string profile);

    twinrx_gain_table(const std::vector<twinrx_gain_config_t>& tbl) : _tbl(tbl) {}

    const twinrx_gain_config_t& find_by_index(size_t index) const;

    inline size_t get_num_entries() const
    {
        return _tbl.size();
    }

    uhd::gain_range_t get_gain_range() const;

private:
    const std::vector<twinrx_gain_config_t>& _tbl;
};


}}}} // namespace uhd::usrp::dboard::twinrx

#if defined(UHD_PLATFORM_MACOS)
#   pragma clang optimize on
#endif

#endif /* INCLUDED_DBOARD_TWINRX_GAIN_TABLES_HPP */