static void store_b100(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
    //parse the revision number
    if (mb_eeprom.has_key("revision")) iface.write_eeprom(
        B100_EEPROM_ADDR, offsetof(b100_eeprom_map, revision),
        string_to_uint16_bytes(mb_eeprom["revision"])
    );

    //parse the product code
    if (mb_eeprom.has_key("product")) iface.write_eeprom(
        B100_EEPROM_ADDR, offsetof(b100_eeprom_map, product),
        string_to_uint16_bytes(mb_eeprom["product"])
    );

    //store the serial
    if (mb_eeprom.has_key("serial")) iface.write_eeprom(
        B100_EEPROM_ADDR, offsetof(b100_eeprom_map, serial),
        string_to_bytes(mb_eeprom["serial"], SERIAL_LEN)
    );

    //store the name
    if (mb_eeprom.has_key("name")) iface.write_eeprom(
        B100_EEPROM_ADDR, offsetof(b100_eeprom_map, name),
        string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN)
    );
}
Beispiel #2
0
void usrp1_impl::set_mb_eeprom(const mboard_eeprom_t &mb_eeprom)
{
    auto &iface = _fx2_ctrl;

    //store the serial
    if (mb_eeprom.has_key("serial")) iface->write_eeprom(
        USRP1_EEPROM_ADDR, offsetof(usrp1_eeprom_map, serial),
        string_to_bytes(mb_eeprom["serial"], USRP1_SERIAL_LEN)
    );

    //store the name
    if (mb_eeprom.has_key("name")) iface->write_eeprom(
        USRP1_EEPROM_ADDR, offsetof(usrp1_eeprom_map, name),
        string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN)
    );

    //store the master clock rate as a 32-bit uint in Hz
    if (mb_eeprom.has_key("mcr")){
        uint32_t master_clock_rate = uint32_t(std::stod(mb_eeprom["mcr"]));
        master_clock_rate = htonl(master_clock_rate);
        const byte_vector_t rate_bytes(
            reinterpret_cast<const uint8_t *>(&master_clock_rate),
            reinterpret_cast<const uint8_t *>(&master_clock_rate)
                + sizeof(master_clock_rate)
        );
        iface->write_eeprom(
            USRP1_EEPROM_ADDR, offsetof(usrp1_eeprom_map, mcr), rate_bytes
        );
    }
}
static void store_e100(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){

    if (mb_eeprom.has_key("vendor")) iface.write_eeprom(
        E100_EEPROM_ADDR, offsetof(e100_eeprom_map, vendor),
        to_bytes(uhd::htonx(boost::lexical_cast<boost::uint16_t>(mb_eeprom["vendor"])))
    );

    if (mb_eeprom.has_key("device")) iface.write_eeprom(
        E100_EEPROM_ADDR, offsetof(e100_eeprom_map, device),
        to_bytes(uhd::htonx(boost::lexical_cast<boost::uint16_t>(mb_eeprom["device"])))
    );

    if (mb_eeprom.has_key("revision")) iface.write_eeprom(
        E100_EEPROM_ADDR, offsetof(e100_eeprom_map, revision),
        byte_vector_t(1, boost::lexical_cast<unsigned>(mb_eeprom["revision"]))
    );

    if (mb_eeprom.has_key("content")) iface.write_eeprom(
        E100_EEPROM_ADDR, offsetof(e100_eeprom_map, content),
        byte_vector_t(1, boost::lexical_cast<unsigned>(mb_eeprom["content"]))
    );

    #define store_e100_string_xx(key) if (mb_eeprom.has_key(#key)) iface.write_eeprom( \
        E100_EEPROM_ADDR, offsetof(e100_eeprom_map, key), \
        string_to_bytes(mb_eeprom[#key], sizeof_member(e100_eeprom_map, key)) \
    );

    store_e100_string_xx(model);
    store_e100_string_xx(env_var);
    store_e100_string_xx(env_setting);
    store_e100_string_xx(serial);
    store_e100_string_xx(name);
}
static void store_b000(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
    //store the serial
    if (mb_eeprom.has_key("serial")) iface.write_eeprom(
        B000_EEPROM_ADDR, offsetof(b000_eeprom_map, serial),
        string_to_bytes(mb_eeprom["serial"], B000_SERIAL_LEN)
    );

    //store the name
    if (mb_eeprom.has_key("name")) iface.write_eeprom(
        B000_EEPROM_ADDR, offsetof(b000_eeprom_map, name),
        string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN)
    );

    //store the master clock rate as a 32-bit uint in Hz
    if (mb_eeprom.has_key("mcr")){
        boost::uint32_t master_clock_rate = boost::uint32_t(boost::lexical_cast<double>(mb_eeprom["mcr"]));
        master_clock_rate = htonl(master_clock_rate);
        const byte_vector_t rate_bytes(
            reinterpret_cast<const boost::uint8_t *>(&master_clock_rate),
            reinterpret_cast<const boost::uint8_t *>(&master_clock_rate) + sizeof(master_clock_rate)
        );
        iface.write_eeprom(
            B000_EEPROM_ADDR, offsetof(b000_eeprom_map, mcr), rate_bytes
        );
    }
}
Beispiel #5
0
void x300_impl::set_mb_eeprom(
        i2c_iface::sptr iface,
        const mboard_eeprom_t &mb_eeprom
) {
    const mboard_eeprom_t curr_eeprom = get_mb_eeprom(iface);

    // Check for duplicate MAC and IP addresses
    const std::vector<std::string> mac_keys{
        "mac-addr0",
        "mac-addr1"
    };
    const std::vector<std::string> ip_keys{
        "ip-addr0",
        "ip-addr1",
        "ip-addr2",
        "ip-addr3"
    };

    //make sure there are no duplicate values
    if (check_for_duplicates<uhd::mac_addr_t>(
        "X300", mb_eeprom, curr_eeprom,"MAC address", mac_keys) or
        check_for_duplicates<boost::asio::ip::address_v4>(
        "X300", mb_eeprom, curr_eeprom, "IP address", ip_keys))
    {
        throw uhd::value_error(
            "Duplicate values not permitted - write to EEPROM aborted");
    }

    //parse the revision number
    if (mb_eeprom.has_key("revision")) iface->write_eeprom(
        X300_EEPROM_ADDR, offsetof(x300_eeprom_map, revision),
        string_to_uint16_bytes(mb_eeprom["revision"])
    );

    //parse the revision compat number
    if (mb_eeprom.has_key("revision_compat")) iface->write_eeprom(
        X300_EEPROM_ADDR, offsetof(x300_eeprom_map, revision_compat),
        string_to_uint16_bytes(mb_eeprom["revision_compat"])
    );

    //parse the product code
    if (mb_eeprom.has_key("product")) iface->write_eeprom(
        X300_EEPROM_ADDR, offsetof(x300_eeprom_map, product),
        string_to_uint16_bytes(mb_eeprom["product"])
    );

    //store the mac addresses
    if (mb_eeprom.has_key("mac-addr0")) iface->write_eeprom(
        X300_EEPROM_ADDR, offsetof(x300_eeprom_map, mac_addr0),
        mac_addr_t::from_string(mb_eeprom["mac-addr0"]).to_bytes()
    );
    if (mb_eeprom.has_key("mac-addr1")) iface->write_eeprom(
        X300_EEPROM_ADDR, offsetof(x300_eeprom_map, mac_addr1),
        mac_addr_t::from_string(mb_eeprom["mac-addr1"]).to_bytes()
    );

    //store the ip addresses
    byte_vector_t ip_addr_bytes(4);
    if (mb_eeprom.has_key("gateway")){
        byte_copy(boost::asio::ip::address_v4::from_string(mb_eeprom["gateway"]).to_bytes(), ip_addr_bytes);
        iface->write_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, gateway), ip_addr_bytes);
    }
    for (size_t i = 0; i < 4; i++)
    {
        const std::string n(1, i+'0');
        if (mb_eeprom.has_key("ip-addr"+n)){
            byte_copy(boost::asio::ip::address_v4::from_string(mb_eeprom["ip-addr"+n]).to_bytes(), ip_addr_bytes);
            iface->write_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, ip_addr)+(i*4), ip_addr_bytes);
        }

        if (mb_eeprom.has_key("subnet"+n)){
            byte_copy(boost::asio::ip::address_v4::from_string(mb_eeprom["subnet"+n]).to_bytes(), ip_addr_bytes);
            iface->write_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, subnet)+(i*4), ip_addr_bytes);
        }
    }

    //store the serial
    if (mb_eeprom.has_key("serial")) iface->write_eeprom(
        X300_EEPROM_ADDR, offsetof(x300_eeprom_map, serial),
        string_to_bytes(mb_eeprom["serial"], SERIAL_LEN)
    );

    //store the name
    if (mb_eeprom.has_key("name")) iface->write_eeprom(
        X300_EEPROM_ADDR, offsetof(x300_eeprom_map, name),
        string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN)
    );
}
static void store_n100(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
    //parse the revision number
    if (mb_eeprom.has_key("hardware")) iface.write_eeprom(
        N100_EEPROM_ADDR, offsetof(n100_eeprom_map, hardware),
        string_to_uint16_bytes(mb_eeprom["hardware"])
    );

    //parse the revision number
    if (mb_eeprom.has_key("revision")) iface.write_eeprom(
        N100_EEPROM_ADDR, offsetof(n100_eeprom_map, revision),
        string_to_uint16_bytes(mb_eeprom["revision"])
    );

    //parse the product code
    if (mb_eeprom.has_key("product")) iface.write_eeprom(
        N100_EEPROM_ADDR, offsetof(n100_eeprom_map, product),
        string_to_uint16_bytes(mb_eeprom["product"])
    );

    //store the addresses
    if (mb_eeprom.has_key("mac-addr")) iface.write_eeprom(
        N100_EEPROM_ADDR, offsetof(n100_eeprom_map, mac_addr),
        mac_addr_t::from_string(mb_eeprom["mac-addr"]).to_bytes()
    );

    if (mb_eeprom.has_key("ip-addr")){
        byte_vector_t ip_addr_bytes(4);
        byte_copy(boost::asio::ip::address_v4::from_string(mb_eeprom["ip-addr"]).to_bytes(), ip_addr_bytes);
        iface.write_eeprom(N100_EEPROM_ADDR, offsetof(n100_eeprom_map, ip_addr), ip_addr_bytes);
    }

    if (mb_eeprom.has_key("subnet")){
        byte_vector_t ip_addr_bytes(4);
        byte_copy(boost::asio::ip::address_v4::from_string(mb_eeprom["subnet"]).to_bytes(), ip_addr_bytes);
        iface.write_eeprom(N100_EEPROM_ADDR, offsetof(n100_eeprom_map, subnet), ip_addr_bytes);
    }

    if (mb_eeprom.has_key("gateway")){
        byte_vector_t ip_addr_bytes(4);
        byte_copy(boost::asio::ip::address_v4::from_string(mb_eeprom["gateway"]).to_bytes(), ip_addr_bytes);
        iface.write_eeprom(N100_EEPROM_ADDR, offsetof(n100_eeprom_map, gateway), ip_addr_bytes);
    }

    //gpsdo capabilities
    if (mb_eeprom.has_key("gpsdo")){
        boost::uint8_t gpsdo_byte = N200_GPSDO_NONE;
        if (mb_eeprom["gpsdo"] == "internal") gpsdo_byte = N200_GPSDO_INTERNAL;
        if (mb_eeprom["gpsdo"] == "onboard") gpsdo_byte = N200_GPSDO_ONBOARD;
        iface.write_eeprom(N100_EEPROM_ADDR, offsetof(n100_eeprom_map, gpsdo), byte_vector_t(1, gpsdo_byte));
    }

    //store the serial
    if (mb_eeprom.has_key("serial")) iface.write_eeprom(
        N100_EEPROM_ADDR, offsetof(n100_eeprom_map, serial),
        string_to_bytes(mb_eeprom["serial"], SERIAL_LEN)
    );

    //store the name
    if (mb_eeprom.has_key("name")) iface.write_eeprom(
        N100_EEPROM_ADDR, offsetof(n100_eeprom_map, name),
        string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN)
    );
}
Beispiel #7
0
/***********************************************************************
 * Structors
 **********************************************************************/
