aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/examples/test_pps_input.cpp10
-rw-r--r--host/lib/transport/CMakeLists.txt3
-rw-r--r--host/lib/transport/include/stdint.h35
-rw-r--r--host/lib/transport/libusb1_base.cpp2
-rw-r--r--host/lib/transport/libusb1_device_handle.cpp18
-rw-r--r--host/lib/transport/libusb1_zero_copy.cpp3
-rw-r--r--host/lib/usrp/usrp1/codec_ctrl.cpp4
-rw-r--r--host/lib/usrp/usrp1/dsp_impl.cpp10
-rw-r--r--host/lib/usrp/usrp1/io_impl.cpp4
-rw-r--r--host/lib/usrp/usrp1/usrp1_ctrl.cpp21
-rw-r--r--host/lib/usrp/usrp1/usrp1_iface.cpp4
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.cpp2
12 files changed, 76 insertions, 40 deletions
diff --git a/host/examples/test_pps_input.cpp b/host/examples/test_pps_input.cpp
index d1b49d320..4b2bb62a3 100644
--- a/host/examples/test_pps_input.cpp
+++ b/host/examples/test_pps_input.cpp
@@ -31,7 +31,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//variables to be set by po
std::string args;
- float seconds;
+ double seconds;
//setup the program options
po::options_description desc("Allowed options");
@@ -60,20 +60,20 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
std::cout << "Set time to known value (100.0) without regard to pps:" << std::endl;
sdev->set_time_now(uhd::time_spec_t(100.0));
boost::this_thread::sleep(boost::posix_time::seconds(1));
- std::cout << boost::format("Reading time 1 second later: %f\n") % (sdev->get_time_now().get_full_secs()) << std::endl;
+ std::cout << boost::format("Reading time 1 second later: %f\n") % (sdev->get_time_now().get_real_secs()) << std::endl;
//store the time to see if PPS resets it
- seconds = sdev->get_time_now().get_full_secs();
+ seconds = sdev->get_time_now().get_real_secs();
//set a known time at next PPS, check that time increments
uhd::time_spec_t time_spec = uhd::time_spec_t(0.0);
std::cout << "Set time to known value (0.0) at next pps:" << std::endl;
sdev->set_time_next_pps(time_spec);
boost::this_thread::sleep(boost::posix_time::seconds(1));
- std::cout << boost::format("Reading time 1 second later: %f\n") % (sdev->get_time_now().get_full_secs()) << std::endl;
+ std::cout << boost::format("Reading time 1 second later: %f\n") % (sdev->get_time_now().get_real_secs()) << std::endl;
//finished
- if (seconds > sdev->get_time_now().get_full_secs()){
+ if (seconds > sdev->get_time_now().get_real_secs()){
std::cout << std::endl << "Success!" << std::endl << std::endl;
return 0;
} else {
diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt
index acd699fc5..92c9f3181 100644
--- a/host/lib/transport/CMakeLists.txt
+++ b/host/lib/transport/CMakeLists.txt
@@ -33,6 +33,9 @@ IF(LIBUSB_FOUND)
${CMAKE_SOURCE_DIR}/lib/transport/libusb1_base.hpp
${CMAKE_SOURCE_DIR}/lib/transport/libusb1_device_handle.cpp
)
+ IF(WIN32) #include our custom stdint for libusb
+ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/transport/include)
+ ENDIF(WIN32)
SET(HAVE_USB_SUPPORT TRUE)
ENDIF(LIBUSB_FOUND)
diff --git a/host/lib/transport/include/stdint.h b/host/lib/transport/include/stdint.h
new file mode 100644
index 000000000..b3eb61aae
--- /dev/null
+++ b/host/lib/transport/include/stdint.h
@@ -0,0 +1,35 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_LIBUHD_TRANSPORT_STDINT_H
+#define INCLUDED_LIBUHD_TRANSPORT_STDINT_H
+
+#include <boost/cstdint.hpp>
+
+//provide a stdint implementation for libusb
+
+typedef boost::uint64_t uint64_t;
+typedef boost::uint32_t uint32_t;
+typedef boost::uint16_t uint16_t;
+typedef boost::uint8_t uint8_t;
+
+typedef boost::int64_t int64_t;
+typedef boost::int32_t int32_t;
+typedef boost::int16_t int16_t;
+typedef boost::int8_t int8_t;
+
+#endif /* INCLUDED_LIBUHD_TRANSPORT_STDINT_H */
diff --git a/host/lib/transport/libusb1_base.cpp b/host/lib/transport/libusb1_base.cpp
index e21c39aa3..1f816c6e2 100644
--- a/host/lib/transport/libusb1_base.cpp
+++ b/host/lib/transport/libusb1_base.cpp
@@ -67,7 +67,7 @@ bool libusb::compare_device(libusb_device *dev,
std::string serial = handle->get_serial();
boost::uint16_t vendor_id = handle->get_vendor_id();
boost::uint16_t product_id = handle->get_product_id();
- boost::uint8_t device_addr = handle->get_device_addr();
+ boost::uint16_t device_addr = handle->get_device_addr();
libusb_device_descriptor libusb_desc;
if (libusb_get_device_descriptor(dev, &libusb_desc) < 0)
diff --git a/host/lib/transport/libusb1_device_handle.cpp b/host/lib/transport/libusb1_device_handle.cpp
index 43d0f0e26..7efddd410 100644
--- a/host/lib/transport/libusb1_device_handle.cpp
+++ b/host/lib/transport/libusb1_device_handle.cpp
@@ -29,9 +29,9 @@ const int libusb_debug_level = 0;
class libusb1_device_handle_impl : public usb_device_handle {
public:
libusb1_device_handle_impl(std::string serial,
- boost::uint32_t product_id,
- boost::uint32_t vendor_id,
- boost::uint32_t device_addr)
+ boost::uint16_t product_id,
+ boost::uint16_t vendor_id,
+ boost::uint16_t device_addr)
: _serial(serial), _product_id(product_id),
_vendor_id(vendor_id), _device_addr(device_addr)
{
@@ -66,9 +66,9 @@ public:
private:
std::string _serial;
- boost::uint32_t _product_id;
- boost::uint32_t _vendor_id;
- boost::uint32_t _device_addr;
+ boost::uint16_t _product_id;
+ boost::uint16_t _vendor_id;
+ boost::uint16_t _device_addr;
};
@@ -81,9 +81,9 @@ usb_device_handle::sptr make_usb_device_handle(libusb_device *dev)
}
std::string serial = libusb::get_serial(dev);
- boost::uint32_t product_id = desc.idProduct;
- boost::uint32_t vendor_id = desc.idVendor;
- boost::uint32_t device_addr = libusb_get_device_address(dev);
+ boost::uint16_t product_id = desc.idProduct;
+ boost::uint16_t vendor_id = desc.idVendor;
+ boost::uint16_t device_addr = libusb_get_device_address(dev);
return usb_device_handle::sptr(new libusb1_device_handle_impl(
serial,
diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp
index b890a87f9..b3a160462 100644
--- a/host/lib/transport/libusb1_zero_copy.cpp
+++ b/host/lib/transport/libusb1_zero_copy.cpp
@@ -18,7 +18,6 @@
#include "libusb1_base.hpp"
#include <uhd/transport/usb_zero_copy.hpp>
#include <uhd/utils/assert.hpp>
-#include <boost/asio.hpp>
#include <boost/format.hpp>
#include <iostream>
#include <iomanip>
@@ -208,7 +207,7 @@ libusb_transfer *usb_endpoint::allocate_transfer(int buff_len)
endpoint, // endpoint
buff, // buffer
buff_len, // length
- callback, // callback
+ libusb_transfer_cb_fn(callback), // callback
this, // user_data
0); // timeout
return lut;
diff --git a/host/lib/usrp/usrp1/codec_ctrl.cpp b/host/lib/usrp/usrp1/codec_ctrl.cpp
index 08f2d2a8e..ad16f6b3a 100644
--- a/host/lib/usrp/usrp1/codec_ctrl.cpp
+++ b/host/lib/usrp/usrp1/codec_ctrl.cpp
@@ -126,7 +126,7 @@ usrp1_codec_ctrl_impl::usrp1_codec_ctrl_impl(usrp1_iface::sptr iface,
_ad9862_regs.clkout2_div_factor = ad9862_regs_t::CLKOUT2_DIV_FACTOR_2;
//write the register settings to the codec
- for (uint8_t addr = 0; addr <= 25; addr++) {
+ for (boost::uint8_t addr = 0; addr <= 25; addr++) {
this->send_reg(addr);
}
@@ -199,7 +199,7 @@ float usrp1_codec_ctrl_impl::get_rx_pga_gain(char which){
**********************************************************************/
static float aux_adc_to_volts(boost::uint8_t high, boost::uint8_t low)
{
- return float((boost::uint16_t(high) << 2) | low)*3.3/0x3ff;
+ return float(((boost::uint16_t(high) << 2) | low)*3.3)/0x3ff;
}
float usrp1_codec_ctrl_impl::read_aux_adc(aux_adc_t which)
diff --git a/host/lib/usrp/usrp1/dsp_impl.cpp b/host/lib/usrp/usrp1/dsp_impl.cpp
index 573bce21f..e9a5e60a6 100644
--- a/host/lib/usrp/usrp1/dsp_impl.cpp
+++ b/host/lib/usrp/usrp1/dsp_impl.cpp
@@ -107,8 +107,7 @@ void usrp1_impl::rx_dsp_set(const wax::obj &key_, const wax::obj &val){
return;
}
case DSP_PROP_HOST_RATE: {
- unsigned int rate =
- _clock_ctrl->get_master_clock_freq() / val.as<double>();
+ size_t rate = size_t(_clock_ctrl->get_master_clock_freq() / val.as<double>());
if ((rate & 0x01) || (rate < 4) || (rate > 256)) {
std::cerr << "Decimation must be even and between 4 and 256"
@@ -118,7 +117,7 @@ void usrp1_impl::rx_dsp_set(const wax::obj &key_, const wax::obj &val){
_rx_dsp_decim = rate;
//TODO Poll every 100ms. Make it selectable?
- _rx_samps_per_poll_interval = 0.1 * _clock_ctrl->get_master_clock_freq() / rate;
+ _rx_samps_per_poll_interval = size_t(0.1 * _clock_ctrl->get_master_clock_freq() / rate);
_iface->poke32(FR_DECIM_RATE, _rx_dsp_decim/2 - 1);
}
@@ -207,8 +206,7 @@ void usrp1_impl::tx_dsp_set(const wax::obj &key_, const wax::obj &val){
}
case DSP_PROP_HOST_RATE: {
- unsigned int rate =
- _clock_ctrl->get_master_clock_freq() * 2 / val.as<double>();
+ size_t rate = size_t(_clock_ctrl->get_master_clock_freq() * 2 / val.as<double>());
if ((rate & 0x01) || (rate < 8) || (rate > 512)) {
std::cerr << "Interpolation rate must be even and between 8 and 512"
@@ -219,7 +217,7 @@ void usrp1_impl::tx_dsp_set(const wax::obj &key_, const wax::obj &val){
_tx_dsp_interp = rate;
//TODO Poll every 100ms. Make it selectable?
- _tx_samps_per_poll_interval = 0.1 * _clock_ctrl->get_master_clock_freq() * 2 / rate;
+ _tx_samps_per_poll_interval = size_t(0.1 * _clock_ctrl->get_master_clock_freq() * 2 / rate);
_iface->poke32(FR_INTERP_RATE, _tx_dsp_interp / 4 - 1);
return;
diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp
index 146038bd9..73974f2d6 100644
--- a/host/lib/usrp/usrp1/io_impl.cpp
+++ b/host/lib/usrp/usrp1/io_impl.cpp
@@ -184,7 +184,7 @@ bool usrp1_impl::io_impl::get_send_buffs(
));
}
- return buffs[0].get();
+ return buffs[0].get() != NULL;
}
/***********************************************************************
@@ -277,7 +277,7 @@ static bool get_recv_buffs(
){
UHD_ASSERT_THROW(buffs.size() == 1);
buffs[0] = zc_if->get_recv_buff();
- return buffs[0].get();
+ return buffs[0].get() != NULL;
}
size_t usrp1_impl::recv(
diff --git a/host/lib/usrp/usrp1/usrp1_ctrl.cpp b/host/lib/usrp/usrp1/usrp1_ctrl.cpp
index 451129ef5..1dc6e6e25 100644
--- a/host/lib/usrp/usrp1/usrp1_ctrl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_ctrl.cpp
@@ -249,45 +249,46 @@ public:
unsigned char buf[ep0_size];
int ret;
- FILE *fp;
- if ((fp = fopen(filename, "rb")) == NULL) {
+ std::ifstream file;
+ file.open(filename, std::ios::in | std::ios::binary);
+ if (not file.good()) {
std::cerr << "cannot open fpga input file" << std::endl;
- fclose(fp);
+ file.close();
return -1;
}
if (usrp_control_write_cmd(VRQ_FPGA_LOAD, 0, FL_BEGIN) < 0) {
std::cerr << "fpga load error" << std::endl;
- fclose(fp);
+ file.close();
return -1;
}
ssize_t n;
- while ((n = fread(buf, 1, sizeof(buf), fp)) > 0) {
+ while ((n = file.readsome((char *)buf, sizeof(buf))) > 0) {
ret = usrp_control_write(VRQ_FPGA_LOAD, 0, FL_XFER,
buf, n);
if (ret != n) {
std::cerr << "fpga load error " << ret << std::endl;
- fclose(fp);
+ file.close();
return -1;
}
}
if (usrp_control_write_cmd(VRQ_FPGA_LOAD, 0, FL_END) < 0) {
std::cerr << "fpga load error" << std::endl;
- fclose(fp);
+ file.close();
return -1;
}
usrp_set_fpga_hash(hash);
- fclose(fp);
+ file.close();
return 0;
}
int usrp_load_eeprom(std::string filestring)
{
const char *filename = filestring.c_str();
- const uint16_t i2c_addr = 0x50;
+ const boost::uint16_t i2c_addr = 0x50;
//FIXME: verify types
int len;
@@ -416,7 +417,7 @@ public:
}
- int usrp_control_write_cmd(uint8_t request, uint16_t value, uint16_t index)
+ int usrp_control_write_cmd(boost::uint8_t request, boost::uint16_t value, boost::uint16_t index)
{
return usrp_control_write(request, value, index, 0, 0);
}
diff --git a/host/lib/usrp/usrp1/usrp1_iface.cpp b/host/lib/usrp/usrp1/usrp1_iface.cpp
index 4bc18dd16..5fd3987d5 100644
--- a/host/lib/usrp/usrp1/usrp1_iface.cpp
+++ b/host/lib/usrp/usrp1/usrp1_iface.cpp
@@ -80,7 +80,7 @@ public:
boost::uint32_t peek32(boost::uint32_t addr)
{
- uint32_t value_out;
+ boost::uint32_t value_out;
boost::uint8_t w_index_h = SPI_ENABLE_FPGA & 0xff;
boost::uint8_t w_index_l = (SPI_FMT_MSB | SPI_FMT_HDR_1) & 0xff;
@@ -100,7 +100,7 @@ public:
boost::uint16_t peek16(boost::uint32_t addr)
{
- uint32_t val = peek32(addr);
+ boost::uint32_t val = peek32(addr);
return boost::uint16_t(val & 0xff);
}
diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp
index a6806dbc3..627180b11 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.cpp
@@ -62,7 +62,7 @@ static device_addrs_t usrp1_find(const device_addr_t &hint)
hint.has_key("fw")? hint["fw"] : "usrp1_fw.ihx"
);
}
- catch(const std::exception &e){
+ catch(...){
uhd::print_warning(
"Could not locate USRP1 firmware.\n"
"Please install the images package.\n"