aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-01-11 19:44:46 -0800
committerJosh Blum <josh@joshknows.com>2011-01-11 19:44:46 -0800
commit18defbd9d40a4c11a33025c8684f48fe51f102c5 (patch)
tree0108636abe7a42f1c3de22043e7ef230dec89cba /host/lib
parent6c03f7e74bf7fcbfbcbc02de89aac9550097afc9 (diff)
downloaduhd-18defbd9d40a4c11a33025c8684f48fe51f102c5.tar.gz
uhd-18defbd9d40a4c11a33025c8684f48fe51f102c5.tar.bz2
uhd-18defbd9d40a4c11a33025c8684f48fe51f102c5.zip
uhd: add msvc stdint.h so we can use stdints typedefs normally like, fix in fw_common.h
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/gain_group.cpp149
-rw-r--r--host/lib/transport/CMakeLists.txt3
-rw-r--r--host/lib/transport/msvc/stdint.h35
-rw-r--r--host/lib/usrp/usrp2/fw_common.h48
4 files changed, 22 insertions, 213 deletions
diff --git a/host/lib/gain_group.cpp b/host/lib/gain_group.cpp
deleted file mode 100644
index 1be09dee2..000000000
--- a/host/lib/gain_group.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-//
-// 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/>.
-//
-
-#include <uhd/utils/gain_group.hpp>
-#include <uhd/types/dict.hpp>
-#include <uhd/utils/algorithm.hpp>
-#include <uhd/utils/assert.hpp>
-#include <boost/foreach.hpp>
-#include <boost/bind.hpp>
-#include <algorithm>
-#include <vector>
-#include <iostream>
-
-using namespace uhd;
-
-static const bool verbose = false;
-
-static bool compare_by_step_size(
- const size_t &rhs, const size_t &lhs, std::vector<gain_fcns_t> &fcns
-){
- return fcns.at(rhs).get_range().step > fcns.at(lhs).get_range().step;
-}
-
-/***********************************************************************
- * gain group implementation
- **********************************************************************/
-class gain_group_impl : public gain_group{
-public:
- gain_group_impl(void){
- /*NOP*/
- }
-
- gain_range_t get_range(void){
- float overall_min = 0, overall_max = 0, overall_step = 0;
- BOOST_FOREACH(const gain_fcns_t &fcns, get_all_fcns()){
- const gain_range_t range = fcns.get_range();
- overall_min += range.min;
- overall_max += range.max;
- //the overall step is the min (zero is invalid, first run)
- if (overall_step == 0) overall_step = range.step;
- overall_step = std::min(overall_step, range.step);
- }
- return gain_range_t(overall_min, overall_max, overall_step);
- }
-
- float get_value(void){
- float overall_gain = 0;
- BOOST_FOREACH(const gain_fcns_t &fcns, get_all_fcns()){
- overall_gain += fcns.get_value();
- }
- return overall_gain;
- }
-
- void set_value(float gain){
- std::vector<gain_fcns_t> all_fcns = get_all_fcns();
- if (all_fcns.size() == 0) return; //nothing to set!
-
- //get the max step size among the gains
- float max_step = 0;
- BOOST_FOREACH(const gain_fcns_t &fcns, all_fcns){
- max_step = std::max(max_step, fcns.get_range().step);
- }
-
- //create gain bucket to distribute power
- std::vector<float> gain_bucket;
-
- //distribute power according to priority (round to max step)
- float gain_left_to_distribute = gain;
- BOOST_FOREACH(const gain_fcns_t &fcns, all_fcns){
- const gain_range_t range = fcns.get_range();
- gain_bucket.push_back(
- max_step*int(std::clip(gain_left_to_distribute, range.min, range.max)/max_step)
- );
- gain_left_to_distribute -= gain_bucket.back();
- }
-
- //get a list of indexes sorted by step size large to small
- std::vector<size_t> indexes_step_size_dec;
- for (size_t i = 0; i < all_fcns.size(); i++){
- indexes_step_size_dec.push_back(i);
- }
- std::sort(
- indexes_step_size_dec.begin(), indexes_step_size_dec.end(),
- boost::bind(&compare_by_step_size, _1, _2, all_fcns)
- );
- UHD_ASSERT_THROW(
- all_fcns.at(indexes_step_size_dec.front()).get_range().step >=
- all_fcns.at(indexes_step_size_dec.back()).get_range().step
- );
-
- //distribute the remainder (less than max step)
- //fill in the largest step sizes first that are less than the remainder
- BOOST_FOREACH(size_t i, indexes_step_size_dec){
- const gain_range_t range = all_fcns.at(i).get_range();
- float additional_gain = range.step*int(
- std::clip(gain_bucket.at(i) + gain_left_to_distribute, range.min, range.max
- )/range.step) - gain_bucket.at(i);
- gain_bucket.at(i) += additional_gain;
- gain_left_to_distribute -= additional_gain;
- }
- if (verbose) std::cout << "gain_left_to_distribute " << gain_left_to_distribute << std::endl;
-
- //now write the bucket out to the individual gain values
- for (size_t i = 0; i < gain_bucket.size(); i++){
- if (verbose) std::cout << gain_bucket.at(i) << std::endl;
- all_fcns.at(i).set_value(gain_bucket.at(i));
- }
- }
-
- void register_fcns(
- const gain_fcns_t &gain_fcns, size_t priority
- ){
- _registry[priority].push_back(gain_fcns);
- }
-
-private:
- //! get the gain function sets in order (highest priority first)
- std::vector<gain_fcns_t> get_all_fcns(void){
- std::vector<gain_fcns_t> all_fcns;
- BOOST_FOREACH(ssize_t key, std::sorted(_registry.keys())){
- const std::vector<gain_fcns_t> &fcns = _registry[key];
- all_fcns.insert(all_fcns.begin(), fcns.begin(), fcns.end());
- }
- return all_fcns;
- }
-
- uhd::dict<size_t, std::vector<gain_fcns_t> > _registry;
-};
-
-/***********************************************************************
- * gain group factory function
- **********************************************************************/
-gain_group::sptr gain_group::make(void){
- return sptr(new gain_group_impl());
-}
diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt
index 67865e0fe..8765c6703 100644
--- a/host/lib/transport/CMakeLists.txt
+++ b/host/lib/transport/CMakeLists.txt
@@ -37,9 +37,6 @@ IF(ENABLE_USB)
${CMAKE_CURRENT_SOURCE_DIR}/libusb1_base.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libusb1_base.hpp
)
- IF(MSVC) #include our custom stdint for libusb
- INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/msvc)
- ENDIF(MSVC)
ELSE(ENABLE_USB)
LIBUHD_APPEND_SOURCES(
${CMAKE_CURRENT_SOURCE_DIR}/usb_dummy_impl.cpp
diff --git a/host/lib/transport/msvc/stdint.h b/host/lib/transport/msvc/stdint.h
deleted file mode 100644
index b3eb61aae..000000000
--- a/host/lib/transport/msvc/stdint.h
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// 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/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h
index 67ba90658..a22f805e1 100644
--- a/host/lib/usrp/usrp2/fw_common.h
+++ b/host/lib/usrp/usrp2/fw_common.h
@@ -18,18 +18,15 @@
#ifndef INCLUDED_USRP2_FW_COMMON_H
#define INCLUDED_USRP2_FW_COMMON_H
+#include <stdint.h>
+
/*!
* Structs and constants for usrp2 communication.
* This header is shared by the firmware and host code.
* Therefore, this header may only contain valid C code.
*/
#ifdef __cplusplus
- #include <boost/cstdint.hpp>
- #define __stdint(type) boost::type
extern "C" {
-#else
- #include <stdint.h>
- #define __stdint(type) type
#endif
//fpga and firmware compatibility numbers
@@ -106,39 +103,38 @@ typedef enum{
} usrp2_clk_edge_t;
typedef struct{
- __stdint(uint32_t) proto_ver;
- __stdint(uint32_t) id;
- __stdint(uint32_t) seq;
+ uint32_t proto_ver;
+ uint32_t id;
+ uint32_t seq;
union{
- __stdint(uint32_t) ip_addr;
+ uint32_t ip_addr;
struct {
- __stdint(uint32_t) dev;
- __stdint(uint32_t) data;
- __stdint(uint8_t) miso_edge;
- __stdint(uint8_t) mosi_edge;
- __stdint(uint8_t) num_bits;
- __stdint(uint8_t) readback;
+ uint32_t dev;
+ uint32_t data;
+ uint8_t miso_edge;
+ uint8_t mosi_edge;
+ uint8_t num_bits;
+ uint8_t readback;
} spi_args;
struct {
- __stdint(uint8_t) addr;
- __stdint(uint8_t) bytes;
- __stdint(uint8_t) data[20];
+ uint8_t addr;
+ uint8_t bytes;
+ uint8_t data[20];
} i2c_args;
struct {
- __stdint(uint32_t) addr;
- __stdint(uint32_t) data;
- __stdint(uint32_t) _pad[2];
- __stdint(uint8_t) num_bytes; //1, 2, 4
+ uint32_t addr;
+ uint32_t data;
+ uint32_t _pad[2];
+ uint8_t num_bytes; //1, 2, 4
} poke_args;
struct {
- __stdint(uint8_t) dev;
- __stdint(uint8_t) bytes;
- __stdint(uint8_t) data[20];
+ uint8_t dev;
+ uint8_t bytes;
+ uint8_t data[20];
} uart_args;
} data;
} usrp2_ctrl_data_t;
-#undef __stdint
#ifdef __cplusplus
}
#endif