diff options
author | Josh Blum <josh@joshknows.com> | 2010-03-30 14:07:19 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-03-30 14:07:19 -0700 |
commit | f9be69cae7c0fd9bca8b310ff79dd6aad958dc2b (patch) | |
tree | 42c05c3501de70c7eddf1aa46c301a6216d270f9 /host/include | |
parent | 5a08586157ed23ebc1344583d21fa56fb27cbe52 (diff) | |
download | uhd-f9be69cae7c0fd9bca8b310ff79dd6aad958dc2b.tar.gz uhd-f9be69cae7c0fd9bca8b310ff79dd6aad958dc2b.tar.bz2 uhd-f9be69cae7c0fd9bca8b310ff79dd6aad958dc2b.zip |
Added io type and otw type for describing types.
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/device.hpp | 10 | ||||
-rw-r--r-- | host/include/uhd/types/CMakeLists.txt | 2 | ||||
-rw-r--r-- | host/include/uhd/types/clock_config.hpp | 16 | ||||
-rw-r--r-- | host/include/uhd/types/io_type.hpp | 69 | ||||
-rw-r--r-- | host/include/uhd/types/otw_type.hpp | 63 |
5 files changed, 147 insertions, 13 deletions
diff --git a/host/include/uhd/device.hpp b/host/include/uhd/device.hpp index bab8afca6..1d0360799 100644 --- a/host/include/uhd/device.hpp +++ b/host/include/uhd/device.hpp @@ -21,7 +21,7 @@ #include <uhd/config.hpp> #include <uhd/types/device_addr.hpp> #include <uhd/types/metadata.hpp> -#include <uhd/props.hpp> +#include <uhd/types/io_type.hpp> #include <uhd/wax.hpp> #include <boost/utility.hpp> #include <boost/shared_ptr.hpp> @@ -91,13 +91,13 @@ public: * * \param buff a buffer pointing to some read-only memory * \param metadata data describing the buffer's contents - * \param the type of data loaded in the buffer (32fc, 16sc) + * \param io_type the type of data loaded in the buffer * \return the number of samples sent */ virtual size_t send( const boost::asio::const_buffer &buff, const tx_metadata_t &metadata, - const std::string &type = "32fc" + const io_type_t &io_type ) = 0; /*! @@ -123,13 +123,13 @@ public: * * \param buff the buffer to fill with IF data * \param metadata data to fill describing the buffer - * \param the type of data to fill into the buffer (32fc, 16sc) + * \param io_type the type of data to fill into the buffer * \return the number of samples received */ virtual size_t recv( const boost::asio::mutable_buffer &buff, rx_metadata_t &metadata, - const std::string &type = "32fc" + const io_type_t &io_type ) = 0; }; diff --git a/host/include/uhd/types/CMakeLists.txt b/host/include/uhd/types/CMakeLists.txt index 10262dd65..e4cdf2cef 100644 --- a/host/include/uhd/types/CMakeLists.txt +++ b/host/include/uhd/types/CMakeLists.txt @@ -20,8 +20,10 @@ INSTALL(FILES clock_config.hpp device_addr.hpp dict.hpp + io_type.hpp mac_addr.hpp metadata.hpp + otw_type.hpp ranges.hpp stream_cmd.hpp time_spec.hpp diff --git a/host/include/uhd/types/clock_config.hpp b/host/include/uhd/types/clock_config.hpp index 8b2fea016..42d74ad90 100644 --- a/host/include/uhd/types/clock_config.hpp +++ b/host/include/uhd/types/clock_config.hpp @@ -29,18 +29,18 @@ namespace uhd{ */ struct UHD_API clock_config_t{ enum ref_source_t { - REF_INT, //internal reference - REF_SMA, //external sma port - REF_MIMO //mimo cable (usrp2 only) + REF_INT = 'i', //internal reference + REF_SMA = 's', //external sma port + REF_MIMO = 'm' //mimo cable (usrp2 only) } ref_source; enum pps_source_t { - PPS_INT, //there is no internal - PPS_SMA, //external sma port - PPS_MIMO //mimo cable (usrp2 only) + PPS_INT = 'i', //there is no internal + PPS_SMA = 's', //external sma port + PPS_MIMO = 'm' //mimo cable (usrp2 only) } pps_source; enum pps_polarity_t { - PPS_NEG, //negative edge - PPS_POS //positive edge + PPS_NEG = 'n', //negative edge + PPS_POS = 'p' //positive edge } pps_polarity; clock_config_t(void); }; diff --git a/host/include/uhd/types/io_type.hpp b/host/include/uhd/types/io_type.hpp new file mode 100644 index 000000000..930394d1b --- /dev/null +++ b/host/include/uhd/types/io_type.hpp @@ -0,0 +1,69 @@ +// +// 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_UHD_TYPES_IO_TYPE_HPP +#define INCLUDED_UHD_TYPES_IO_TYPE_HPP + +#include <uhd/config.hpp> + +namespace uhd{ + + /*! + * Used to specify the IO type with device send/recv. + */ + class UHD_API io_type_t{ + public: + + /*! + * Built in IO types known to the system. + */ + enum tid_t{ + CUSTOM_TYPE = '?', + COMPLEX_FLOAT32 = 'f', + COMPLEX_INT16 = 's', + COMPLEX_INT8 = 'b' + }; + + /*! + * The size of this io type in bytes. + */ + const size_t size; + + /*! + * The type id of this io type. + * Good for using with switch statements. + */ + const tid_t tid; + + /*! + * Create an io type from a built-in type id. + * \param tid a type id known to the system + */ + io_type_t(tid_t tid); + + /*! + * Create an io type from attributes. + * The tid will be set to custom. + * \param size the size in bytes + */ + io_type_t(size_t size); + + }; + +} //namespace uhd + +#endif /* INCLUDED_UHD_TYPES_IO_TYPE_HPP */ diff --git a/host/include/uhd/types/otw_type.hpp b/host/include/uhd/types/otw_type.hpp new file mode 100644 index 000000000..f10664584 --- /dev/null +++ b/host/include/uhd/types/otw_type.hpp @@ -0,0 +1,63 @@ +// +// 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_UHD_TYPES_OTW_TYPE_HPP +#define INCLUDED_UHD_TYPES_OTW_TYPE_HPP + +#include <uhd/config.hpp> + +namespace uhd{ + + /*! + * Description for over-the-wire integers: + * The DSP units in the FPGA deal with signed 16-bit integers. + * The width and shift define the translation between OTW and DSP, + * defined by the following relation: otw_int = dsp_int >> shift + * + * Note: possible combinations of width, shift, and byteorder + * depend on the internals of the FPGA. Not all are supported! + */ + struct UHD_API otw_type_t{ + + /*! + * Width of an over-the-wire integer in bits. + */ + size_t width; //in bits + + /*! + * Shift of an over-the-wire integer in bits. + * otw_int = dsp_int >> shift + * dsp_int = otw_int << shift + */ + size_t shift; //in bits + + /*! + * Constants for byte order (borrowed from numpy's dtype) + */ + enum /*bo_t*/ { + BO_NATIVE = '=', + BO_LITTLE_ENDIAN = '<', + BO_BIG_ENDIAN = '>', + BO_NOT_APPLICABLE = '|' + } byteorder; + + otw_type_t(void); + }; + +} //namespace uhd + +#endif /* INCLUDED_UHD_TYPES_OTW_TYPE_HPP */ |