aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp1/usrp1_calc_mux.hpp
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2020-03-02 15:25:13 -0800
committeratrnati <54334261+atrnati@users.noreply.github.com>2020-03-03 08:51:32 -0600
commit876d4150aa3da531ddd687b48afada6e43f79146 (patch)
treefd72a71419f4cd800d4e500cfcaded4dfc8dc367 /host/lib/usrp/usrp1/usrp1_calc_mux.hpp
parent1393553d623bdf4ba40d5435c9719b6ce990d9ac (diff)
downloaduhd-876d4150aa3da531ddd687b48afada6e43f79146.tar.gz
uhd-876d4150aa3da531ddd687b48afada6e43f79146.tar.bz2
uhd-876d4150aa3da531ddd687b48afada6e43f79146.zip
uhd: Apply clang-format against all .cpp and .hpp files in host/
Note: template_lvbitx.{cpp,hpp} need to be excluded from the list of files that clang-format gets applied against.
Diffstat (limited to 'host/lib/usrp/usrp1/usrp1_calc_mux.hpp')
-rw-r--r--host/lib/usrp/usrp1/usrp1_calc_mux.hpp133
1 files changed, 69 insertions, 64 deletions
diff --git a/host/lib/usrp/usrp1/usrp1_calc_mux.hpp b/host/lib/usrp/usrp1/usrp1_calc_mux.hpp
index 1169f2fe8..63f00f514 100644
--- a/host/lib/usrp/usrp1/usrp1_calc_mux.hpp
+++ b/host/lib/usrp/usrp1/usrp1_calc_mux.hpp
@@ -12,14 +12,14 @@
#include <uhd/utils/log.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/format.hpp>
+#include <string>
#include <utility>
#include <vector>
-#include <string>
#ifndef INCLUDED_USRP1_CALC_MUX_HPP
-#define INCLUDED_USRP1_CALC_MUX_HPP
+# define INCLUDED_USRP1_CALC_MUX_HPP
-//db_name, conn_type for the mux calculations below...
+// db_name, conn_type for the mux calculations below...
typedef std::pair<std::string, std::string> mapping_pair_t;
/***********************************************************************
@@ -27,7 +27,8 @@ typedef std::pair<std::string, std::string> mapping_pair_t;
* The I and Q mux values are intentionally reversed to flip I and Q
* to account for the reversal in the type conversion routines.
**********************************************************************/
-static int calc_rx_mux_pair(int adc_for_i, int adc_for_q){
+static int calc_rx_mux_pair(int adc_for_i, int adc_for_q)
+{
return (adc_for_i << 0) | (adc_for_q << 2);
}
@@ -38,48 +39,49 @@ static int calc_rx_mux_pair(int adc_for_i, int adc_for_q){
* | must be zero | Q3| I3| Q2| I2| Q1| I1| Q0| I0|Z| NCH |
* +-----------------------+-------+-------+-------+-------+-+-----+
*/
-static uint32_t calc_rx_mux(const std::vector<mapping_pair_t> &mapping){
- //create look-up-table for mapping dboard name and connection type to ADC flags
+static uint32_t calc_rx_mux(const std::vector<mapping_pair_t>& mapping)
+{
+ // create look-up-table for mapping dboard name and connection type to ADC flags
static const int ADC0 = 0, ADC1 = 1, ADC2 = 2, ADC3 = 3;
- static const uhd::dict<std::string, uhd::dict<std::string, int> > name_to_conn_to_flag = boost::assign::map_list_of
- ("A", boost::assign::map_list_of
- ("IQ", calc_rx_mux_pair(ADC0, ADC1)) //I and Q
- ("QI", calc_rx_mux_pair(ADC1, ADC0)) //I and Q
- ("I", calc_rx_mux_pair(ADC0, ADC0)) //I and Q (Q identical but ignored Z=1)
- ("Q", calc_rx_mux_pair(ADC1, ADC1)) //I and Q (Q identical but ignored Z=1)
- )
- ("B", boost::assign::map_list_of
- ("IQ", calc_rx_mux_pair(ADC2, ADC3)) //I and Q
- ("QI", calc_rx_mux_pair(ADC3, ADC2)) //I and Q
- ("I", calc_rx_mux_pair(ADC2, ADC2)) //I and Q (Q identical but ignored Z=1)
- ("Q", calc_rx_mux_pair(ADC3, ADC3)) //I and Q (Q identical but ignored Z=1)
- )
- ;
-
- //extract the number of channels
+ static const uhd::dict<std::string, uhd::dict<std::string, int>>
+ name_to_conn_to_flag = boost::assign::map_list_of("A",
+ boost::assign::map_list_of("IQ", calc_rx_mux_pair(ADC0, ADC1)) // I and Q
+ ("QI", calc_rx_mux_pair(ADC1, ADC0)) // I and Q
+ ("I", calc_rx_mux_pair(ADC0, ADC0)) // I and Q (Q identical but ignored Z=1)
+ ("Q", calc_rx_mux_pair(ADC1, ADC1)) // I and Q (Q identical but ignored Z=1)
+ )("B",
+ boost::assign::map_list_of("IQ", calc_rx_mux_pair(ADC2, ADC3)) // I and Q
+ ("QI", calc_rx_mux_pair(ADC3, ADC2)) // I and Q
+ ("I", calc_rx_mux_pair(ADC2, ADC2)) // I and Q (Q identical but ignored Z=1)
+ ("Q", calc_rx_mux_pair(ADC3, ADC3)) // I and Q (Q identical but ignored Z=1)
+ );
+
+ // extract the number of channels
const size_t nchan = mapping.size();
- //calculate the channel flags
+ // calculate the channel flags
int channel_flags = 0;
size_t num_reals = 0, num_quads = 0;
- for(const mapping_pair_t &pair: uhd::reversed(mapping)){
+ for (const mapping_pair_t& pair : uhd::reversed(mapping)) {
const std::string name = pair.first, conn = pair.second;
- if (conn == "IQ" or conn == "QI") num_quads++;
- if (conn == "I" or conn == "Q") num_reals++;
+ if (conn == "IQ" or conn == "QI")
+ num_quads++;
+ if (conn == "I" or conn == "Q")
+ num_reals++;
channel_flags = (channel_flags << 4) | name_to_conn_to_flag[name][conn];
}
- //calculate Z:
+ // calculate Z:
// for all real sources: Z = 1
// for all quadrature sources: Z = 0
// for mixed sources: warning + Z = 0
- int Z = (num_quads > 0)? 0 : 1;
- if (num_quads != 0 and num_reals != 0) UHD_LOGGER_WARNING("USRP1") << boost::format(
- "Mixing real and quadrature rx subdevices is not supported.\n"
- "The Q input to the real source(s) will be non-zero.\n"
- );
+ int Z = (num_quads > 0) ? 0 : 1;
+ if (num_quads != 0 and num_reals != 0)
+ UHD_LOGGER_WARNING("USRP1") << boost::format(
+ "Mixing real and quadrature rx subdevices is not supported.\n"
+ "The Q input to the real source(s) will be non-zero.\n");
- //calculate the rx mux value
+ // calculate the rx mux value
return ((channel_flags & 0xffff) << 4) | ((Z & 0x1) << 3) | ((nchan & 0x7) << 0);
}
@@ -88,7 +90,8 @@ static uint32_t calc_rx_mux(const std::vector<mapping_pair_t> &mapping){
* The I and Q mux values are intentionally reversed to flip I and Q
* to account for the reversal in the type conversion routines.
**********************************************************************/
-static int calc_tx_mux_pair(int chn_for_i, int chn_for_q){
+static int calc_tx_mux_pair(int chn_for_i, int chn_for_q)
+{
return (chn_for_i << 0) | (chn_for_q << 4);
}
@@ -99,48 +102,50 @@ static int calc_tx_mux_pair(int chn_for_i, int chn_for_q){
* | | DAC1Q | DAC1I | DAC0Q | DAC0I |0| NCH |
* +-----------------------------------------------+-------+-+-----+
*/
-static uint32_t calc_tx_mux(const std::vector<mapping_pair_t> &mapping){
- //create look-up-table for mapping channel number and connection type to flags
+static uint32_t calc_tx_mux(const std::vector<mapping_pair_t>& mapping)
+{
+ // create look-up-table for mapping channel number and connection type to flags
static const int ENB = 1 << 3, CHAN_I0 = 0, CHAN_Q0 = 1, CHAN_I1 = 2, CHAN_Q1 = 3;
- static const uhd::dict<size_t, uhd::dict<std::string, int> > chan_to_conn_to_flag = boost::assign::map_list_of
- (0, boost::assign::map_list_of
- ("IQ", calc_tx_mux_pair(CHAN_I0 | ENB, CHAN_Q0 | ENB))
- ("QI", calc_tx_mux_pair(CHAN_Q0 | ENB, CHAN_I0 | ENB))
- ("I", calc_tx_mux_pair(CHAN_I0 | ENB, 0 ))
- ("Q", calc_tx_mux_pair(0, CHAN_I0 | ENB))
- )
- (1, boost::assign::map_list_of
- ("IQ", calc_tx_mux_pair(CHAN_I1 | ENB, CHAN_Q1 | ENB))
- ("QI", calc_tx_mux_pair(CHAN_Q1 | ENB, CHAN_I1 | ENB))
- ("I", calc_tx_mux_pair(CHAN_I1 | ENB, 0 ))
- ("Q", calc_tx_mux_pair(0, CHAN_I1 | ENB))
- )
- ;
-
- //extract the number of channels
+ static const uhd::dict<size_t, uhd::dict<std::string, int>> chan_to_conn_to_flag =
+ boost::assign::map_list_of(0,
+ boost::assign::map_list_of(
+ "IQ", calc_tx_mux_pair(CHAN_I0 | ENB, CHAN_Q0 | ENB))(
+ "QI", calc_tx_mux_pair(CHAN_Q0 | ENB, CHAN_I0 | ENB))(
+ "I", calc_tx_mux_pair(CHAN_I0 | ENB, 0))(
+ "Q", calc_tx_mux_pair(0, CHAN_I0 | ENB)))(1,
+ boost::assign::map_list_of(
+ "IQ", calc_tx_mux_pair(CHAN_I1 | ENB, CHAN_Q1 | ENB))(
+ "QI", calc_tx_mux_pair(CHAN_Q1 | ENB, CHAN_I1 | ENB))(
+ "I", calc_tx_mux_pair(CHAN_I1 | ENB, 0))(
+ "Q", calc_tx_mux_pair(0, CHAN_I1 | ENB)));
+
+ // extract the number of channels
size_t nchan = mapping.size();
- //calculate the channel flags
+ // calculate the channel flags
int channel_flags = 0, chan = 0;
- uhd::dict<std::string, int> slot_to_chan_count = boost::assign::map_list_of("A", 0)("B", 0);
- for(const mapping_pair_t &pair: mapping){
+ uhd::dict<std::string, int> slot_to_chan_count =
+ boost::assign::map_list_of("A", 0)("B", 0);
+ for (const mapping_pair_t& pair : mapping) {
const std::string name = pair.first, conn = pair.second;
- //combine the channel flags: shift for slot A vs B
- if (name == "A") channel_flags |= chan_to_conn_to_flag[chan][conn] << 0;
- if (name == "B") channel_flags |= chan_to_conn_to_flag[chan][conn] << 8;
+ // combine the channel flags: shift for slot A vs B
+ if (name == "A")
+ channel_flags |= chan_to_conn_to_flag[chan][conn] << 0;
+ if (name == "B")
+ channel_flags |= chan_to_conn_to_flag[chan][conn] << 8;
- //sanity check, only 1 channel per slot
+ // sanity check, only 1 channel per slot
slot_to_chan_count[name]++;
- if (slot_to_chan_count[name] > 1) throw uhd::value_error(
- "cannot assign dboard slot to multiple channels: " + name
- );
+ if (slot_to_chan_count[name] > 1)
+ throw uhd::value_error(
+ "cannot assign dboard slot to multiple channels: " + name);
- //increment for the next channel
+ // increment for the next channel
chan++;
}
- //calculate the tx mux value
+ // calculate the tx mux value
return ((channel_flags & 0xffff) << 4) | ((nchan & 0x7) << 0);
}