UHD 003.001.000
|
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/cstdint.hpp> 00023 #include <vector> 00024 00025 namespace uhd{ 00026 00030 typedef std::vector<boost::uint8_t> byte_vector_t; 00031 00044 class UHD_API i2c_iface{ 00045 public: 00051 virtual void write_i2c( 00052 boost::uint8_t addr, 00053 const byte_vector_t &buf 00054 ) = 0; 00055 00062 virtual byte_vector_t read_i2c( 00063 boost::uint8_t addr, 00064 size_t num_bytes 00065 ) = 0; 00066 00073 virtual void write_eeprom( 00074 boost::uint8_t addr, 00075 boost::uint8_t offset, 00076 const byte_vector_t &buf 00077 ); 00078 00086 virtual byte_vector_t read_eeprom( 00087 boost::uint8_t addr, 00088 boost::uint8_t offset, 00089 size_t num_bytes 00090 ); 00091 }; 00092 00097 struct UHD_API spi_config_t{ 00102 enum edge_t{ 00103 EDGE_RISE = 'r', 00104 EDGE_FALL = 'f' 00105 }; 00106 00108 edge_t mosi_edge; 00109 00111 edge_t miso_edge; 00112 00117 spi_config_t(edge_t edge = EDGE_RISE); 00118 }; 00119 00124 class UHD_API spi_iface{ 00125 public: 00135 virtual boost::uint32_t transact_spi( 00136 int which_slave, 00137 const spi_config_t &config, 00138 boost::uint32_t data, 00139 size_t num_bits, 00140 bool readback 00141 ) = 0; 00142 00151 virtual boost::uint32_t read_spi( 00152 int which_slave, 00153 const spi_config_t &config, 00154 boost::uint32_t data, 00155 size_t num_bits 00156 ); 00157 00165 virtual void write_spi( 00166 int which_slave, 00167 const spi_config_t &config, 00168 boost::uint32_t data, 00169 size_t num_bits 00170 ); 00171 }; 00172 00173 } //namespace uhd 00174 00175 #endif /* INCLUDED_UHD_TYPES_SERIAL_HPP */