e100_impl::e100_impl(const uhd::device_addr_t &device_addr){
    _tree = property_tree::make();

    //setup the main interface into fpga
    const std::string node = device_addr["node"];
    _fpga_ctrl = e100_ctrl::make(node);

    //read the eeprom so we can determine the hardware
    _dev_i2c_iface = e100_ctrl::make_dev_i2c_iface(E100_I2C_DEV_NODE);
    const mboard_eeprom_t mb_eeprom(*_dev_i2c_iface, mboard_eeprom_t::MAP_E100);

    //determine the model string for this device
    const std::string model = device_addr.get("model", mb_eeprom.get("model", ""));
    if (not model_to_fpga_file_name.has_key(model)) throw uhd::runtime_error(str(boost::format(
        "\n"
        "  The specified model string \"%s\" is not recognized.\n"
        "  Perhaps the EEPROM is uninitialized, missing, or damaged.\n"
        "  Or, a monitor is pirating the I2C address of the EEPROM.\n"
    ) % model));

    //extract the fpga path and compute hash
    const std::string default_fpga_file_name = model_to_fpga_file_name[model];
    const std::string e100_fpga_image = find_image_path(device_addr.get("fpga", default_fpga_file_name));
    const boost::uint32_t file_hash = boost::uint32_t(hash_fpga_file(e100_fpga_image));

    //When the hash does not match:
    // - close the device node
    // - load the fpga bin file
    // - re-open the device node
    if (_fpga_ctrl->peek32(E100_REG_RB_MISC_TEST32) != file_hash){
        _fpga_ctrl.reset();
        e100_load_fpga(e100_fpga_image);
        _fpga_ctrl = e100_ctrl::make(node);
    }

    //setup clock control here to ensure that the FPGA has a good clock before we continue
    bool dboard_clocks_diff = true;
    if      (mb_eeprom.get("revision", "0") == "3") dboard_clocks_diff = false;
    else if (mb_eeprom.get("revision", "0") == "4") dboard_clocks_diff = true;
    else UHD_MSG(warning)
        << "Unknown E1XX revision number!\n"
        << "defaulting to differential dboard clocks to be safe.\n"
        << std::endl;
    const double master_clock_rate = device_addr.cast<double>("master_clock_rate", E100_DEFAULT_CLOCK_RATE);
    _aux_spi_iface = e100_ctrl::make_aux_spi_iface();
    _clock_ctrl = e100_clock_ctrl::make(_aux_spi_iface, master_clock_rate, dboard_clocks_diff);

    //Perform wishbone readback tests, these tests also write the hash
    bool test_fail = false;
    UHD_MSG(status) << "Performing wishbone readback test... " << std::flush;
    for (size_t i = 0; i < 100; i++){
        _fpga_ctrl->poke32(E100_REG_SR_MISC_TEST32, file_hash);
        test_fail = _fpga_ctrl->peek32(E100_REG_RB_MISC_TEST32) != file_hash;
        if (test_fail) break; //exit loop on any failure
    }
    UHD_MSG(status) << ((test_fail)? " fail" : "pass") << std::endl;

    if (test_fail) UHD_MSG(error) << boost::format(
        "The FPGA is either clocked improperly\n"
        "or the FPGA build is not compatible.\n"
        "Subsequent errors may follow...\n"
    );

    //check that the compatibility is correct
    this->check_fpga_compat();

    ////////////////////////////////////////////////////////////////////
    // Create controller objects
    ////////////////////////////////////////////////////////////////////
    _fpga_i2c_ctrl = i2c_core_100::make(_fpga_ctrl, E100_REG_SLAVE(3));
    _fpga_spi_ctrl = spi_core_100::make(_fpga_ctrl, E100_REG_SLAVE(2));
    _data_transport = e100_make_mmap_zero_copy(_fpga_ctrl);

    ////////////////////////////////////////////////////////////////////
    // Initialize the properties tree
    ////////////////////////////////////////////////////////////////////
    _tree->create<std::string>("/name").set("E-Series Device");
    const fs_path mb_path = "/mboards/0";
    _tree->create<std::string>(mb_path / "name").set(str(boost::format("%s (euewanee)") % model));

    ////////////////////////////////////////////////////////////////////
    // setup the mboard eeprom
    ////////////////////////////////////////////////////////////////////
    _tree->create<mboard_eeprom_t>(mb_path / "eeprom")
        .set(mb_eeprom)
        .subscribe(boost::bind(&e100_impl::set_mb_eeprom, this, _1));

    ////////////////////////////////////////////////////////////////////
    // create clock control objects
    ////////////////////////////////////////////////////////////////////
    //^^^ clock created up top, just reg props here... ^^^
    _tree->create<double>(mb_path / "tick_rate")
        .publish(boost::bind(&e100_clock_ctrl::get_fpga_clock_rate, _clock_ctrl))
        .subscribe(boost::bind(&e100_impl::update_tick_rate, this, _1));

    ////////////////////////////////////////////////////////////////////
    // create codec control objects
    ////////////////////////////////////////////////////////////////////
    _codec_ctrl = e100_codec_ctrl::make(_fpga_spi_ctrl);
    const fs_path rx_codec_path = mb_path / "rx_codecs/A";
    const fs_path tx_codec_path = mb_path / "tx_codecs/A";
    _tree->create<std::string>(rx_codec_path / "name").set("ad9522");
    _tree->create<meta_range_t>(rx_codec_path / "gains/pga/range").set(e100_codec_ctrl::rx_pga_gain_range);
    _tree->create<double>(rx_codec_path / "gains/pga/value")
        .coerce(boost::bind(&e100_impl::update_rx_codec_gain, this, _1));
    _tree->create<std::string>(tx_codec_path / "name").set("ad9522");
    _tree->create<meta_range_t>(tx_codec_path / "gains/pga/range").set(e100_codec_ctrl::tx_pga_gain_range);
    _tree->create<double>(tx_codec_path / "gains/pga/value")
        .subscribe(boost::bind(&e100_codec_ctrl::set_tx_pga_gain, _codec_ctrl, _1))
        .publish(boost::bind(&e100_codec_ctrl::get_tx_pga_gain, _codec_ctrl));

    ////////////////////////////////////////////////////////////////////
    // and do the misc mboard sensors
    ////////////////////////////////////////////////////////////////////
    _tree->create<sensor_value_t>(mb_path / "sensors/ref_locked")
        .publish(boost::bind(&e100_impl::get_ref_locked, this));

    ////////////////////////////////////////////////////////////////////
    // Create the GPSDO control
    ////////////////////////////////////////////////////////////////////
    try{
        _gps = gps_ctrl::make(e100_ctrl::make_gps_uart_iface(E100_UART_DEV_NODE));
    }
    catch(std::exception &e){
        UHD_MSG(error) << "An error occurred making GPSDO control: " << e.what() << std::endl;
    }
    if (_gps.get() != NULL and _gps->gps_detected()){
        BOOST_FOREACH(const std::string &name, _gps->get_sensors()){
            _tree->create<sensor_value_t>(mb_path / "sensors" / name)
                .publish(boost::bind(&gps_ctrl::get_sensor, _gps, name));
        }
    }
Beispiel #8
0
/***********************************************************************
 * Structors
 **********************************************************************/
e100_impl::e100_impl(const uhd::device_addr_t &device_addr){
    _tree = property_tree::make();
    _type = device::USRP;
    _ignore_cal_file = device_addr.has_key("ignore-cal-file");

    //read the eeprom so we can determine the hardware
    _dev_i2c_iface = e100_ctrl::make_dev_i2c_iface(E100_I2C_DEV_NODE);
    const mboard_eeprom_t mb_eeprom(*_dev_i2c_iface, E100_EEPROM_MAP_KEY);

    //determine the model string for this device
    const std::string model = device_addr.get("model", mb_eeprom.get("model", ""));
    if (not model_to_fpga_file_name.has_key(model)) throw uhd::runtime_error(str(boost::format(
        "\n"
        "  The specified model string \"%s\" is not recognized.\n"
        "  Perhaps the EEPROM is uninitialized, missing, or damaged.\n"
        "  Or, a monitor is pirating the I2C address of the EEPROM.\n"
    ) % model));

    //extract the fpga path and compute hash
    const std::string default_fpga_file_name = model_to_fpga_file_name[model];
    std::string e100_fpga_image;
    try{
        e100_fpga_image = find_image_path(device_addr.get("fpga", default_fpga_file_name));
    }
    catch(...){
        UHD_MSG(error) << boost::format("Could not find FPGA image. %s\n") % print_utility_error("uhd_images_downloader.py");
        throw;
    }
    e100_load_fpga(e100_fpga_image);

    ////////////////////////////////////////////////////////////////////
    // Setup the FPGA clock over AUX SPI
    ////////////////////////////////////////////////////////////////////
    bool dboard_clocks_diff = true;
    if      (mb_eeprom.get("revision", "0") == "3") dboard_clocks_diff = false;
    else if (mb_eeprom.get("revision", "0") == "4") dboard_clocks_diff = true;
    else UHD_MSG(warning)
        << "Unknown E1XX revision number!\n"
        << "defaulting to differential dboard clocks to be safe.\n"
        << std::endl;
    const double master_clock_rate = device_addr.cast<double>("master_clock_rate", E100_DEFAULT_CLOCK_RATE);
    _aux_spi_iface = e100_ctrl::make_aux_spi_iface();
    _clock_ctrl = e100_clock_ctrl::make(_aux_spi_iface, master_clock_rate, dboard_clocks_diff);

    ////////////////////////////////////////////////////////////////////
    // setup the main interface into fpga
    //  - do this after aux spi, because we share gpio147
    ////////////////////////////////////////////////////////////////////
    const std::string node = device_addr["node"];
    _fpga_ctrl = e100_ctrl::make(node);

    ////////////////////////////////////////////////////////////////////
    // Initialize FPGA control communication
    ////////////////////////////////////////////////////////////////////
    fifo_ctrl_excelsior_config fifo_ctrl_config;
    fifo_ctrl_config.async_sid_base = E100_TX_ASYNC_SID;
    fifo_ctrl_config.num_async_chan = 1;
    fifo_ctrl_config.ctrl_sid_base = E100_CTRL_MSG_SID;
    fifo_ctrl_config.spi_base = TOREG(SR_SPI);
    fifo_ctrl_config.spi_rb = REG_RB_SPI;
    _fifo_ctrl = fifo_ctrl_excelsior::make(_fpga_ctrl, fifo_ctrl_config);

    //Perform wishbone readback tests, these tests also write the hash
    bool test_fail = false;
    UHD_MSG(status) << "Performing control readback test... " << std::flush;
    size_t hash = time(NULL);
    for (size_t i = 0; i < 100; i++){
        boost::hash_combine(hash, i);
        _fifo_ctrl->poke32(TOREG(SR_MISC+0), boost::uint32_t(hash));
        test_fail = _fifo_ctrl->peek32(REG_RB_CONFIG0) != boost::uint32_t(hash);
        if (test_fail) break; //exit loop on any failure
    }
    UHD_MSG(status) << ((test_fail)? " fail" : "pass") << std::endl;

    if (test_fail) UHD_MSG(error) << boost::format(
        "The FPGA is either clocked improperly\n"
        "or the FPGA build is not compatible.\n"
        "Subsequent errors may follow...\n"
    );

    //check that the compatibility is correct
    this->check_fpga_compat();

    ////////////////////////////////////////////////////////////////////
    // Create controller objects
    ////////////////////////////////////////////////////////////////////
    _fpga_i2c_ctrl = i2c_core_200::make(_fifo_ctrl, TOREG(SR_I2C), REG_RB_I2C);
    _data_transport = e100_make_mmap_zero_copy(_fpga_ctrl);

    ////////////////////////////////////////////////////////////////////
    // Initialize the properties tree
    ////////////////////////////////////////////////////////////////////
    _tree->create<std::string>("/name").set("E-Series Device");
    const fs_path mb_path = "/mboards/0";
    _tree->create<std::string>(mb_path / "name").set(model);
    _tree->create<std::string>(mb_path / "codename").set("Euwanee");

    ////////////////////////////////////////////////////////////////////
    // setup the mboard eeprom
    ////////////////////////////////////////////////////////////////////
    _tree->create<mboard_eeprom_t>(mb_path / "eeprom")
        .set(mb_eeprom)
        .subscribe(boost::bind(&e100_impl::set_mb_eeprom, this, _1));

    ////////////////////////////////////////////////////////////////////
    // create clock control objects
    ////////////////////////////////////////////////////////////////////
    //^^^ clock created up top, just reg props here... ^^^
    _tree->create<double>(mb_path / "tick_rate")
        .publish(boost::bind(&e100_clock_ctrl::get_fpga_clock_rate, _clock_ctrl))
        .subscribe(boost::bind(&fifo_ctrl_excelsior::set_tick_rate, _fifo_ctrl, _1))
        .subscribe(boost::bind(&e100_impl::update_tick_rate, this, _1));

    //subscribe the command time while we are at it
    _tree->create<time_spec_t>(mb_path / "time/cmd")
        .subscribe(boost::bind(&fifo_ctrl_excelsior::set_time, _fifo_ctrl, _1));

    ////////////////////////////////////////////////////////////////////
    // create codec control objects
    ////////////////////////////////////////////////////////////////////
    _codec_ctrl = e100_codec_ctrl::make(_fifo_ctrl/*spi*/);
    const fs_path rx_codec_path = mb_path / "rx_codecs/A";
    const fs_path tx_codec_path = mb_path / "tx_codecs/A";
    _tree->create<std::string>(rx_codec_path / "name").set("ad9522");
    _tree->create<meta_range_t>(rx_codec_path / "gains/pga/range").set(e100_codec_ctrl::rx_pga_gain_range);
    _tree->create<double>(rx_codec_path / "gains/pga/value")
        .coerce(boost::bind(&e100_impl::update_rx_codec_gain, this, _1));
    _tree->create<std::string>(tx_codec_path / "name").set("ad9522");
    _tree->create<meta_range_t>(tx_codec_path / "gains/pga/range").set(e100_codec_ctrl::tx_pga_gain_range);
    _tree->create<double>(tx_codec_path / "gains/pga/value")
        .subscribe(boost::bind(&e100_codec_ctrl::set_tx_pga_gain, _codec_ctrl, _1))
        .publish(boost::bind(&e100_codec_ctrl::get_tx_pga_gain, _codec_ctrl));

    ////////////////////////////////////////////////////////////////////
    // and do the misc mboard sensors
    ////////////////////////////////////////////////////////////////////
    _tree->create<sensor_value_t>(mb_path / "sensors/ref_locked")
        .publish(boost::bind(&e100_impl::get_ref_locked, this));

    ////////////////////////////////////////////////////////////////////
    // Create the GPSDO control
    ////////////////////////////////////////////////////////////////////
    static const fs::path GPSDO_VOLATILE_PATH("/media/ram/e100_internal_gpsdo.cache");
    if (not fs::exists(GPSDO_VOLATILE_PATH))
    {
        UHD_MSG(status) << "Detecting internal GPSDO.... " << std::flush;
        try{
            _gps = gps_ctrl::make(e100_ctrl::make_gps_uart_iface(E100_UART_DEV_NODE));
        }
        catch(std::exception &e){
            UHD_MSG(error) << "An error occurred making GPSDO control: " << e.what() << std::endl;
        }
        if (_gps and _gps->gps_detected())
        {
            BOOST_FOREACH(const std::string &name, _gps->get_sensors())
            {
                _tree->create<sensor_value_t>(mb_path / "sensors" / name)
                    .publish(boost::bind(&gps_ctrl::get_sensor, _gps, name));
            }
        }
Beispiel #9
0
static void store_x300(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface)
{
    //parse the revision number
    if (mb_eeprom.has_key("revision")) iface.write_eeprom(
        X300_EEPROM_ADDR, offsetof(x300_eeprom_map, revision),
        string_to_uint16_bytes(mb_eeprom["revision"])
    );

    //parse the revision compat number
    if (mb_eeprom.has_key("revision_compat")) iface.write_eeprom(
        X300_EEPROM_ADDR, offsetof(x300_eeprom_map, revision_compat),
        string_to_uint16_bytes(mb_eeprom["revision_compat"])
    );

    //parse the product code
    if (mb_eeprom.has_key("product")) iface.write_eeprom(
        X300_EEPROM_ADDR, offsetof(x300_eeprom_map, product),
        string_to_uint16_bytes(mb_eeprom["product"])
    );

    //store the mac addresses
    if (mb_eeprom.has_key("mac-addr0")) iface.write_eeprom(
        X300_EEPROM_ADDR, offsetof(x300_eeprom_map, mac_addr0),
        mac_addr_t::from_string(mb_eeprom["mac-addr0"]).to_bytes()
    );
    if (mb_eeprom.has_key("mac-addr1")) iface.write_eeprom(
        X300_EEPROM_ADDR, offsetof(x300_eeprom_map, mac_addr1),
        mac_addr_t::from_string(mb_eeprom["mac-addr1"]).to_bytes()
    );

    //store the ip addresses
    byte_vector_t ip_addr_bytes(4);
    if (mb_eeprom.has_key("gateway")){
        byte_copy(boost::asio::ip::address_v4::from_string(mb_eeprom["gateway"]).to_bytes(), ip_addr_bytes);
        iface.write_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, gateway), ip_addr_bytes);
    }
    for (size_t i = 0; i < 4; i++)
    {
        const std::string n(1, i+'0');
        if (mb_eeprom.has_key("ip-addr"+n)){
            byte_copy(boost::asio::ip::address_v4::from_string(mb_eeprom["ip-addr"+n]).to_bytes(), ip_addr_bytes);
            iface.write_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, ip_addr)+(i*4), ip_addr_bytes);
        }

        if (mb_eeprom.has_key("subnet"+n)){
            byte_copy(boost::asio::ip::address_v4::from_string(mb_eeprom["subnet"+n]).to_bytes(), ip_addr_bytes);
            iface.write_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, subnet)+(i*4), ip_addr_bytes);
        }
    }

    //store the serial
    if (mb_eeprom.has_key("serial")) iface.write_eeprom(
        X300_EEPROM_ADDR, offsetof(x300_eeprom_map, serial),
        string_to_bytes(mb_eeprom["serial"], SERIAL_LEN)
    );

    //store the name
    if (mb_eeprom.has_key("name")) iface.write_eeprom(
        X300_EEPROM_ADDR, offsetof(x300_eeprom_map, name),
        string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN)
    );
}