UHD
003.004.003-release
|
00001 // 00002 // Copyright 2010-2011 Ettus Research LLC 00003 // 00004 // This program is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 00018 #ifndef INCLUDED_UHD_TYPES_SERIAL_HPP 00019 #define INCLUDED_UHD_TYPES_SERIAL_HPP 00020 00021 #include <uhd/config.hpp> 00022 #include <boost/shared_ptr.hpp> 00023 #include <boost/cstdint.hpp> 00024 #include <vector> 00025 00026 namespace uhd{ 00027 00031 typedef std::vector<boost::uint8_t> byte_vector_t; 00032 00045 class UHD_API i2c_iface{ 00046 public: 00047 typedef boost::shared_ptr<i2c_iface> sptr; 00048 00054 virtual void write_i2c( 00055 boost::uint8_t addr, 00056 const byte_vector_t &buf 00057 ) = 0; 00058 00065 virtual byte_vector_t read_i2c( 00066 boost::uint8_t addr, 00067 size_t num_bytes 00068 ) = 0; 00069 00076 virtual void write_eeprom( 00077 boost::uint8_t addr, 00078 boost::uint8_t offset, 00079 const byte_vector_t &buf 00080 ); 00081 00089 virtual byte_vector_t read_eeprom( 00090 boost::uint8_t addr, 00091 boost::uint8_t offset, 00092 size_t num_bytes 00093 ); 00094 }; 00095 00100 struct UHD_API spi_config_t{ 00105 enum edge_t{ 00106 EDGE_RISE = 'r', 00107 EDGE_FALL = 'f' 00108 }; 00109 00111 edge_t mosi_edge; 00112 00114 edge_t miso_edge; 00115 00120 spi_config_t(edge_t edge = EDGE_RISE); 00121 }; 00122 00127 class UHD_API spi_iface{ 00128 public: 00129 typedef boost::shared_ptr<spi_iface> sptr; 00130 00140 virtual boost::uint32_t transact_spi( 00141 int which_slave, 00142 const spi_config_t &config, 00143 boost::uint32_t data, 00144 size_t num_bits, 00145 bool readback 00146 ) = 0; 00147 00156 virtual boost::uint32_t read_spi( 00157 int which_slave, 00158 const spi_config_t &config, 00159 boost::uint32_t data, 00160 size_t num_bits 00161 ); 00162 00170 virtual void write_spi( 00171 int which_slave, 00172 const spi_config_t &config, 00173 boost::uint32_t data, 00174 size_t num_bits 00175 ); 00176 }; 00177 00181 class UHD_API uart_iface{ 00182 public: 00183 typedef boost::shared_ptr<uart_iface> sptr; 00184 00189 virtual void write_uart(const std::string &buf) = 0; 00190 00197 virtual std::string read_uart(double timeout) = 0; 00198 }; 00199 00200 } //namespace uhd 00201 00202 #endif /* INCLUDED_UHD_TYPES_SERIAL_HPP */