diff options
author | Josh Blum <josh@joshknows.com> | 2010-03-21 00:58:34 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-03-21 00:58:34 -0700 |
commit | d1ecc555e53770f1a5608000352f56f48c36c310 (patch) | |
tree | ccccaac506fa6fe0812fce202121a4ad85d3f752 /host/lib/usrp/usrp2/mboard_impl.cpp | |
parent | 26ada5ee709fc4d7e195d19720b467c14368bc05 (diff) | |
download | uhd-d1ecc555e53770f1a5608000352f56f48c36c310.tar.gz uhd-d1ecc555e53770f1a5608000352f56f48c36c310.tar.bz2 uhd-d1ecc555e53770f1a5608000352f56f48c36c310.zip |
Moved typedefs from props.hpp into new file types.hpp.
Created structs to replace range tuples, and clock config struct.
Merged clock config props into one property using config struct.
Added templated dict construction to use the assign::map_list_of.
Added gcc flag to set visibility to hidden and use the api macro.
Diffstat (limited to 'host/lib/usrp/usrp2/mboard_impl.cpp')
-rw-r--r-- | host/lib/usrp/usrp2/mboard_impl.cpp | 74 |
1 files changed, 28 insertions, 46 deletions
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 4f63e6cc9..cbca8eec7 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -16,7 +16,6 @@ // #include <uhd/utils.hpp> -#include <boost/assign/list_of.hpp> #include "usrp2_impl.hpp" using namespace uhd; @@ -36,21 +35,27 @@ void usrp2_impl::mboard_init(void){ } void usrp2_impl::init_clock_config(void){ + //init the ref source clock config + _ref_source_dict = boost::assign::map_list_of + ("int", USRP2_REF_SOURCE_INT) + ("sma", USRP2_REF_SOURCE_SMA) + ("mimo", USRP2_REF_SOURCE_MIMO) + ; + _clock_config.ref_source = "int"; + //init the pps source clock config - _pps_source_dict["sma"] = USRP2_PPS_SOURCE_SMA; - _pps_source_dict["mimo"] = USRP2_PPS_SOURCE_MIMO; - _pps_source = "sma"; + _pps_source_dict = boost::assign::map_list_of + ("sma", USRP2_PPS_SOURCE_SMA) + ("mimo", USRP2_PPS_SOURCE_MIMO) + ; + _clock_config.pps_source = "sma"; //init the pps polarity clock config - _pps_polarity_dict["pos"] = USRP2_PPS_POLARITY_POS; - _pps_polarity_dict["neg"] = USRP2_PPS_POLARITY_NEG; - _pps_polarity = "neg"; - - //init the ref source clock config - _ref_source_dict["int"] = USRP2_REF_SOURCE_INT; - _ref_source_dict["sma"] = USRP2_REF_SOURCE_SMA; - _ref_source_dict["mimo"] = USRP2_REF_SOURCE_MIMO; - _ref_source = "int"; + _pps_polarity_dict = boost::assign::map_list_of + (clock_config_t::POLARITY_POS, USRP2_PPS_POLARITY_POS) + (clock_config_t::POLARITY_NEG, USRP2_PPS_POLARITY_NEG) + ; + _clock_config.pps_polarity = clock_config_t::POLARITY_NEG; //update the clock config (sends a control packet) update_clock_config(); @@ -60,9 +65,9 @@ void usrp2_impl::update_clock_config(void){ //setup the out data usrp2_ctrl_data_t out_data; out_data.id = htonl(USRP2_CTRL_ID_HERES_A_NEW_CLOCK_CONFIG_BRO); - out_data.data.clock_config.pps_source = _pps_source_dict [_pps_source]; - out_data.data.clock_config.pps_polarity = _pps_polarity_dict[_pps_polarity]; - out_data.data.clock_config.ref_source = _ref_source_dict [_ref_source]; + out_data.data.clock_config.ref_source = _ref_source_dict [_clock_config.ref_source]; + out_data.data.clock_config.pps_source = _pps_source_dict [_clock_config.pps_source]; + out_data.data.clock_config.pps_polarity = _pps_polarity_dict[_clock_config.pps_polarity]; //send and recv usrp2_ctrl_data_t in_data = ctrl_send_and_recv(out_data); @@ -175,22 +180,14 @@ void usrp2_impl::mboard_get(const wax::obj &key_, wax::obj &val){ val = prop_names_t(_tx_dsps.get_keys()); return; - case MBOARD_PROP_PPS_SOURCE: - val = _pps_source; + case MBOARD_PROP_CLOCK_CONFIG: + val = _clock_config; return; case MBOARD_PROP_PPS_SOURCE_NAMES: val = prop_names_t(_pps_source_dict.get_keys()); return; - case MBOARD_PROP_PPS_POLARITY: - val = _pps_polarity; - return; - - case MBOARD_PROP_REF_SOURCE: - val = _ref_source; - return; - case MBOARD_PROP_REF_SOURCE_NAMES: val = prop_names_t(_ref_source_dict.get_keys()); return; @@ -237,26 +234,11 @@ void usrp2_impl::mboard_set(const wax::obj &key, const wax::obj &val){ //handle the get request conditioned on the key switch(key.as<mboard_prop_t>()){ - case MBOARD_PROP_PPS_SOURCE:{ - std::string name = val.as<std::string>(); - assert_has(_pps_source_dict.get_keys(), name, "usrp2 pps source"); - _pps_source = name; //shadow - update_clock_config(); - } - return; - - case MBOARD_PROP_PPS_POLARITY:{ - std::string name = val.as<std::string>(); - assert_has(_pps_polarity_dict.get_keys(), name, "usrp2 pps polarity"); - _pps_polarity = name; //shadow - update_clock_config(); - } - return; - - case MBOARD_PROP_REF_SOURCE:{ - std::string name = val.as<std::string>(); - assert_has(_ref_source_dict.get_keys(), name, "usrp2 reference source"); - _ref_source = name; //shadow + case MBOARD_PROP_CLOCK_CONFIG:{ + clock_config_t clock_config = val.as<clock_config_t>(); + assert_has(_pps_source_dict.get_keys(), clock_config.pps_source, "usrp2 pps source"); + assert_has(_ref_source_dict.get_keys(), clock_config.ref_source, "usrp2 ref source"); + _clock_config = clock_config; //shadow update_clock_config(); } return; |