Imported Upstream version 3.2.2
[debian/gnuradio] / usrp2 / firmware / lib / db_base.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2008,2009 Free Software Foundation, Inc.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef INCLUDED_DB_BASE_H
20 #define INCLUDED_DB_BASE_H
21
22 #include <usrp2_types.h>
23 #include <bool.h>
24
25 /*!
26  * \brief "base class" for firmware version of daughterboard code
27  */
28 struct db_base {
29   uint16_t              dbid;           //< daughterboard ID
30
31   uint16_t              is_tx             : 1;  //< is this a transmit db?
32   uint16_t              is_quadrature     : 1;
33   uint16_t              i_and_q_swapped   : 1;
34   uint16_t              spectrum_inverted : 1;
35
36   uint16_t              output_enables; //< bitmask of which pins should be outputs from FPGA
37   uint16_t              used_pins;      //< bitmask of pins used by the daughterboard
38
39   u2_fxpt_freq_t        freq_min;       //< min freq that can be set (Hz)
40   u2_fxpt_freq_t        freq_max;       //< max freq that can be set (Hz)
41
42   u2_fxpt_gain_t        gain_min;       //< min gain that can be set (dB)
43   u2_fxpt_gain_t        gain_max;       //< max gain that can be set (dB)
44   u2_fxpt_gain_t        gain_step_size; //< (dB)
45
46   u2_fxpt_freq_t        default_lo_offset;  //< offset to add to tune frequency, reset value
47   u2_fxpt_freq_t        current_lo_offset;  //< current value of lo_offset
48
49   /*
50    * Auto T/R control values
51    */
52   uint32_t              atr_mask;       //< which bits to control
53   uint32_t              atr_txval;      //< value to use when transmitting
54   uint32_t              atr_rxval;      //< value to use when receiving
55
56   //! delay in clk ticks from when Tx fifo gets data to when T/R switches
57   // uint32_t           atr_tx_delay;
58
59   //! delay in clk ticks from when Tx fifo goes empty to when T/R switches
60   // uint32_t           atr_rx_delay;
61
62   bool  (*init)(struct db_base *);
63   bool  (*set_freq)(struct db_base *, u2_fxpt_freq_t freq, u2_fxpt_freq_t *dc);
64   bool  (*set_gain)(struct db_base *, u2_fxpt_gain_t gain);
65   bool  (*set_tx_enable)(struct db_base *, bool on);
66 };
67
68
69 #endif /* INCLUDED_DB_BASE_H */