summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gr-vrt/src/vrt_quadradio_source_32fc.cc14
-rw-r--r--gr-vrt/src/vrt_quadradio_source_32fc.h5
-rw-r--r--vrt/include/vrt/quadradio.h14
-rw-r--r--vrt/lib/quadradio.cc44
4 files changed, 57 insertions, 20 deletions
diff --git a/gr-vrt/src/vrt_quadradio_source_32fc.cc b/gr-vrt/src/vrt_quadradio_source_32fc.cc
index 0321062aa..0aac86991 100644
--- a/gr-vrt/src/vrt_quadradio_source_32fc.cc
+++ b/gr-vrt/src/vrt_quadradio_source_32fc.cc
@@ -86,9 +86,15 @@ vrt_quadradio_source_32fc::set_center_freq(double target_freq)
}
bool
-vrt_quadradio_source_32fc::set_band_select(const std::string &band)
+vrt_quadradio_source_32fc::set_band_select(int band)
{
- return d_qr->set_band_select(band);
+ return d_qr->set_band_select(static_cast<vrt_band_sel_t>(band));
+}
+
+int
+vrt_quadradio_source_32fc::get_band_select(void)
+{
+ return static_cast<int>(d_qr->get_band_select());
}
//void
@@ -210,3 +216,7 @@ vrt_quadradio_source_32fc::set_beamforming(std::vector<gr_complex> gains){
return d_qr->set_beamforming(gains_ints);
}
+bool
+vrt_quadradio_source_32fc::set_cal_enb(bool enb){
+ return d_qr->set_cal_enb(enb);
+}
diff --git a/gr-vrt/src/vrt_quadradio_source_32fc.h b/gr-vrt/src/vrt_quadradio_source_32fc.h
index 6ad63f7be..6193efa10 100644
--- a/gr-vrt/src/vrt_quadradio_source_32fc.h
+++ b/gr-vrt/src/vrt_quadradio_source_32fc.h
@@ -68,9 +68,9 @@ public:
/*!
* \brief Set the band select dboard bits.
- * \param band "A", "B", "C", "D"
*/
- bool set_band_select(const std::string &band);
+ bool set_band_select(int band);
+ int get_band_select(void);
/*!
* \brief Turn the 10 dB attenuation on/off.
@@ -109,6 +109,7 @@ public:
bool set_lo_freq(double freq);
bool set_cal_freq(double freq);
bool set_beamforming(std::vector<gr_complex> gains);
+ bool set_cal_enb(bool enb);
};
diff --git a/vrt/include/vrt/quadradio.h b/vrt/include/vrt/quadradio.h
index 747ca8ef4..83323f093 100644
--- a/vrt/include/vrt/quadradio.h
+++ b/vrt/include/vrt/quadradio.h
@@ -38,6 +38,14 @@ typedef enum{
} vrt_test_sig_t;
+typedef enum{
+ VRT_BAND_SEL_A='A',
+ VRT_BAND_SEL_B='B',
+ VRT_BAND_SEL_C='C',
+ VRT_BAND_SEL_D='D',
+
+ } vrt_band_sel_t;
+
namespace vrt {
/*
@@ -53,7 +61,7 @@ namespace vrt {
int d_data_port; // our data port number
vrt::rx::sptr d_rx; // has-a rx
- int d_band_select; // band select setting
+ vrt_band_sel_t d_band_select; // band select setting
int d_rx_antenna; // antenna type rf/cal
int d_attenuation0; // attenuation setting
int d_attenuation1; // attenuation setting
@@ -92,7 +100,8 @@ namespace vrt {
/* convenience methods that ultimately write the dboard pins */
bool set_center_freq(double target_freq);
- bool set_band_select(const std::string &band);
+ bool set_band_select(vrt_band_sel_t band);
+ vrt_band_sel_t get_band_select(void){return d_band_select;}
//void set_10dB_atten(bool on);
bool set_attenuation0(int attenuation);
bool select_rx_antenna(const std::string &ant);
@@ -110,6 +119,7 @@ namespace vrt {
bool set_lo_freq(double freq);
bool set_cal_freq(double freq);
bool set_beamforming(int32_t gains[8]);
+ bool set_cal_enb(bool enb);
/*
* The first parameter for these is a bitmask which indicates which
* daughterboard or daughterboards to apply the operation to.
diff --git a/vrt/lib/quadradio.cc b/vrt/lib/quadradio.cc
index ab5de89b8..8cf542e0f 100644
--- a/vrt/lib/quadradio.cc
+++ b/vrt/lib/quadradio.cc
@@ -51,7 +51,7 @@ send_and_check(int fd, void *buf, size_t len)
vrt::quadradio::quadradio(const std::string &ip, size_t rx_bufsize)
: d_ctrl_fd(0), d_data_fd(0), d_data_port(0),
- d_band_select(0), d_rx_antenna(0), d_attenuation0(0), d_attenuation1(0)//d_10dB_atten(true)
+ d_band_select(VRT_BAND_SEL_A), d_rx_antenna(0), d_attenuation0(0), d_attenuation1(0)//d_10dB_atten(true)
{
if (!open(ip.c_str()))
throw std::runtime_error("vrt::quadradio: failed to open " + ip + "\n");
@@ -89,20 +89,16 @@ vrt::quadradio::stop_streaming()
bool
vrt::quadradio::set_center_freq(double target_freq){
if (target_freq < 700e6) return false;
- if (target_freq <= 1.0e9) return set_band_select("A");
- if (target_freq <= 1.5e9) return set_band_select("B");
- if (target_freq <= 2.2e9) return set_band_select("C");
- if (target_freq <= 3.0e9) return set_band_select("D");
+ if (target_freq <= 1.0e9) return set_band_select(VRT_BAND_SEL_A);
+ if (target_freq <= 1.5e9) return set_band_select(VRT_BAND_SEL_B);
+ if (target_freq <= 2.2e9) return set_band_select(VRT_BAND_SEL_C);
+ if (target_freq <= 3.0e9) return set_band_select(VRT_BAND_SEL_D);
return false;
}
bool
-vrt::quadradio::set_band_select(const std::string &band){
- if (band == "A") d_band_select = 3;
- else if (band == "B") d_band_select = 2;
- else if (band == "C") d_band_select = 1;
- else if (band == "D") d_band_select = 0;
- else return false;
+vrt::quadradio::set_band_select(vrt_band_sel_t band){
+ d_band_select = band;
update_dboard_pins();
return true;
}
@@ -149,11 +145,21 @@ static int reverse_bits(int input, int len){
void
vrt::quadradio::update_dboard_pins(void){
+ //convert the band ID to bits
+ int band_select;
+ switch (d_band_select){
+ case VRT_BAND_SEL_A: band_select = 3; break;
+ case VRT_BAND_SEL_B: band_select = 2; break;
+ case VRT_BAND_SEL_C: band_select = 1; break;
+ case VRT_BAND_SEL_D: band_select = 0; break;
+ default: band_select = 0;
+ }
+ //calculate the control bits
int db_ctrl = \
- ((reverse_bits(d_attenuation0, 5) & 0x1f) << 10) | \
+ ((reverse_bits(d_attenuation0, 5) & 0x1f) << 10) | \
((reverse_bits(~d_attenuation1, 5) & 0x1f) << 03) | \
- ((d_band_select & 0x03) << 01) | \
- ((d_rx_antenna & 0x01) << 00);
+ ((band_select & 0x03) << 01) | \
+ ((d_rx_antenna & 0x01) << 00);
set_dboard_pins(ALL_DBOARDS, db_ctrl); // FIXME sets them all
}
@@ -406,3 +412,13 @@ vrt::quadradio::set_beamforming(int32_t gains[8]){
return send_and_check(d_ctrl_fd, cmd, sizeof(cmd));
}
+bool
+vrt::quadradio::set_cal_enb(bool enb)
+{
+ uint32_t cmd[3];
+ cmd[0] = htonl(0); // verb: set
+ cmd[1] = htonl(9); // id: cal enb
+ cmd[2] = htonl(enb);
+
+ return send_and_check(d_ctrl_fd, cmd, sizeof(cmd));
+}